diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index 9bcf07a..66a6928 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -210,23 +210,27 @@ namespace RacesOfValheim { float side = i == 0 ? -1f : 1f; - GameObject quad = GameObject.CreatePrimitive(PrimitiveType.Quad); - quad.name = "Eye" + i; + // Spheres, not quads. A quad has no thickness: seen edge-on it is a line and the + // eyes vanish, which is why they came and went with the camera angle. A sphere + // reads the same from every direction and is properly hidden by the skull when + // the head is between it and the camera. + GameObject eye = GameObject.CreatePrimitive(PrimitiveType.Sphere); + eye.name = "Eye" + i; // A primitive comes with a collider, which on a player's face would be its own // kind of bug. - foreach (Collider collider in quad.GetComponents()) + foreach (Collider collider in eye.GetComponents()) { Object.Destroy(collider); } - quad.transform.SetParent(holder.transform, false); - quad.transform.localPosition = new Vector3( + eye.transform.SetParent(holder.transform, false); + eye.transform.localPosition = new Vector3( side * DvergarConfig.EyeSeparation, DvergarConfig.EyeHeight, DvergarConfig.EyeForward); - quad.transform.localRotation = Quaternion.identity; - quad.transform.localScale = Vector3.one * DvergarConfig.EyeSize; + eye.transform.localRotation = Quaternion.identity; + eye.transform.localScale = Vector3.one * DvergarConfig.EyeSize; - Renderer renderer = quad.GetComponent(); + Renderer renderer = eye.GetComponent(); renderer.material = new Material(glow); renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; renderer.receiveShadows = false; @@ -239,13 +243,19 @@ namespace RacesOfValheim /// Finds a shader that will render a flat colour past 1 so the bloom pass picks it up. /// Unity strips shaders nothing references, so this asks for several and reports which one /// the game actually shipped rather than assuming. + /// + /// Opaque first, deliberately. The first version took Sprites/Default, which is a + /// transparent shader with depth writing switched off - so the eyes drew over the head + /// from angles that should have hidden them, and were visible from behind because it also + /// disables backface culling. An unlit opaque shader is occluded by the skull like any + /// other solid thing, which is the whole point of putting them in the face. /// private static Shader ResolveGlowShader() { if (glowShaderResolved) return cachedGlowShader; glowShaderResolved = true; - string[] candidates = { "Sprites/Default", "Unlit/Color", "UI/Default", "Particles/Standard Unlit", "Standard" }; + string[] candidates = { "Unlit/Color", "Standard", "Particles/Standard Unlit", "Sprites/Default", "UI/Default" }; foreach (string name in candidates) { Shader shader = Shader.Find(name);