fix(dvergar): push the eyes out to the surface of the face

Placement is right and the trace proves it - 0.095m from the head bone, exactly the offsets after the race scale, parented to Head and following it. They were simply still inside the skull, and the shader that resolved is depth-tested, so the head hid them completely.

The bone sits at the base of the skull and a face is further forward than it looks. Offsets raised to land about 0.109m out on a Dvergar. The trace now also reports how far up the eye ended up and whether it is on the face side of the head at all, so the next look distinguishes too shallow from the wrong direction entirely.
This commit is contained in:
kanym 2026-08-05 20:51:11 +02:00
commit e512dcfb93
2 changed files with 15 additions and 4 deletions

View file

@ -95,9 +95,13 @@ namespace RacesOfValheim
// reference and is not: it is where the camera goes, half a metre above the head bone, // reference and is not: it is where the camera goes, half a metre above the head bone,
// and starting from it put the eyes in the treetops. That was measured, not guessed - // and starting from it put the eyes in the treetops. That was measured, not guessed -
// the trace is in the commit history. // the trace is in the commit history.
// These are pre-scale numbers: a Dvergar renders at 0.78, so 0.140 forward lands about
// 0.109m out. The bone is at the base of the skull, and a face is further forward than it
// looks - at 0.095 the eyes were correctly placed and entirely inside the head, which the
// depth-tested shader then hid completely.
public static readonly float EyeSeparation = 0.032f; // half the distance between them public static readonly float EyeSeparation = 0.032f; // half the distance between them
public static readonly float EyeForward = 0.095f; public static readonly float EyeForward = 0.140f;
public static readonly float EyeHeight = 0.070f; public static readonly float EyeHeight = 0.100f;
public static readonly float EyeSize = 0.020f; public static readonly float EyeSize = 0.020f;
// Base glow, before any star. The tiers replace it with the emissive colours the game // Base glow, before any star. The tiers replace it with the emissive colours the game

View file

@ -281,11 +281,18 @@ namespace RacesOfValheim
if (eye != null) if (eye != null)
{ {
// Which side of the head it came out on. Positive means the face; negative would
// mean the offsets are pushing into the back of the skull, which no amount of
// increasing them would ever fix.
Vector3 offset = eye.position - headBone.position;
Vector3 flat = new Vector3(offset.x, 0f, offset.z);
float towardFace = Vector3.Dot(flat.normalized, player.transform.forward);
Jotunn.Logger.LogInfo( Jotunn.Logger.LogInfo(
$"[Dvergar] eye parent='{(eye.parent != null ? eye.parent.name : "none")}' " + $"[Dvergar] eye parent='{(eye.parent != null ? eye.parent.name : "none")}' " +
$"localPos={eye.localPosition} localScale={eye.localScale} world={eye.position} " + $"localPos={eye.localPosition} localScale={eye.localScale} world={eye.position} " +
$"distFromHead={Vector3.Distance(eye.position, headBone.position):F3}m " + $"distFromHead={offset.magnitude:F3}m up={offset.y:F3}m " +
$"worldSize={eye.lossyScale.x:F3}m"); $"towardFace={towardFace:F2} worldSize={eye.lossyScale.x:F3}m");
} }
} }