Skip to content

Commit

Permalink
Version 0.10.0 Alpha.4 [Prerelease]
Browse files Browse the repository at this point in the history
Warning: This commit hash may not be preserved!

Debug state: The new LOD and LOD Crossfade have been tested in a simple setup. However, no performance testing or usage at scale has been done.
  • Loading branch information
Dreaming381 committed Apr 14, 2024
1 parent 9cd3240 commit cd34426
Show file tree
Hide file tree
Showing 27 changed files with 1,008 additions and 685 deletions.
5 changes: 2 additions & 3 deletions Calligraphics/Authoring/LatiosTextBackendBakingUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static void BakeTextBackendMeshAndMaterial(this IBaker baker, Renderer re
{
var mesh = Resources.Load<Mesh>(kTextBackendMeshResource);

RenderingBakingTools.GetLOD(baker, renderer, out var lodGroupEntity, out var lodMask);
RenderingBakingTools.GetLOD(baker, renderer, out var lodSettings);

var rendererSettings = new MeshRendererBakeSettings
{
Expand All @@ -30,8 +30,7 @@ public static void BakeTextBackendMeshAndMaterial(this IBaker baker, Renderer re
useLightmapsIfPossible = true,
lightmapIndex = renderer.lightmapIndex,
lightmapScaleOffset = renderer.lightmapScaleOffset,
lodGroupEntity = lodGroupEntity,
lodGroupMask = lodMask,
lodSettings = lodSettings,
isStatic = baker.IsStatic(),
localBounds = default,
};
Expand Down
58 changes: 37 additions & 21 deletions Calligraphics/Fonts/LiberationSans SDF.asset
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ Material:
type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_ValidKeywords:
- _ALPHATEST_ON
- _SURFACE_TYPE_TRANSPARENT
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
stringTagMap:
RenderType: Transparent
disabledShaderPasses:
- DepthOnly
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
Expand Down Expand Up @@ -54,16 +58,22 @@ Material:
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _AlphaClip: 1
- _AlphaToMask: 0
- _Ambient: 0.3
- _BevelAmount: 0
- _BevelClamp: 0
- _BevelOffset: 0
- _BevelRoundness: 0
- _BevelType: 0
- _BevelWidth: 0
- _Blend: 0
- _CastShadows: 1
- _ColorMask: 15
- _Cull: 0
- _CullMode: 0
- _Diffuse: 0.3
- _DstBlend: 10
- _FaceDilate: 0
- _GradientScale: 10
- _LightAngle: 0
Expand All @@ -87,11 +97,13 @@ Material:
- _ShaderFlags: 0
- _Sharpness: 0
- _SpecularPower: 0
- _SrcBlend: 5
- _Stencil: 0
- _StencilComp: 8
- _StencilOp: 0
- _StencilReadMask: 255
- _StencilWriteMask: 255
- _Surface: 1
- _TextureHeight: 1024
- _TextureWidth: 1024
- _UnderlayDilate: 0
Expand All @@ -102,6 +114,10 @@ Material:
- _VertexOffsetY: 0
- _WeightBold: 0.75
- _WeightNormal: 0
- _ZTest: 4
- _ZWrite: 0
- _ZWriteControl: 0
- _latiosTextGlyphMaskBase: 0
m_Colors:
- _ClipRect: {r: -32767, g: -32767, b: 32767, a: 32767}
- _FaceColor: {r: 1, g: 1, b: 1, a: 1}
Expand Down Expand Up @@ -137,6 +153,24 @@ MonoBehaviour:
m_Version: 1.1.0
m_Material: {fileID: -658778759613031741}
m_SourceFontFileGUID: e3265ab4bf004d28a9537516768c1c75
m_fontAssetCreationEditorSettings:
sourceFontFileGUID: e3265ab4bf004d28a9537516768c1c75
faceIndex: 0
pointSizeSamplingMode: 0
pointSize: 84
padding: 9
paddingMode: 2
packingMode: 0
atlasWidth: 1024
atlasHeight: 1024
characterSetSelectionMode: 1
characterSequence: 32 - 126, 160 - 255, 8192 - 8303, 8364, 8482, 9633
referencedFontAssetGUID: b773c04e36205284fa9d7b06cf720e42
referencedTextAssetGUID:
fontStyle: 0
fontStyleModifier: 0
renderMode: 4165
includeFontFeatures: 1
m_SourceFontFile: {fileID: 0}
m_SourceFontFilePath:
m_AtlasPopulationMode: 0
Expand Down Expand Up @@ -8161,24 +8195,6 @@ MonoBehaviour:
m_MarkToBaseAdjustmentRecords: []
m_MarkToMarkAdjustmentRecords: []
m_FallbackFontAssetTable: []
m_fontAssetCreationEditorSettings:
sourceFontFileGUID: e3265ab4bf004d28a9537516768c1c75
faceIndex: 0
pointSizeSamplingMode: 0
pointSize: 84
padding: 9
paddingMode: 2
packingMode: 0
atlasWidth: 1024
atlasHeight: 1024
characterSetSelectionMode: 1
characterSequence: 32 - 126, 160 - 255, 8192 - 8303, 8364, 8482, 9633
referencedFontAssetGUID: b773c04e36205284fa9d7b06cf720e42
referencedTextAssetGUID:
fontStyle: 0
fontStyleModifier: 0
renderMode: 4165
includeFontFeatures: 1
m_FontWeightTable:
- regularTypeface: {fileID: 0}
italicTypeface: {fileID: 0}
Expand Down
68 changes: 34 additions & 34 deletions Calligraphics/Internal/RichText/RichTextParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -839,36 +839,36 @@ internal static bool ValidateHtmlTag(
// }
// }
// return true;
case 275917: // <align=>
case 186285: // <ALIGN>
switch (firstTagIndentifier.valueHashCode)
{
case 3774683: // <align=left>
textConfiguration.m_lineJustification = HorizontalAlignmentOptions.Left;
textConfiguration.m_lineJustificationStack.Add(textConfiguration.m_lineJustification);
return true;
case 136703040: // <align=right>
textConfiguration.m_lineJustification = HorizontalAlignmentOptions.Right;
textConfiguration.m_lineJustificationStack.Add(textConfiguration.m_lineJustification);
return true;
case -458210101: // <align=center>
textConfiguration.m_lineJustification = HorizontalAlignmentOptions.Center;
textConfiguration.m_lineJustificationStack.Add(textConfiguration.m_lineJustification);
return true;
case -523808257: // <align=justified>
textConfiguration.m_lineJustification = HorizontalAlignmentOptions.Justified;
textConfiguration.m_lineJustificationStack.Add(textConfiguration.m_lineJustification);
return true;
case 122383428: // <align=flush>
textConfiguration.m_lineJustification = HorizontalAlignmentOptions.Flush;
textConfiguration.m_lineJustificationStack.Add(textConfiguration.m_lineJustification);
return true;
}
return false;
case 1065846: // </align>
case 976214: // </ALIGN>
textConfiguration.m_lineJustification = textConfiguration.m_lineJustificationStack.RemoveExceptRoot();
return true;
//case 275917: // <align=>
//case 186285: // <ALIGN>
// switch (firstTagIndentifier.valueHashCode)
// {
// case 3774683: // <align=left>
// textConfiguration.m_lineJustification = HorizontalAlignmentOptions.Left;
// textConfiguration.m_lineJustificationStack.Add(textConfiguration.m_lineJustification);
// return true;
// case 136703040: // <align=right>
// textConfiguration.m_lineJustification = HorizontalAlignmentOptions.Right;
// textConfiguration.m_lineJustificationStack.Add(textConfiguration.m_lineJustification);
// return true;
// case -458210101: // <align=center>
// textConfiguration.m_lineJustification = HorizontalAlignmentOptions.Center;
// textConfiguration.m_lineJustificationStack.Add(textConfiguration.m_lineJustification);
// return true;
// case -523808257: // <align=justified>
// textConfiguration.m_lineJustification = HorizontalAlignmentOptions.Justified;
// textConfiguration.m_lineJustificationStack.Add(textConfiguration.m_lineJustification);
// return true;
// case 122383428: // <align=flush>
// textConfiguration.m_lineJustification = HorizontalAlignmentOptions.Flush;
// textConfiguration.m_lineJustificationStack.Add(textConfiguration.m_lineJustification);
// return true;
// }
// return false;
//case 1065846: // </align>
//case 976214: // </ALIGN>
// textConfiguration.m_lineJustification = textConfiguration.m_lineJustificationStack.RemoveExceptRoot();
// return true;
case 327550: // <width=xx>
case 237918: // <WIDTH>
calliString.GetSubString(ref textConfiguration.m_htmlTag, firstTagIndentifier.valueStartIndex, firstTagIndentifier.valueLength);
Expand Down Expand Up @@ -1526,8 +1526,8 @@ internal static bool ValidateHtmlTag(

// m_actionStack.Remove();
// return true;
case 315682: // <scale=xx.x>
case 226050: // <SCALE=xx.x>
case 315682: // <scale=xx.x>
case 226050: // <SCALE=xx.x>
calliString.GetSubString(ref textConfiguration.m_htmlTag, firstTagIndentifier.valueStartIndex, firstTagIndentifier.valueLength);
// Reject tag if value is invalid.
if (ConvertToFloat(ref textConfiguration.m_htmlTag, out value) != ParseError.None)
Expand All @@ -1536,8 +1536,8 @@ internal static bool ValidateHtmlTag(
textConfiguration.m_FXScale = new Vector3(value, 1, 1);

return true;
case 1105611: // </scale>
case 1015979: // </SCALE>
case 1105611: // </scale>
case 1015979: // </SCALE>
textConfiguration.m_FXScale = 1;
return true;
case 2227963: // <rotate=xx.x>
Expand Down
3 changes: 1 addition & 2 deletions Calligraphics/Shaders/Calligraphics-URP.shadergraph
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,6 @@
"m_OutputNode": {
"m_Id": ""
},
"m_SubDatas": [],
"m_ActiveTargets": [
{
"m_Id": "94300469581b4924ac7dda496811d45d"
Expand Down Expand Up @@ -3762,7 +3761,7 @@
"m_ActiveSubTarget": {
"m_Id": "0eeb5490760e492f8c9691086fa00929"
},
"m_AllowMaterialOverride": false,
"m_AllowMaterialOverride": true,
"m_SurfaceType": 1,
"m_ZTestMode": 4,
"m_ZWriteControl": 0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Latios;
using Latios.Transforms;
using Latios.Transforms.Abstract;
using Unity.Burst;
using Unity.Collections;
Expand All @@ -8,6 +6,8 @@
using Unity.Mathematics;
using Unity.Rendering;

// Todo: This is a dead system due to the query for RenderMesh. Unity hasn't updated the query either.

namespace Latios.Kinemation.Authoring
{
[WorldSystemFilter(WorldSystemFilterFlags.EntitySceneOptimizations)]
Expand Down
1 change: 0 additions & 1 deletion Kinemation/Authoring/KinemationBakingBootstrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public static void InstallKinemation(ref CustomBakingBootstrapContext context)

context.optimizationSystemTypesToInject.Add(TypeManager.GetSystemTypeIndex<LatiosFrozenStaticRendererSystem>());
context.optimizationSystemTypesToDisable.Add(TypeManager.GetSystemTypeIndex<Unity.Rendering.FrozenStaticRendererSystem>());
context.optimizationSystemTypesToInject.Add(TypeManager.GetSystemTypeIndex<LatiosLODRequirementsUpdateSystem>());
context.optimizationSystemTypesToInject.Add(TypeManager.GetSystemTypeIndex<LatiosAddWorldAndChunkRenderBoundsSystem>());
context.optimizationSystemTypesToInject.Add(TypeManager.GetSystemTypeIndex<LatiosRenderBoundsUpdateSystem>());
}
Expand Down
41 changes: 38 additions & 3 deletions Kinemation/Authoring/LatiosMeshRendererBakingUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,45 @@ internal static void Convert(IBaker baker,
if (renderer.isDeforming)
requiredPropertiesForReference |= classification;

if (renderer.lodGroupEntity != Entity.Null && renderer.lodGroupMask != -1)
if (!renderer.lodSettings.Equals(default(LodSettings)))
{
var lodComponent = new MeshLODComponent { Group = renderer.lodGroupEntity, LODMask = renderer.lodGroupMask };
baker.AddComponent(renderer.targetEntity, lodComponent);
bool negHeight = (renderer.lodSettings.lowestResLodLevel & 0x1) == 1;
bool negMin = (renderer.lodSettings.lowestResLodLevel & 0x2) == 2;
bool negMax = (renderer.lodSettings.lowestResLodLevel & 0x4) == 4;
if (negHeight)
renderer.lodSettings.localHeight *= -1;
if (negMin)
renderer.lodSettings.minScreenHeightPercent *= new half(-1f);
if (negMax)
renderer.lodSettings.maxScreenHeightPercent *= new half(-1f);

if (renderer.lodSettings.minScreenHeightPercentAtCrossfadeEdge > 0f || renderer.lodSettings.maxScreenHeightPercentAtCrossfadeEdge > 0f)
{
if (renderer.lodSettings.isSpeedTree)
baker.AddComponent<SpeedTreeCrossfadeTag>(renderer.targetEntity);

if (renderer.lodSettings.maxScreenHeightPercentAtCrossfadeEdge < 0f)
renderer.lodSettings.maxScreenHeightPercentAtCrossfadeEdge = half.MaxValueAsHalf;

baker.AddComponent<LodCrossfade>(renderer.targetEntity);
baker.AddComponent( renderer.targetEntity, new LodHeightPercentagesWithCrossfadeMargins
{
localSpaceHeight = renderer.lodSettings.localHeight,
maxCrossFadeEdge = renderer.lodSettings.maxScreenHeightPercentAtCrossfadeEdge,
maxPercent = renderer.lodSettings.maxScreenHeightPercent,
minCrossFadeEdge = renderer.lodSettings.minScreenHeightPercentAtCrossfadeEdge,
minPercent = renderer.lodSettings.minScreenHeightPercent
});
}
else
{
baker.AddComponent(renderer.targetEntity, new LodHeightPercentages
{
localSpaceHeight = renderer.lodSettings.localHeight,
maxPercent = renderer.lodSettings.maxScreenHeightPercent,
minPercent = renderer.lodSettings.minScreenHeightPercent
});
}
}

if (renderer.useLightmapsIfPossible)
Expand Down
Loading

0 comments on commit cd34426

Please sign in to comment.