A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
fix(map): the selection band writes depth too (fix round 2, N6)
eyalgolan0aed934ab2db
diff --git a/unity/Assets/Shaders/HexSelection.shader b/unity/Assets/Shaders/HexSelection.shaderindex b53d214c5..d9f1a2391 100644--- a/unity/Assets/Shaders/HexSelection.shader+++ b/unity/Assets/Shaders/HexSelection.shader@@ -1,6 +1,7 @@// The selected hex's outline band (MapScene.Select). Unlit, one colour, drawn after the hex overlay with a depth offset// towards the camera, so the overlay's lines under the band's edge never z-fight with it, even at the camera's maximum// distance where a 24-bit depth step is tens of metres (fix round 1, M2). Both faces: the band is seen from every yaw.+// A DepthOnly pass puts it in the depth texture as well (fix round 2, N6).Shader "Statecraft/HexSelection"{Properties@@ -36,5 +37,30 @@ Shader "Statecraft/HexSelection"half4 Frag(Varyings input) : SV_Target { return _BaseColor; }ENDHLSL}+ // Writes the band into the depth prepass and the camera depth texture (fix round 2, N6), so depth of field and any+ // other depth reader see the band, not the terrain under it. Same depth offset as the colour pass.+ Pass+ {+ Name "DepthOnly"+ Tags { "LightMode" = "DepthOnly" }+ Cull Off+ ZWrite On+ ColorMask R+ Offset -1, -4+ HLSLPROGRAM+ #pragma vertex Vert+ #pragma fragment Frag+ #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"+ struct Attributes { float4 positionOS : POSITION; };+ struct Varyings { float4 positionCS : SV_POSITION; };+ Varyings Vert(Attributes input)+ {+ Varyings o;+ o.positionCS = TransformObjectToHClip(input.positionOS.xyz);+ return o;+ }+ half Frag(Varyings input) : SV_Target { return input.positionCS.z; }+ ENDHLSL+ }}}diff --git a/unity/Assets/Tests/EditMode/SettlementTests.cs b/unity/Assets/Tests/EditMode/SettlementTests.csindex 1bd9f8776..ccfd33615 100644--- a/unity/Assets/Tests/EditMode/SettlementTests.cs+++ b/unity/Assets/Tests/EditMode/SettlementTests.cs@@ -270,6 +270,9 @@ public class MapSceneTestsAssert.AreEqual("Statecraft/HexSelection", selection.shader.name);StringAssert.IsMatch(@"(?m)^\s*Offset\s+-\d+\s*,\s*-\d+", File.ReadAllText(AssetDatabase.GetAssetPath(selection.shader)));Assert.Greater(selection.renderQueue, Load(OverlayMatPath).renderQueue, "drawn after the overlay lines");+ // Fix round 2 (N6): the band is in the depth prepass / camera depth texture too, so depth of field sees its depth.+ Assert.GreaterOrEqual(selection.FindPass("DepthOnly"), 0, "a DepthOnly pass");+ Assert.AreEqual("DepthOnly", selection.shader.FindPassTagValue(selection.FindPass("DepthOnly"), new UnityEngine.Rendering.ShaderTagId("LightMode")).name);float size = map.Hexes.hex_size_km * 1000f;bool Inland(HexJson h) // whole hex on the terrain, so no corner is clamped to the map's edge{