From eabc1c54bf776b73ebd877094eeb2e8c472c9b8d Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 19:27:34 +0200 Subject: [PATCH 01/30] feat(skeleton): show the race on the main-menu character preview The body swap read the race off the ZDO and gave up when there was none, which is exactly the situation on the menu preview - FejdStartup instantiates a Player and calls PlayerProfile.LoadPlayerData on it, so the preview knows its own custom data and therefore its race, but it has no business owning a network view. It now falls back to m_customData the way every other race in the mod already does, so a Skeleton character looks like one before you press Start. The tier falls back the same way. In the menu there is no world loaded to have killed anything, so the preview is the base skeleton whatever the character has done elsewhere. feat(dvergar): age into a starred dverger's colours One star at Bonemass, two at Fader. Nothing is picked by eye. A starred creature in Valheim is not a second model: it is the same one recoloured by LevelEffects, whose LevelSetup list holds a hue/saturation/value offset per star. Those offsets are read off the Dverger prefab at runtime and applied to the race's own slate blue-grey, so the tiers land on the tints the game itself uses and keep following them if the prefab changes. The tier comes from the ZDO key DvergarRace already publishes, so a remote Dvergar is coloured at their own standing rather than the observer's - which matters as soon as anyone runs personal progression. Crossing a tier pushes a colour refresh through immediately, since the tint is only written from the UpdateColors postfix and Valheim runs that on its own schedule. Same treatment the health malus already gets a few lines above. The hood is deliberately untouched. --- JotunnModStub/Dvergar/DvergarConfig.cs | 11 +++ JotunnModStub/Dvergar/DvergarPatches.cs | 5 +- JotunnModStub/Dvergar/DvergarRace.cs | 13 +++ JotunnModStub/Dvergar/DvergarVisuals.cs | 103 ++++++++++++++++++++++ JotunnModStub/Skeleton/SkeletonPatches.cs | 15 ++-- JotunnModStub/Skeleton/SkeletonVisuals.cs | 49 ++++++++++ 6 files changed, 189 insertions(+), 7 deletions(-) diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index c4e1080..e891051 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -51,6 +51,17 @@ namespace RacesOfValheim // Dvergr are white-haired. The hood hides most of it, but the beard shows. public static readonly Color HairColor = new Color(0.85f, 0.87f, 0.92f, 1f); + // ─── Star colours ──────────────────────────────────────────────────── + // A starred dverger is not a different model: Valheim recolours the same one with a + // LevelEffects component, whose LevelSetup list carries a hue/saturation/value offset per + // star and an optional emissive colour for the eyes. Setup 0 is one star, setup 1 is two. + // + // Nothing here hardcodes a colour. The offsets are read off the creature prefab at + // runtime, so the race ages into exactly the tints the game itself uses - and follows + // them if a patch ever changes them. + public const int OneStarState = 4; // Bonemass + public const int TwoStarState = 8; // Fader + // ─── Cosmetic hood ─────────────────────────────────────────────────── // The helmet slot itself stays free — whatever the player equips keeps all of its stats, // only the mesh is swapped. diff --git a/JotunnModStub/Dvergar/DvergarPatches.cs b/JotunnModStub/Dvergar/DvergarPatches.cs index 6953737..94ae69e 100644 --- a/JotunnModStub/Dvergar/DvergarPatches.cs +++ b/JotunnModStub/Dvergar/DvergarPatches.cs @@ -343,7 +343,10 @@ namespace RacesOfValheim if (__instance.m_bodyModel != null && __instance.m_bodyModel.material != null) { - __instance.m_bodyModel.material.SetColor("_SkinColor", DvergarConfig.SkinColor); + // Not the flat config colour any more: it carries the star shift a dverger of + // this standing would wear, so the race visibly ages at Bonemass and again at + // Fader. + __instance.m_bodyModel.material.SetColor("_SkinColor", DvergarVisuals.GetSkinColor(player)); } TintRenderers(Traverse.Create(__instance).Field("m_hairItemInstance").GetValue()); diff --git a/JotunnModStub/Dvergar/DvergarRace.cs b/JotunnModStub/Dvergar/DvergarRace.cs index def4d70..9b55b9b 100644 --- a/JotunnModStub/Dvergar/DvergarRace.cs +++ b/JotunnModStub/Dvergar/DvergarRace.cs @@ -18,6 +18,7 @@ namespace RacesOfValheim // NaN so that the very first frame always counts as a change and pushes the malus through. private float lastAppliedMalus = float.NaN; + private int lastAppliedStarTier = -1; private void Awake() { @@ -101,6 +102,18 @@ namespace RacesOfValheim nview.GetZDO().Set(DvergarConfig.StateZdoKey, state); } + // The skin tint is only written from the UpdateColors postfix, which Valheim runs on + // its own schedule - so crossing into a new star tier would otherwise not show until + // something else happened to refresh the visuals. Push one through, the same way the + // health malus above pushes a food update. + int starTier = DvergarVisuals.GetStarTier(state); + if (starTier != lastAppliedStarTier) + { + lastAppliedStarTier = starTier; + VisEquipment visEq = player.GetComponent(); + if (visEq != null) Traverse.Create(visEq).Method("UpdateColors").GetValue(); + } + DvergarAbilities.Tick(player, state); } } diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index a1dc77f..6015658 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -47,6 +47,109 @@ namespace RacesOfValheim public static bool IsDvergarPlayer(Player player) => GetPlayerRace(player) == DvergarConfig.RaceId; + // ─── Star colours ──────────────────────────────────────────────────── + + // Read once per session, failure included. + private static LevelEffects.LevelSetup[] cachedStarSetups; + private static bool starSetupsResolved; + + /// + /// How many stars the Dvergar's colouring has earned: one at Bonemass, two at Fader. + /// + public static int GetStarTier(int state) + { + if (state >= DvergarConfig.TwoStarState) return 2; + if (state >= DvergarConfig.OneStarState) return 1; + return 0; + } + + /// + /// The skin tint for a player at their current standing: the race's own slate blue-grey, + /// shifted by the hue/saturation/value offsets a real dverger of that star count wears. + /// + /// Valheim does not give a starred creature a different model or a different colour - it + /// gives the same material an HSV offset through LevelEffects. Reading those offsets off + /// the creature prefab rather than picking two colours by eye means the tiers land on the + /// exact tints the game uses, and keeps following them if the prefab ever changes. + /// + public static Color GetSkinColor(Player player) + { + LevelEffects.LevelSetup setup = GetStarSetup(GetStarTier(GetProgressionState(player))); + if (setup == null) return DvergarConfig.SkinColor; + + return ShiftHsv(DvergarConfig.SkinColor, setup.m_hue, setup.m_saturation, setup.m_value); + } + + /// + /// The tier this particular Dvergar should be coloured for. DvergarRace publishes it to + /// the ZDO every frame, so a remote player is shown at their own standing rather than the + /// observer's - which matters the moment anyone runs personal progression. Falls back to + /// this client's own reckoning when there is no ZDO, which is the main-menu preview. + /// + private static int GetProgressionState(Player player) + { + ZNetView nview = player != null ? player.GetComponent() : null; + if (nview != null && nview.IsValid()) + { + int published = nview.GetZDO().GetInt(DvergarConfig.StateZdoKey, 0); + if (published > 0) return published; + } + + return BossProgressionManager.GetCurrentProgressionState(); + } + + private static LevelEffects.LevelSetup GetStarSetup(int tier) + { + if (tier <= 0) return null; + + LevelEffects.LevelSetup[] setups = ResolveStarSetups(); + if (setups == null || setups.Length == 0) return null; + + // m_levelSetups[0] is one star, [1] is two - the game indexes it as level - 2. + int index = Mathf.Min(tier - 1, setups.Length - 1); + return setups[index]; + } + + private static LevelEffects.LevelSetup[] ResolveStarSetups() + { + if (starSetupsResolved) return cachedStarSetups; + starSetupsResolved = true; + + GameObject prefab = PrefabManager.Cache.GetPrefab(DvergarConfig.DvergerPrefabName); + LevelEffects effects = prefab != null ? prefab.GetComponentInChildren(true) : null; + + if (effects == null || effects.m_levelSetups == null || effects.m_levelSetups.Count == 0) + { + Jotunn.Logger.LogWarning( + $"[Dvergar] No LevelEffects setups on '{DvergarConfig.DvergerPrefabName}'; " + + "star colouring stays at the base tint."); + return null; + } + + cachedStarSetups = effects.m_levelSetups.ToArray(); + Jotunn.Logger.LogInfo( + $"[Dvergar] Star colours resolved: {cachedStarSetups.Length} setups from " + + $"'{DvergarConfig.DvergerPrefabName}'."); + return cachedStarSetups; + } + + /// + /// Applies an HSV offset the way the creature shader does - hue wraps, the other two + /// clamp - so the result is the same shift a starred dverger gets, on our colour. + /// + private static Color ShiftHsv(Color color, float hue, float saturation, float value) + { + Color.RGBToHSV(color, out float h, out float s, out float v); + + h = Mathf.Repeat(h + hue, 1f); + s = Mathf.Clamp01(s + saturation); + v = Mathf.Clamp01(v + value); + + Color shifted = Color.HSVToRGB(h, s, v); + shifted.a = color.a; + return shifted; + } + // ─── Scale ─────────────────────────────────────────────────────────── /// diff --git a/JotunnModStub/Skeleton/SkeletonPatches.cs b/JotunnModStub/Skeleton/SkeletonPatches.cs index 61a92a5..40d9043 100644 --- a/JotunnModStub/Skeleton/SkeletonPatches.cs +++ b/JotunnModStub/Skeleton/SkeletonPatches.cs @@ -244,19 +244,22 @@ namespace RacesOfValheim if (!__instance.m_isPlayer) return; Player p = __instance.GetComponent(); if (p == null) return; - ZNetView nview = p.GetComponent(); - if (nview == null || !nview.IsValid()) return; - - string race = nview.GetZDO().GetString("RacesOfValheim_Race", "Human"); - if (race == "Skeleton") + // Race and tier both come through SkeletonVisuals, which falls back to + // m_customData when there is no ZNetView. That is the whole of what was keeping + // the race off the main-menu character preview: the preview player carries its + // saved custom data but has no network view, so an unconditional ZDO read gave up + // before it could find out it was looking at a Skeleton. + string race = SkeletonVisuals.GetPlayerRace(p); + + if (race == SkeletonVisuals.RaceId) { if (__instance.m_bodyModel != null) { // Ensure the base model is hidden __instance.m_bodyModel.enabled = false; - int state = nview.GetZDO().GetInt("RacesOfValheim_SkeletonState", 0); + int state = SkeletonVisuals.GetProgressionState(p); SkeletonProgression.SkeletonRules rules = SkeletonProgression.GetRules(state); string targetBodyName = $"SkeletonBody_{rules.ModelPrefab}"; diff --git a/JotunnModStub/Skeleton/SkeletonVisuals.cs b/JotunnModStub/Skeleton/SkeletonVisuals.cs index 75f9e7e..cc46787 100644 --- a/JotunnModStub/Skeleton/SkeletonVisuals.cs +++ b/JotunnModStub/Skeleton/SkeletonVisuals.cs @@ -16,6 +16,55 @@ namespace RacesOfValheim /// public static class SkeletonVisuals { + public const string RaceId = "Skeleton"; + + /// + /// Reads the race off the ZDO, falling back to m_customData. + /// + /// The fallback is what makes the race show up on the main-menu character preview. + /// FejdStartup.SetupCharacterPreview instantiates a Player and calls + /// PlayerProfile.LoadPlayerData on it, which restores m_customData - so the preview does + /// know it is a Skeleton. What it has no business having is a ZNetView, and reading the + /// race from the ZDO alone meant the body swap gave up before it ever looked. + /// + public static string GetPlayerRace(Player player) + { + if (player == null) return "Human"; + + ZNetView nview = player.GetComponent(); + if (nview != null && nview.IsValid()) + { + string race = nview.GetZDO().GetString("RacesOfValheim_Race", ""); + if (!string.IsNullOrEmpty(race)) return race; + } + + if (player.m_customData != null && player.m_customData.TryGetValue("Race", out string custom)) + { + return custom; + } + + return "Human"; + } + + public static bool IsSkeletonPlayer(Player player) => GetPlayerRace(player) == RaceId; + + /// + /// The tier a given player's body should be built for. The ZDO carries it so remote + /// players render at their own standing; without one - the menu preview - fall back to + /// whatever this client can work out, which in the menu is the base tier, since there is + /// no world loaded to have killed anything. + /// + public static int GetProgressionState(Player player) + { + ZNetView nview = player != null ? player.GetComponent() : null; + if (nview != null && nview.IsValid()) + { + return nview.GetZDO().GetInt("RacesOfValheim_SkeletonState", 0); + } + + return BossProgressionManager.GetCurrentProgressionState(); + } + // Fire sources in preference order. The torch is an item every world has; the ground // torch and the fire pit are the building pieces to fall back on. private static readonly string[] FlameSourcePrefabs = -- 2.52.0 From 9f6308ec949491393e484214c1b3eef8f8284081 Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 19:34:41 +0200 Subject: [PATCH 02/30] fix(skeleton): hide the helmet on the menu preview too SkeletonRace hides it every frame, but that script only ever runs for the local player in a loaded world - so the moment the body swap started working in the menu, the helmet came back with it. Hiding it from the visuals postfix instead covers the preview, remote players and the first frame after a race change, none of which reach SkeletonRace. Scaled to zero rather than deactivated, since Valheim re-enables the instance on every refresh, and restored only from zero so another race scaling the same helmet is left alone. Armour is untouched, as asked. fix(dvergar): stop the two-star tier turning back into a pink human The star offsets are authored against a dverger's own texture, where a brightened, desaturated result is a pale dverger. Ours multiplies the human skin texture, where the same result is white - and a white multiplier is no tint at all, which is exactly what two stars produced: an ordinary human. One star survived only because its offset was smaller. Saturation now has a floor and value a ceiling, so a tier can shift the colour but never wash it out. The resolved offsets and the colour each one lands on are logged once per session, so if a tier still reads wrong it can be tuned against the real numbers rather than by eye. --- JotunnModStub/Dvergar/DvergarConfig.cs | 9 +++++++ JotunnModStub/Dvergar/DvergarVisuals.cs | 30 ++++++++++++++++----- JotunnModStub/Skeleton/SkeletonPatches.cs | 32 +++++++++++++++++++++++ 3 files changed, 64 insertions(+), 7 deletions(-) diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index e891051..bed7c3d 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -62,6 +62,15 @@ namespace RacesOfValheim public const int OneStarState = 4; // Bonemass public const int TwoStarState = 8; // Fader + // Those offsets are authored against a dverger's own texture. Ours is a multiplier over + // the human skin, where white means "no tint at all" - so an offset that brightens and + // desaturates far enough lands on white and hands back an ordinary pink human. That is + // exactly what the two-star tier did. These bounds keep every tier recognisably the same + // colour, shifted rather than washed out. + public const float StarMinSaturation = 0.25f; + public const float StarMinValue = 0.20f; + public const float StarMaxValue = 0.85f; + // ─── Cosmetic hood ─────────────────────────────────────────────────── // The helmet slot itself stays free — whatever the player equips keeps all of its stats, // only the mesh is swapped. diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index 6015658..4247a81 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -127,23 +127,39 @@ namespace RacesOfValheim } cachedStarSetups = effects.m_levelSetups.ToArray(); - Jotunn.Logger.LogInfo( - $"[Dvergar] Star colours resolved: {cachedStarSetups.Length} setups from " + - $"'{DvergarConfig.DvergerPrefabName}'."); + + // The offsets themselves, so a tier that lands on the wrong colour can be tuned + // against the real numbers rather than by eye. + for (int i = 0; i < cachedStarSetups.Length; i++) + { + LevelEffects.LevelSetup setup = cachedStarSetups[i]; + Jotunn.Logger.LogInfo( + $"[Dvergar] Star {i + 1}: hue={setup.m_hue:F3} saturation={setup.m_saturation:F3} " + + $"value={setup.m_value:F3} emissive={(setup.m_setEmissiveColor ? setup.m_emissiveColor.ToString() : "none")} " + + $"-> skin {ShiftHsv(DvergarConfig.SkinColor, setup.m_hue, setup.m_saturation, setup.m_value)}"); + } + return cachedStarSetups; } /// - /// Applies an HSV offset the way the creature shader does - hue wraps, the other two - /// clamp - so the result is the same shift a starred dverger gets, on our colour. + /// Applies a star's HSV offset to our tint. Hue wraps the way the creature shader's does; + /// saturation and value are bounded rather than merely clamped to 0..1. + /// + /// The bounds are the whole trick. The shader applies these offsets to a dverger's own + /// texture, where a bright desaturated result is a pale dverger. Ours multiplies the human + /// skin texture, where the same result is *white* - and a white multiplier is no tint at + /// all, which is why the two-star Dvergar came out looking like an ordinary pink human. + /// Keeping saturation off the floor and value off the ceiling means every tier stays a + /// colour. /// private static Color ShiftHsv(Color color, float hue, float saturation, float value) { Color.RGBToHSV(color, out float h, out float s, out float v); h = Mathf.Repeat(h + hue, 1f); - s = Mathf.Clamp01(s + saturation); - v = Mathf.Clamp01(v + value); + s = Mathf.Clamp(s + saturation, DvergarConfig.StarMinSaturation, 1f); + v = Mathf.Clamp(v + value, DvergarConfig.StarMinValue, DvergarConfig.StarMaxValue); Color shifted = Color.HSVToRGB(h, s, v); shifted.a = color.a; diff --git a/JotunnModStub/Skeleton/SkeletonPatches.cs b/JotunnModStub/Skeleton/SkeletonPatches.cs index 40d9043..1fee96c 100644 --- a/JotunnModStub/Skeleton/SkeletonPatches.cs +++ b/JotunnModStub/Skeleton/SkeletonPatches.cs @@ -335,6 +335,7 @@ namespace RacesOfValheim HideItemInstances(__instance, "m_hairItemInstances"); HideItemInstances(__instance, "m_beardItemInstances"); + SetHelmetVisible(__instance, false); } } else @@ -358,10 +359,41 @@ namespace RacesOfValheim ShowItemInstances(__instance, "m_hairItemInstances"); ShowItemInstances(__instance, "m_beardItemInstances"); + SetHelmetVisible(__instance, true); } } } + /// + /// A helmet on a skull looks like a helmet floating in a skull, so the race hides it. + /// + /// SkeletonRace does this every frame in a world, but it only ever runs for the local + /// player - which is why the helmet came back on the main-menu preview once the body + /// swap started working there. Doing it here covers the menu, remote players and the + /// first frame after a race change, all of which reach this postfix and none of which + /// reach SkeletonRace. + /// + /// Scaled rather than deactivated, because Valheim re-enables the instance whenever it + /// refreshes visuals - the approach the Dvergar's hood already proved out. + /// + private static void SetHelmetVisible(VisEquipment visEq, bool visible) + { + GameObject helmet = Traverse.Create(visEq).Field("m_helmetItemInstance").Value; + if (helmet == null) return; + + Vector3 wanted = visible ? Vector3.one : Vector3.zero; + + // Only ever undo our own hiding: another race may legitimately be scaling this. + if (!visible && helmet.transform.localScale != Vector3.zero) + { + helmet.transform.localScale = wanted; + } + else if (visible && helmet.transform.localScale == Vector3.zero) + { + helmet.transform.localScale = wanted; + } + } + private static void HideItemInstances(VisEquipment visEq, string fieldName) { try -- 2.52.0 From 760ddffc27f835df3e75a459a56c2979f92f2c3c Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 19:42:38 +0200 Subject: [PATCH 03/30] feat(dvergar): give two stars a stone tone instead of deriving one Deriving it from the creature's own two-star offset put the tier a shade away from ordinary human skin, and no amount of clamping fixes that, because the derivation is asking for something a multiplier cannot do. Those offsets brighten and desaturate a dverger's own texture. Ours multiplies the human skin map, where less saturation means less tint, and less tint means more flesh - the opposite direction from the one intended. A multiplier can darken and it can bias. It cannot desaturate: the pink lives in the texture and survives being multiplied by grey, only dimmer. So two stars now states a colour outright - dark, and cold enough to sit on top of the flesh tone rather than under it. One star keeps deriving from the prefab, since that tier reads correctly. --- JotunnModStub/Dvergar/DvergarConfig.cs | 10 ++++++++++ JotunnModStub/Dvergar/DvergarVisuals.cs | 11 ++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index bed7c3d..7fbeb82 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -71,6 +71,16 @@ namespace RacesOfValheim public const float StarMinValue = 0.20f; public const float StarMaxValue = 0.85f; + // Two stars is hand-picked rather than derived, because the derivation cannot express + // what it is asking for. A multiplier can darken a texture and it can bias a texture, but + // it cannot desaturate one: the pink is in the human skin map, and multiplying by grey + // keeps every bit of it, only dimmer. So the two-star tier says "stone" the only way this + // channel can - dark, and cold enough to sit on top of the pink rather than under it. + // + // To tune: raise all three together for a lighter dvergr, and widen the gap between R and + // B for a colder one. Keeping R below B is what holds the flesh tone down. + public static readonly Color TwoStarSkinColor = new Color(0.34f, 0.37f, 0.44f, 1f); + // ─── Cosmetic hood ─────────────────────────────────────────────────── // The helmet slot itself stays free — whatever the player equips keeps all of its stats, // only the mesh is swapped. diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index 4247a81..5647fef 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -74,7 +74,16 @@ namespace RacesOfValheim /// public static Color GetSkinColor(Player player) { - LevelEffects.LevelSetup setup = GetStarSetup(GetStarTier(GetProgressionState(player))); + int tier = GetStarTier(GetProgressionState(player)); + + // Two stars stops deriving and states a colour outright. The creature's own two-star + // offset brightens and desaturates, which through a multiplier over the human skin + // texture means "tint it less" - and landed the tier a shade away from ordinary + // flesh, which is the opposite of what two stars should read as. Stone grey says it + // in the one language a multiplier speaks. + if (tier >= 2) return DvergarConfig.TwoStarSkinColor; + + LevelEffects.LevelSetup setup = GetStarSetup(tier); if (setup == null) return DvergarConfig.SkinColor; return ShiftHsv(DvergarConfig.SkinColor, setup.m_hue, setup.m_saturation, setup.m_value); -- 2.52.0 From 0b6a61a852430676b6faff86a6efb205c24050a4 Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 20:00:15 +0200 Subject: [PATCH 04/30] chore(dvergar): survey the body shader, and record why pale is out of reach Custom/Player carries 13 properties and exactly one colour among them, _SkinColor. No _Hue, no _Saturation, no _Value, no _Brightness, no _Grayscale. That closes the question the last three commits kept circling. A real dverger turns pale at two stars through saturation -1 on the creature shader, which genuinely desaturates its texture. The player body has no equivalent control: _SkinColor multiplies the human skin map, and a multiply can darken or bias but never desaturate, because the pink lives in the texture and survives being multiplied by grey. White is the multiplier's identity, so "paler" and "more human" are the same direction - which is exactly what every attempt walked into. Reaching it would mean swapping _MainTex for a desaturated copy of the skin texture, a per-player blit through a custom shader. Disproportionate for a cosmetic tier. The survey stays as a check rather than being deleted, in case a game update ever changes the player shader, and the finding is written where the next person will look for it. The star offsets read off the prefab, for the record: Star 1: hue +0.100, saturation +0.200, value 0, emissive RGBA(0, 4, 3.294) Star 2: hue 0, saturation -1.000, value 0, emissive RGBA(11.984, 0, 8.784) Both emissive colours are HDR and are what a starred dverger's eyes glow with. --- JotunnModStub/Dvergar/DvergarPatches.cs | 4 ++ JotunnModStub/Dvergar/DvergarVisuals.cs | 50 +++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/JotunnModStub/Dvergar/DvergarPatches.cs b/JotunnModStub/Dvergar/DvergarPatches.cs index 94ae69e..0375054 100644 --- a/JotunnModStub/Dvergar/DvergarPatches.cs +++ b/JotunnModStub/Dvergar/DvergarPatches.cs @@ -343,6 +343,10 @@ namespace RacesOfValheim if (__instance.m_bodyModel != null && __instance.m_bodyModel.material != null) { + // Once per session: settles whether this material can be desaturated properly + // or whether the multiplier tint is the ceiling. + DvergarVisuals.LogSkinShaderOnce(__instance.m_bodyModel.material); + // Not the flat config colour any more: it carries the star shift a dverger of // this standing would wear, so the race visibly ages at Bonemass and again at // Fader. diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index 5647fef..f27c198 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -107,6 +107,56 @@ namespace RacesOfValheim return BossProgressionManager.GetCurrentProgressionState(); } + // ─── Shader survey ─────────────────────────────────────────────────── + + private static bool loggedSkinShader; + + /// + /// Reports what the player's body material can actually be asked to do, once per session. + /// + /// This was written to settle whether a pale Dvergar was reachable, and it settled it: + /// + /// Custom/Player, 13 properties, of which exactly one is a colour - _SkinColor. + /// No _Hue, no _Saturation, no _Value, no _Brightness, no _Grayscale. + /// + /// So the answer is no, and it is a property of the shader rather than of the numbers we + /// pick. A real dverger goes pale at two stars by way of saturation -1 on the creature + /// shader, which genuinely desaturates its texture. The player body has no such control: + /// _SkinColor multiplies the human skin map, and a multiply can darken or bias but never + /// desaturate - the pink is in the texture and survives being multiplied by grey. White + /// is the multiplier's identity, so "paler" and "more human" are the same direction. + /// + /// Getting there would mean replacing _MainTex with a desaturated copy of the skin + /// texture, which is a blit through a custom shader per player - far more machinery than a + /// cosmetic tier is worth. Kept as a check rather than deleted, in case a game update ever + /// changes the player shader. + /// + public static void LogSkinShaderOnce(Material material) + { + if (loggedSkinShader || material == null) return; + loggedSkinShader = true; + + Shader shader = material.shader; + Jotunn.Logger.LogInfo($"[Dvergar] Body shader: '{(shader != null ? shader.name : "null")}'"); + + if (shader != null) + { + int count = shader.GetPropertyCount(); + System.Text.StringBuilder sb = new System.Text.StringBuilder(); + for (int i = 0; i < count; i++) + { + sb.Append(shader.GetPropertyName(i)).Append(" (").Append(shader.GetPropertyType(i)).Append(") "); + } + Jotunn.Logger.LogInfo($"[Dvergar] Body shader has {count} properties: {sb}"); + } + + string[] wanted = { "_Hue", "_Saturation", "_Value", "_Brightness", "_Contrast", "_Grayscale", "_SkinColor" }; + foreach (string name in wanted) + { + Jotunn.Logger.LogInfo($"[Dvergar] HasProperty('{name}') = {material.HasProperty(name)}"); + } + } + private static LevelEffects.LevelSetup GetStarSetup(int tier) { if (tier <= 0) return null; -- 2.52.0 From 9dc072f0a5e6ecdf0441904e6059f45c222d5e4c Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 20:05:52 +0200 Subject: [PATCH 05/30] feat(dvergar): give the eyes a glow, and take the colour from the stars A player's eyes are painted into the skin texture, and Custom/Player has no emission channel to light them with - the shader survey in the last commit is what established that. So a Dvergar wears two small emissive quads over them instead. There was no working example to copy: the Aswid's red eyes were never built, only cleaned up, which is why they never glowed. Colour comes from the same LevelSetup list the skin tint does. One star is RGBA(0, 4, 3.3), two stars RGBA(12, 0, 8.8) - both far past 1, which is what makes them bloom rather than merely look bright. Only the base tier's colour is ours to choose. The quads hang off Character.m_eye, which already sits at eye height and already faces the look direction, so the offsets are plain metres in an obvious frame: no working out which way a rig bone points, and no fighting the 100x scale the player armature is authored at. Everything about the placement is a named constant, since none of it can be judged without seeing it. Applied from the UpdateColors postfix rather than UpdateVisuals so that the refresh DvergarRace already forces when a boss falls recolours the eyes in the same frame it recolours the skin. It runs before the race check so it also takes them off again. The glow shader is resolved from a list and the winner is logged, because Unity strips shaders nothing references and assuming one would be a silent failure. --- JotunnModStub/Dvergar/DvergarConfig.cs | 21 ++++ JotunnModStub/Dvergar/DvergarPatches.cs | 10 +- JotunnModStub/Dvergar/DvergarVisuals.cs | 130 ++++++++++++++++++++++++ 3 files changed, 160 insertions(+), 1 deletion(-) diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index 7fbeb82..15ac579 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -81,6 +81,27 @@ namespace RacesOfValheim // B for a colder one. Keeping R below B is what holds the flesh tone down. public static readonly Color TwoStarSkinColor = new Color(0.34f, 0.37f, 0.44f, 1f); + // ─── Glowing eyes ──────────────────────────────────────────────────── + // A player's eyes are painted into the skin texture, and Custom/Player has no emission + // channel to light them with - so a Dvergar wears two small emissive quads over them + // instead. Nothing else in the mod does this, so there was no working example to copy; + // the Aswid's red eyes were never built at all, only cleaned up. + // + // Offsets are in metres from Character.m_eye, which already sits at eye height and faces + // wherever the player is looking, so no bone axes have to be guessed at. EyeForward is + // the one to tune first: too little and the quads sink into the face, too much and they + // float in front of it. + public static readonly float EyeSeparation = 0.035f; // half the distance between them + public static readonly float EyeForward = 0.075f; + public static readonly float EyeHeight = -0.010f; + public static readonly float EyeSize = 0.022f; + + // Base glow, before any star. The tiers replace it with the emissive colours the game + // itself gives a starred dverger - RGBA(0, 4, 3.3) at one star and RGBA(12, 0, 8.8) at + // two, both far past 1, which is exactly what makes them bloom rather than just look + // bright. + public static readonly Color BaseEyeColor = new Color(0f, 2.2f, 1.8f, 1f); + // ─── Cosmetic hood ─────────────────────────────────────────────────── // The helmet slot itself stays free — whatever the player equips keeps all of its stats, // only the mesh is swapped. diff --git a/JotunnModStub/Dvergar/DvergarPatches.cs b/JotunnModStub/Dvergar/DvergarPatches.cs index 0375054..a744e15 100644 --- a/JotunnModStub/Dvergar/DvergarPatches.cs +++ b/JotunnModStub/Dvergar/DvergarPatches.cs @@ -339,7 +339,15 @@ namespace RacesOfValheim if (__instance == null || !__instance.m_isPlayer) return; Player player = __instance.GetComponent(); - if (player == null || !DvergarVisuals.IsDvergarPlayer(player)) return; + if (player == null) return; + + // Before the race check, because it takes the eyes off anyone who has stopped + // being a Dvergar as well as putting them on anyone who is one. Here rather than + // in the UpdateVisuals postfix so that the tier refresh DvergarRace forces on a + // boss kill recolours them at the same moment it recolours the skin. + DvergarVisuals.ApplyEyes(player); + + if (!DvergarVisuals.IsDvergarPlayer(player)) return; if (__instance.m_bodyModel != null && __instance.m_bodyModel.material != null) { diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index f27c198..a253124 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -107,6 +107,136 @@ namespace RacesOfValheim return BossProgressionManager.GetCurrentProgressionState(); } + // ─── Glowing eyes ──────────────────────────────────────────────────── + + private const string EyesName = "DvergarEyes"; + + private static Shader cachedGlowShader; + private static bool glowShaderResolved; + + /// + /// Keeps two small emissive quads sitting over the player's painted-on eyes, coloured by + /// star tier. Safe to call for anyone: it removes them again from whoever is not a living + /// Dvergar. + /// + /// They hang off Character.m_eye rather than the head bone. m_eye is already at eye + /// height and already faces the look direction, so the offsets below are plain metres in + /// an obvious frame - no working out which way a rig bone happens to point, and no + /// fighting the 100x scale the player armature is authored at. + /// + public static void ApplyEyes(Player player) + { + if (player == null) return; + + Transform anchor = player.m_eye; + if (anchor == null) return; + + Transform eyes = anchor.Find(EyesName); + + if (!IsDvergarPlayer(player) || player.IsDead()) + { + if (eyes != null) + { + // Renamed first: Destroy is deferred to the end of the frame, and every call + // until then would otherwise find it again. + eyes.name = EyesName + "_Removed"; + Object.Destroy(eyes.gameObject); + } + return; + } + + if (eyes == null) eyes = BuildEyes(anchor); + if (eyes == null) return; // already logged once by the resolver + + Color glow = GetEyeColor(player); + foreach (Renderer renderer in eyes.GetComponentsInChildren(true)) + { + Material material = renderer.material; + if (material == null) continue; + + material.color = glow; + if (material.HasProperty("_EmissionColor")) material.SetColor("_EmissionColor", glow); + } + } + + /// + /// One star and two stars use the emissive colours the game gives a starred dverger, read + /// off the same LevelSetup list the skin tint comes from. Only the base tier is ours. + /// + private static Color GetEyeColor(Player player) + { + LevelEffects.LevelSetup setup = GetStarSetup(GetStarTier(GetProgressionState(player))); + if (setup != null && setup.m_setEmissiveColor) return setup.m_emissiveColor; + + return DvergarConfig.BaseEyeColor; + } + + private static Transform BuildEyes(Transform anchor) + { + Shader glow = ResolveGlowShader(); + if (glow == null) return null; + + GameObject holder = new GameObject(EyesName); + holder.transform.SetParent(anchor, false); + holder.transform.localPosition = Vector3.zero; + holder.transform.localRotation = Quaternion.identity; + holder.transform.localScale = Vector3.one; + + for (int i = 0; i < 2; i++) + { + float side = i == 0 ? -1f : 1f; + + GameObject quad = GameObject.CreatePrimitive(PrimitiveType.Quad); + quad.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()) + { + Object.Destroy(collider); + } + + quad.transform.SetParent(holder.transform, false); + quad.transform.localPosition = new Vector3( + side * DvergarConfig.EyeSeparation, DvergarConfig.EyeHeight, DvergarConfig.EyeForward); + quad.transform.localRotation = Quaternion.identity; + quad.transform.localScale = Vector3.one * DvergarConfig.EyeSize; + + Renderer renderer = quad.GetComponent(); + renderer.material = new Material(glow); + renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; + renderer.receiveShadows = false; + } + + return holder.transform; + } + + /// + /// 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. + /// + private static Shader ResolveGlowShader() + { + if (glowShaderResolved) return cachedGlowShader; + glowShaderResolved = true; + + string[] candidates = { "Sprites/Default", "Unlit/Color", "UI/Default", "Particles/Standard Unlit", "Standard" }; + foreach (string name in candidates) + { + Shader shader = Shader.Find(name); + if (shader == null) continue; + + Jotunn.Logger.LogInfo($"[Dvergar] Eye glow shader resolved to '{name}'."); + cachedGlowShader = shader; + return cachedGlowShader; + } + + Jotunn.Logger.LogWarning( + "[Dvergar] No glow shader resolved (" + string.Join(", ", candidates) + "); eyes stay unlit."); + return null; + } + // ─── Shader survey ─────────────────────────────────────────────────── private static bool loggedSkinShader; -- 2.52.0 From 76b89a8e5a088e2bc0cc18d857949ca052208c45 Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 20:14:08 +0200 Subject: [PATCH 06/30] fix(dvergar): put the eyes on the head instead of on the camera Both faults reported came from the same wrong anchor. Character.m_eye is the camera's eye point, not the model's: it lives outside the scaled rig, so on a Dvergar - who renders at 78% - the quads hung where a full-height human's face would have been, a foot above the head. And it turns with the look direction rather than with the face, so they pointed wherever the player was looking rather than wherever the head was. They now hang off the player root, unscaled, and are placed onto the head bone in world space every frame: position from the bone, orientation from the player's own facing, and every offset multiplied by the race's visual scale so they shrink with the body. That also means the placement constants are honest metres measured from the base of the skull, which is what makes them tunable at all. Driven per frame from the two places that already tick a Dvergar - the race script for the local player, the visual controller for remote ones - because world-space placement has to be re-applied rather than inherited. --- JotunnModStub/Dvergar/DvergarConfig.cs | 23 +++++++----- JotunnModStub/Dvergar/DvergarRace.cs | 4 +++ JotunnModStub/Dvergar/DvergarVisuals.cs | 48 ++++++++++++++++++------- JotunnModStub/ZdoVisualSync.cs | 1 + 4 files changed, 56 insertions(+), 20 deletions(-) diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index 15ac579..cd1319d 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -87,14 +87,21 @@ namespace RacesOfValheim // instead. Nothing else in the mod does this, so there was no working example to copy; // the Aswid's red eyes were never built at all, only cleaned up. // - // Offsets are in metres from Character.m_eye, which already sits at eye height and faces - // wherever the player is looking, so no bone axes have to be guessed at. EyeForward is - // the one to tune first: too little and the quads sink into the face, too much and they - // float in front of it. - public static readonly float EyeSeparation = 0.035f; // half the distance between them - public static readonly float EyeForward = 0.075f; - public static readonly float EyeHeight = -0.010f; - public static readonly float EyeSize = 0.022f; + // Offsets are in metres from the head bone, along the player's own facing, and every one + // of them is multiplied by the race's visual scale so they shrink with a Dvergar rather + // than hanging where a full-height human's face would have been. + // + // The first attempt hung them off Character.m_eye instead. That is the camera's eye + // point, not the model's: it sits outside the scaled rig, so the quads floated above and + // in front of a shrunken Dvergar, and it turns with the look direction rather than the + // head, so they never sat in the face at all. + // + // EyeForward and EyeHeight are the two to tune, measured from the head bone at the base + // of the skull. + public static readonly float EyeSeparation = 0.032f; // half the distance between them + public static readonly float EyeForward = 0.090f; + public static readonly float EyeHeight = 0.080f; + public static readonly float EyeSize = 0.020f; // Base glow, before any star. The tiers replace it with the emissive colours the game // itself gives a starred dverger - RGBA(0, 4, 3.3) at one star and RGBA(12, 0, 8.8) at diff --git a/JotunnModStub/Dvergar/DvergarRace.cs b/JotunnModStub/Dvergar/DvergarRace.cs index 9b55b9b..731dbab 100644 --- a/JotunnModStub/Dvergar/DvergarRace.cs +++ b/JotunnModStub/Dvergar/DvergarRace.cs @@ -69,6 +69,10 @@ namespace RacesOfValheim DvergarVisuals.ApplyHood(player); + // Every frame, because the eyes are placed onto the head bone in world space rather + // than parented to it - see ApplyEyes for why. + DvergarVisuals.ApplyEyes(player); + // Max health is recomputed by Player.UpdateFood, which runs on its own schedule. Left // to itself the malus would only take effect at the next food tick, so a change of // race or of tier is pushed through immediately - this is also what makes the health diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index a253124..9bcf07a 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -117,21 +117,20 @@ namespace RacesOfValheim /// /// Keeps two small emissive quads sitting over the player's painted-on eyes, coloured by /// star tier. Safe to call for anyone: it removes them again from whoever is not a living - /// Dvergar. + /// Dvergar. Call it every frame - it builds once and then only follows the head. /// - /// They hang off Character.m_eye rather than the head bone. m_eye is already at eye - /// height and already faces the look direction, so the offsets below are plain metres in - /// an obvious frame - no working out which way a rig bone happens to point, and no - /// fighting the 100x scale the player armature is authored at. + /// The holder hangs off the player root, which is unscaled, and is placed onto the head + /// bone in world space each frame. That is deliberate. Parenting straight to the head + /// bone would drag in the 100x scale the armature is authored at, and parenting to + /// Character.m_eye - the first attempt - put them outside the scaled rig entirely, which + /// is why they floated above a shrunken Dvergar and turned with the camera instead of the + /// face. Reading the bone's position and the player's facing sidesteps both. /// public static void ApplyEyes(Player player) { if (player == null) return; - Transform anchor = player.m_eye; - if (anchor == null) return; - - Transform eyes = anchor.Find(EyesName); + Transform eyes = player.transform.Find(EyesName); if (!IsDvergarPlayer(player) || player.IsDead()) { @@ -145,9 +144,25 @@ namespace RacesOfValheim return; } - if (eyes == null) eyes = BuildEyes(anchor); + Animator animator = player.GetComponentInChildren(); + Transform headBone = animator != null ? animator.GetBoneTransform(HumanBodyBones.Head) : null; + if (headBone == null) return; // rig not up yet; try again next frame + + if (eyes == null) eyes = BuildEyes(player); if (eyes == null) return; // already logged once by the resolver + // Everything is expressed in the player's own frame and multiplied by the race's + // visual scale, so the eyes sit in a Dvergar's face at Dvergar size rather than where + // a full-height human's would have been. + float raceScale = GetVisualScale(player); + Transform root = player.transform; + + eyes.position = headBone.position + + root.forward * (DvergarConfig.EyeForward * raceScale) + + root.up * (DvergarConfig.EyeHeight * raceScale); + eyes.rotation = Quaternion.LookRotation(root.forward, root.up); + eyes.localScale = Vector3.one * raceScale; + Color glow = GetEyeColor(player); foreach (Renderer renderer in eyes.GetComponentsInChildren(true)) { @@ -159,6 +174,13 @@ namespace RacesOfValheim } } + /// The scale the race is currently rendering its body at; 1 for anyone not resized. + private static float GetVisualScale(Player player) + { + GameObject visual = Traverse.Create(player).Field("m_visual").GetValue(); + return visual != null ? visual.transform.localScale.x : 1f; + } + /// /// One star and two stars use the emissive colours the game gives a starred dverger, read /// off the same LevelSetup list the skin tint comes from. Only the base tier is ours. @@ -171,13 +193,15 @@ namespace RacesOfValheim return DvergarConfig.BaseEyeColor; } - private static Transform BuildEyes(Transform anchor) + private static Transform BuildEyes(Player player) { Shader glow = ResolveGlowShader(); if (glow == null) return null; + // Under the player root rather than the rig: ApplyEyes drives the transform in world + // space every frame, and an unscaled parent keeps the offsets honest metres. GameObject holder = new GameObject(EyesName); - holder.transform.SetParent(anchor, false); + holder.transform.SetParent(player.transform, false); holder.transform.localPosition = Vector3.zero; holder.transform.localRotation = Quaternion.identity; holder.transform.localScale = Vector3.one; diff --git a/JotunnModStub/ZdoVisualSync.cs b/JotunnModStub/ZdoVisualSync.cs index 6a8e688..814f5ee 100644 --- a/JotunnModStub/ZdoVisualSync.cs +++ b/JotunnModStub/ZdoVisualSync.cs @@ -100,6 +100,7 @@ namespace RacesOfValheim // Scale is handled for every player by the Player.Update postfix; this only keeps // the hood and the hidden helmet asserted between equipment refreshes. DvergarVisuals.ApplyHood(m_player); + DvergarVisuals.ApplyEyes(m_player); } else { -- 2.52.0 From bb952ac4c2a080b24fd15cfc3bd4a443b1250b78 Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 20:20:53 +0200 Subject: [PATCH 07/30] fix(dvergar): make the eyes solid, so the camera angle stops deciding whether they exist Two symptoms, one cause each, and both were choices from the first version. Vanishing from certain angles: the eyes were quads. A quad has no thickness, so seen edge-on it is a line and there is nothing to draw. Now spheres, which read the same from every direction. Drawing in front of the face, and visible from behind: the shader resolver was asked for Sprites/Default first and got it. That is a transparent shader with depth writing off and backface culling off - so the eyes drew over whatever was in front of them and stayed visible through the back of the head. The resolver now asks for an unlit opaque shader first, which the skull occludes like any other solid thing. Between them, an eye is now a small solid glowing ball in a face rather than a sticker that only exists at some angles. --- JotunnModStub/Dvergar/DvergarVisuals.cs | 28 +++++++++++++++++-------- 1 file changed, 19 insertions(+), 9 deletions(-) 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); -- 2.52.0 From 8014986f0a117f48ab1522d322ffdf6889125d9a Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 20:28:01 +0200 Subject: [PATCH 08/30] fix(dvergar): socket the eyes into the head bone instead of following it They were placed from the player root's axes every frame, which follows where the body faces and knows nothing about where the head is looking - so an idle animation turned the head and left the eyes behind, reading as attached to the camera rather than to the face. They are children of the head bone now, so position and rotation are inherited and no longer computed. The reason that was avoided in the first place was not knowing which way a rig bone points, and the answer turned out to be to stop guessing: the body's forward and up, expressed in the head bone's local space, are exactly the directions wanted, and because they are local they go on meaning the same thing as the head turns. Measured once at build time, while the head is still looking where the body is. Scale is the only thing still asserted each frame, because it can change under us. The bone carries the armature's hundredfold scale multiplied by whatever the race renders at; dividing it out leaves the holder standing at exactly the race's scale, which keeps the offsets underneath honest metres and keeps the eyes shrinking with a Dvergar. --- JotunnModStub/Dvergar/DvergarVisuals.cs | 58 +++++++++++++++---------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index 66a6928..bc83191 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -130,7 +130,11 @@ namespace RacesOfValheim { if (player == null) return; - Transform eyes = player.transform.Find(EyesName); + Animator animator = player.GetComponentInChildren(); + Transform headBone = animator != null ? animator.GetBoneTransform(HumanBodyBones.Head) : null; + if (headBone == null) return; // rig not up yet; try again next frame + + Transform eyes = headBone.Find(EyesName); if (!IsDvergarPlayer(player) || player.IsDead()) { @@ -144,24 +148,23 @@ namespace RacesOfValheim return; } - Animator animator = player.GetComponentInChildren(); - Transform headBone = animator != null ? animator.GetBoneTransform(HumanBodyBones.Head) : null; - if (headBone == null) return; // rig not up yet; try again next frame - - if (eyes == null) eyes = BuildEyes(player); + if (eyes == null) eyes = BuildEyes(player, headBone); if (eyes == null) return; // already logged once by the resolver - // Everything is expressed in the player's own frame and multiplied by the race's - // visual scale, so the eyes sit in a Dvergar's face at Dvergar size rather than where - // a full-height human's would have been. - float raceScale = GetVisualScale(player); - Transform root = player.transform; - - eyes.position = headBone.position - + root.forward * (DvergarConfig.EyeForward * raceScale) - + root.up * (DvergarConfig.EyeHeight * raceScale); - eyes.rotation = Quaternion.LookRotation(root.forward, root.up); - eyes.localScale = Vector3.one * raceScale; + // The holder is a child of the head bone, so position and rotation are inherited and + // the eyes are socketed rather than followed - the previous version drove them from + // the player root's axes each frame, which meant an idle animation could turn the head + // while the eyes stayed pointing wherever the body did. + // + // Only the scale still needs saying, because it can change under us: the bone carries + // the armature's own hundredfold scale multiplied by whatever the race is rendering + // at, and dividing it out leaves the holder standing at exactly the race's scale, so + // the offsets underneath stay honest metres. + float lossy = headBone.lossyScale.x; + if (Mathf.Abs(lossy) > 0.0001f) + { + eyes.localScale = Vector3.one * (GetVisualScale(player) / lossy); + } Color glow = GetEyeColor(player); foreach (Renderer renderer in eyes.GetComponentsInChildren(true)) @@ -193,17 +196,28 @@ namespace RacesOfValheim return DvergarConfig.BaseEyeColor; } - private static Transform BuildEyes(Player player) + private static Transform BuildEyes(Player player, Transform headBone) { Shader glow = ResolveGlowShader(); if (glow == null) return null; - // Under the player root rather than the rig: ApplyEyes drives the transform in world - // space every frame, and an unscaled parent keeps the offsets honest metres. GameObject holder = new GameObject(EyesName); - holder.transform.SetParent(player.transform, false); + holder.transform.SetParent(headBone, false); holder.transform.localPosition = Vector3.zero; - holder.transform.localRotation = Quaternion.identity; + + // Which way a rig bone points is nobody's business but the artist's, and the head + // bone's axes are not the model's. Rather than guess, ask: the body's own forward and + // up, expressed in the head bone's local space, are exactly the directions wanted - + // and because they are local they keep meaning the same thing as the head turns. + // Measured once, here, while the head is still looking where the body is. + Transform root = player.transform; + Vector3 localForward = headBone.InverseTransformDirection(root.forward).normalized; + Vector3 localUp = headBone.InverseTransformDirection(root.up).normalized; + + holder.transform.localRotation = localForward.sqrMagnitude > 0.0001f + ? Quaternion.LookRotation(localForward, localUp) + : Quaternion.identity; + holder.transform.localScale = Vector3.one; for (int i = 0; i < 2; i++) -- 2.52.0 From e7d60f61baa3b1ce2eccc8d9ce834003b4f3e5ec Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 20:33:13 +0200 Subject: [PATCH 09/30] fix(dvergar): measure where the eyes go instead of guessing at it Three attempts have now placed these by picking a distance from a bone and hoping, and all three landed somewhere wrong - above the head, on the camera, and inside the skull. The distance was never the thing to fix. Character.m_eye is the game's own answer to where a player's eyes are. Asking the head bone to express that point in its local space gives an offset that is correct by construction: no working out which way the bone points, no hand-picked distance from the base of the skull, and because the result is local it rides every head animation without being recomputed. The config offsets stay as small nudges in metres on top of that, with EyeForward pushing out of the skull to the surface of the face. Also logs the bone name, its scale and the measured eye point once per session, so the next round starts from numbers rather than from another guess. --- JotunnModStub/Dvergar/DvergarConfig.cs | 24 +++--- JotunnModStub/Dvergar/DvergarVisuals.cs | 99 +++++++++++++++++-------- 2 files changed, 81 insertions(+), 42 deletions(-) diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index cd1319d..3fa0c72 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -87,20 +87,22 @@ namespace RacesOfValheim // instead. Nothing else in the mod does this, so there was no working example to copy; // the Aswid's red eyes were never built at all, only cleaned up. // - // Offsets are in metres from the head bone, along the player's own facing, and every one - // of them is multiplied by the race's visual scale so they shrink with a Dvergar rather - // than hanging where a full-height human's face would have been. + // These are adjustments in metres on top of a measured starting point, not absolute + // offsets from a bone. The eyes are parented to the head bone and placed at whatever + // Character.m_eye works out to in that bone's local space - the game's own answer to + // where this player's eyes are - so the numbers below only have to nudge, and everything + // rides the head animation because it is expressed in the head's own coordinates. // - // The first attempt hung them off Character.m_eye instead. That is the camera's eye - // point, not the model's: it sits outside the scaled rig, so the quads floated above and - // in front of a shrunken Dvergar, and it turns with the look direction rather than the - // head, so they never sat in the face at all. + // Two earlier attempts guessed instead, and both failed in an instructive way: parented + // to m_eye the eyes floated a foot above a shrunken Dvergar, because m_eye is the + // camera's anchor and lives outside the scaled rig; placed from the player root's axes + // they ignored the head entirely and read as stuck to the camera. // - // EyeForward and EyeHeight are the two to tune, measured from the head bone at the base - // of the skull. + // EyeForward pushes them out of the skull to the surface of the face - it is the one that + // matters. All of them scale with the race. public static readonly float EyeSeparation = 0.032f; // half the distance between them - public static readonly float EyeForward = 0.090f; - public static readonly float EyeHeight = 0.080f; + public static readonly float EyeForward = 0.070f; + public static readonly float EyeHeight = 0.000f; public static readonly float EyeSize = 0.020f; // Base glow, before any star. The tiers replace it with the emissive colours the game diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index bc83191..f04221e 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -151,20 +151,7 @@ namespace RacesOfValheim if (eyes == null) eyes = BuildEyes(player, headBone); if (eyes == null) return; // already logged once by the resolver - // The holder is a child of the head bone, so position and rotation are inherited and - // the eyes are socketed rather than followed - the previous version drove them from - // the player root's axes each frame, which meant an idle animation could turn the head - // while the eyes stayed pointing wherever the body did. - // - // Only the scale still needs saying, because it can change under us: the bone carries - // the armature's own hundredfold scale multiplied by whatever the race is rendering - // at, and dividing it out leaves the holder standing at exactly the race's scale, so - // the offsets underneath stay honest metres. - float lossy = headBone.lossyScale.x; - if (Mathf.Abs(lossy) > 0.0001f) - { - eyes.localScale = Vector3.one * (GetVisualScale(player) / lossy); - } + PlaceEyes(player, headBone, eyes); Color glow = GetEyeColor(player); foreach (Renderer renderer in eyes.GetComponentsInChildren(true)) @@ -196,28 +183,78 @@ namespace RacesOfValheim return DvergarConfig.BaseEyeColor; } + /// + /// Puts the two eyes where the face is, in the head bone's own coordinates, every frame. + /// + /// The placement is measured rather than guessed. Character.m_eye is the game's own answer + /// to "where are this player's eyes", and asking the head bone to express that point in + /// its local space gives an offset that is correct by construction - no working out which + /// way the bone points, no hand-picked distance from the base of the skull. Being local, + /// it then rides every head animation for free. + /// + /// The config offsets stay, as small adjustments in metres on top of that measurement. + /// + private static void PlaceEyes(Player player, Transform headBone, Transform holder) + { + float lossy = headBone.lossyScale.x; + if (Mathf.Abs(lossy) < 0.0001f) return; + + Transform root = player.transform; + + // Metres -> the head bone's local units, which the armature authors at roughly 100x. + float toLocal = 1f / lossy; + + Vector3 localEye = player.m_eye != null + ? headBone.InverseTransformPoint(player.m_eye.position) + : Vector3.zero; + + Vector3 localForward = headBone.InverseTransformDirection(root.forward).normalized; + Vector3 localUp = headBone.InverseTransformDirection(root.up).normalized; + Vector3 localRight = headBone.InverseTransformDirection(root.right).normalized; + + float raceScale = GetVisualScale(player); + Vector3 baseLocal = localEye + + localForward * (DvergarConfig.EyeForward * raceScale * toLocal) + + localUp * (DvergarConfig.EyeHeight * raceScale * toLocal); + + float eyeLocalSize = DvergarConfig.EyeSize * raceScale * toLocal; + + for (int i = 0; i < holder.childCount; i++) + { + Transform eye = holder.GetChild(i); + float side = i == 0 ? -1f : 1f; + + eye.localPosition = baseLocal + localRight * (side * DvergarConfig.EyeSeparation * raceScale * toLocal); + eye.localScale = Vector3.one * eyeLocalSize; + } + + LogEyePlacementOnce(headBone, localEye, localForward, lossy, raceScale); + } + + private static bool loggedEyePlacement; + + private static void LogEyePlacementOnce(Transform headBone, Vector3 localEye, Vector3 localForward, float lossy, float raceScale) + { + if (loggedEyePlacement) return; + loggedEyePlacement = true; + + Jotunn.Logger.LogInfo( + $"[Dvergar] Eyes on bone '{headBone.name}': lossyScale={lossy:F2} raceScale={raceScale:F2} " + + $"localEyePoint={localEye} localForward={localForward}"); + } + private static Transform BuildEyes(Player player, Transform headBone) { Shader glow = ResolveGlowShader(); if (glow == null) return null; + // Straight onto the head bone, with no rotation of its own: everything underneath is + // expressed in the bone's own local space by PlaceEyes, so position and rotation are + // inherited from the skull rather than recomputed against the body. GameObject holder = new GameObject(EyesName); holder.transform.SetParent(headBone, false); holder.transform.localPosition = Vector3.zero; - - // Which way a rig bone points is nobody's business but the artist's, and the head - // bone's axes are not the model's. Rather than guess, ask: the body's own forward and - // up, expressed in the head bone's local space, are exactly the directions wanted - - // and because they are local they keep meaning the same thing as the head turns. - // Measured once, here, while the head is still looking where the body is. - Transform root = player.transform; - Vector3 localForward = headBone.InverseTransformDirection(root.forward).normalized; - Vector3 localUp = headBone.InverseTransformDirection(root.up).normalized; - - holder.transform.localRotation = localForward.sqrMagnitude > 0.0001f - ? Quaternion.LookRotation(localForward, localUp) - : Quaternion.identity; - + holder.transform.localRotation = Quaternion.identity; holder.transform.localScale = Vector3.one; for (int i = 0; i < 2; i++) @@ -238,11 +275,11 @@ namespace RacesOfValheim Object.Destroy(collider); } + // Position and size are PlaceEyes' business, and it runs immediately after this. eye.transform.SetParent(holder.transform, false); - eye.transform.localPosition = new Vector3( - side * DvergarConfig.EyeSeparation, DvergarConfig.EyeHeight, DvergarConfig.EyeForward); + eye.transform.localPosition = Vector3.zero; eye.transform.localRotation = Quaternion.identity; - eye.transform.localScale = Vector3.one * DvergarConfig.EyeSize; + eye.transform.localScale = Vector3.zero; Renderer renderer = eye.GetComponent(); renderer.material = new Material(glow); -- 2.52.0 From c974977f6469d2d1d323b2b71441bc61e986d43e Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 20:37:45 +0200 Subject: [PATCH 10/30] fix(dvergar): hang the eyes on the bone the mesh is actually skinned to A child transform cannot ignore its parent's rotation, so eyes that followed the body but sat out every idle bob of the head were never parented to the head that was moving. They were parented to the Animator avatar's HumanBodyBones.Head, which on this rig is a transform that travels with the player and is not the one the animation drives. The rest of the mod has never used the avatar for this. The hood, the Skeleton's body swap and the Furling's head all take the bone off VisEquipment.m_bodyModel.bones - the array the skinned mesh deforms with, which is by definition the rig that moves. The eyes do too now, with the avatar left as a fallback only for the case where the body model is not up yet. The one-shot log prints both candidates side by side and says whether they are the same transform, so the next report confirms or kills this outright rather than leaving it to inference. --- JotunnModStub/Dvergar/DvergarVisuals.cs | 43 +++++++++++++++++++++---- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index f04221e..c36d138 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -130,8 +130,7 @@ namespace RacesOfValheim { if (player == null) return; - Animator animator = player.GetComponentInChildren(); - Transform headBone = animator != null ? animator.GetBoneTransform(HumanBodyBones.Head) : null; + Transform headBone = FindHeadBone(player); if (headBone == null) return; // rig not up yet; try again next frame Transform eyes = headBone.Find(EyesName); @@ -164,6 +163,30 @@ namespace RacesOfValheim } } + /// + /// The head bone the body mesh is actually skinned to. + /// + /// Not the Animator's. Asking the avatar for HumanBodyBones.Head returned a transform that + /// moves with the player but is not the one the head animation drives - which is why the + /// eyes tracked the body faithfully and ignored every idle bob of the head while being + /// parented to it, a thing a child transform cannot otherwise do. The rest of this mod has + /// always taken the head off VisEquipment.m_bodyModel.bones, the array the skinned mesh + /// deforms with, and that is the rig that moves. + /// + private static Transform FindHeadBone(Player player) + { + VisEquipment visEq = player.GetComponent(); + if (visEq != null && visEq.m_bodyModel != null && visEq.m_bodyModel.bones != null) + { + Transform bone = FindBoneByName(visEq.m_bodyModel.bones, DvergarConfig.PlayerHeadBoneName); + if (bone != null) return bone; + } + + // Last resort, and only so that something renders if the body model is not up yet. + Animator animator = player.GetComponentInChildren(); + return animator != null ? animator.GetBoneTransform(HumanBodyBones.Head) : null; + } + /// The scale the race is currently rendering its body at; 1 for anyone not resized. private static float GetVisualScale(Player player) { @@ -228,19 +251,27 @@ namespace RacesOfValheim eye.localScale = Vector3.one * eyeLocalSize; } - LogEyePlacementOnce(headBone, localEye, localForward, lossy, raceScale); + LogEyePlacementOnce(player, headBone, localEye, localForward, lossy, raceScale); } private static bool loggedEyePlacement; - private static void LogEyePlacementOnce(Transform headBone, Vector3 localEye, Vector3 localForward, float lossy, float raceScale) + private static void LogEyePlacementOnce(Player player, Transform headBone, Vector3 localEye, Vector3 localForward, float lossy, float raceScale) { if (loggedEyePlacement) return; loggedEyePlacement = true; Jotunn.Logger.LogInfo( - $"[Dvergar] Eyes on bone '{headBone.name}': lossyScale={lossy:F2} raceScale={raceScale:F2} " + - $"localEyePoint={localEye} localForward={localForward}"); + $"[Dvergar] Eyes on bone '{headBone.name}' at {headBone.position}: lossyScale={lossy:F2} " + + $"raceScale={raceScale:F2} localEyePoint={localEye} localForward={localForward}"); + + // The two candidates side by side. If these are different transforms, that difference + // is the whole story of why the eyes ignored the head animation. + Animator animator = player.GetComponentInChildren(); + Transform avatarHead = animator != null ? animator.GetBoneTransform(HumanBodyBones.Head) : null; + Jotunn.Logger.LogInfo( + $"[Dvergar] avatar head: {(avatarHead != null ? $"'{avatarHead.name}' at {avatarHead.position}" : "none")}" + + $" | same transform = {avatarHead == headBone}"); } private static Transform BuildEyes(Player player, Transform headBone) -- 2.52.0 From 7651a0727907910c373dbe19f8d09f4c58c853b1 Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 20:43:24 +0200 Subject: [PATCH 11/30] chore(dvergar): trace where the eyes actually are, not where they should be The arithmetic puts them 7cm from the head bone and the screen puts them metres away, so the offsets are not the thing to keep adjusting. Traces position, parent, local and world transforms and the distance from the head, six times over the first few seconds - enough to tell a bad offset from an object that is not parented, or one that is parented and then moved. --- JotunnModStub/Dvergar/DvergarVisuals.cs | 41 ++++++++++++++++--------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index c36d138..3dea9d8 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -251,27 +251,40 @@ namespace RacesOfValheim eye.localScale = Vector3.one * eyeLocalSize; } - LogEyePlacementOnce(player, headBone, localEye, localForward, lossy, raceScale); + LogEyeTrace(player, headBone, holder, lossy, raceScale); } - private static bool loggedEyePlacement; + // Traced repeatedly rather than once. The arithmetic says these eyes land 7cm from the + // head bone, and the screen says they are metres away - so the useful question is no + // longer what the offsets are, but whether the objects are where they were put and whether + // they stay there. Position, parent and distance, several times over the first few + // seconds, answers both. + private static int eyeTraceCount; + private static float nextEyeTrace; - private static void LogEyePlacementOnce(Player player, Transform headBone, Vector3 localEye, Vector3 localForward, float lossy, float raceScale) + private static void LogEyeTrace(Player player, Transform headBone, Transform holder, float lossy, float raceScale) { - if (loggedEyePlacement) return; - loggedEyePlacement = true; + if (eyeTraceCount >= 6 || Time.time < nextEyeTrace) return; + eyeTraceCount++; + nextEyeTrace = Time.time + 2f; + + Transform eye = holder.childCount > 0 ? holder.GetChild(0) : null; Jotunn.Logger.LogInfo( - $"[Dvergar] Eyes on bone '{headBone.name}' at {headBone.position}: lossyScale={lossy:F2} " + - $"raceScale={raceScale:F2} localEyePoint={localEye} localForward={localForward}"); - - // The two candidates side by side. If these are different transforms, that difference - // is the whole story of why the eyes ignored the head animation. - Animator animator = player.GetComponentInChildren(); - Transform avatarHead = animator != null ? animator.GetBoneTransform(HumanBodyBones.Head) : null; + $"[Dvergar] trace {eyeTraceCount}: player={player.transform.position} head={headBone.position} " + + $"lossy={lossy:F2} race={raceScale:F2}"); Jotunn.Logger.LogInfo( - $"[Dvergar] avatar head: {(avatarHead != null ? $"'{avatarHead.name}' at {avatarHead.position}" : "none")}" + - $" | same transform = {avatarHead == headBone}"); + $"[Dvergar] holder parent='{(holder.parent != null ? holder.parent.name : "none")}' " + + $"localPos={holder.localPosition} localScale={holder.localScale} world={holder.position}"); + + if (eye != null) + { + Jotunn.Logger.LogInfo( + $"[Dvergar] eye parent='{(eye.parent != null ? eye.parent.name : "none")}' " + + $"localPos={eye.localPosition} localScale={eye.localScale} world={eye.position} " + + $"distFromHead={Vector3.Distance(eye.position, headBone.position):F3}m " + + $"worldSize={eye.lossyScale.x:F3}m"); + } } private static Transform BuildEyes(Player player, Transform headBone) -- 2.52.0 From f93b57ceff9155963017b7b66aa6d714e986353f Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 20:47:17 +0200 Subject: [PATCH 12/30] fix(dvergar): stop measuring the eyes from the camera anchor The trace found it. An eye sat at local (0, 0.0066, 0) on a bone with a scale of 78, which is 0.513m straight up - exactly the distance being reported from the head. The offsets in play are 0.0007 local units, three orders of magnitude too small to account for that, so the drift was never in them. It was the origin. The previous version started from Character.m_eye on the reasoning that it is the game's own answer to where a player's eyes are, and it is not: it is where the camera goes, half a metre above the head bone. Everything after that was correct arithmetic applied to the wrong point, which is why five rounds of adjusting the offsets changed nothing. Placement now starts at the head bone and nowhere else. The offsets return to real distances for a face - forward to the surface of the skull, up from its base - and the frame conversion is left alone, since the same trace proved it right: 0.0002 local units on a bone scaled 78 rendered as a 0.016m eye, exactly as asked. --- JotunnModStub/Dvergar/DvergarConfig.cs | 23 +++++++++-------------- JotunnModStub/Dvergar/DvergarVisuals.cs | 14 ++++++++------ 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index 3fa0c72..6078c2d 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -87,22 +87,17 @@ namespace RacesOfValheim // instead. Nothing else in the mod does this, so there was no working example to copy; // the Aswid's red eyes were never built at all, only cleaned up. // - // These are adjustments in metres on top of a measured starting point, not absolute - // offsets from a bone. The eyes are parented to the head bone and placed at whatever - // Character.m_eye works out to in that bone's local space - the game's own answer to - // where this player's eyes are - so the numbers below only have to nudge, and everything - // rides the head animation because it is expressed in the head's own coordinates. + // Metres from the head bone, which sits at the base of the skull, along the player's own + // forward and up. The eyes are parented to that bone, so all of this rides the head + // animation, and every offset scales with the race. // - // Two earlier attempts guessed instead, and both failed in an instructive way: parented - // to m_eye the eyes floated a foot above a shrunken Dvergar, because m_eye is the - // camera's anchor and lives outside the scaled rig; placed from the player root's axes - // they ignored the head entirely and read as stuck to the camera. - // - // EyeForward pushes them out of the skull to the surface of the face - it is the one that - // matters. All of them scale with the race. + // Do not reintroduce Character.m_eye as a starting point. It reads like the right + // 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 - + // the trace is in the commit history. public static readonly float EyeSeparation = 0.032f; // half the distance between them - public static readonly float EyeForward = 0.070f; - public static readonly float EyeHeight = 0.000f; + public static readonly float EyeForward = 0.095f; + public static readonly float EyeHeight = 0.070f; public static readonly float EyeSize = 0.020f; // Base glow, before any star. The tiers replace it with the emissive colours the game diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index 3dea9d8..ffdac13 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -227,17 +227,19 @@ namespace RacesOfValheim // Metres -> the head bone's local units, which the armature authors at roughly 100x. float toLocal = 1f / lossy; - Vector3 localEye = player.m_eye != null - ? headBone.InverseTransformPoint(player.m_eye.position) - : Vector3.zero; - Vector3 localForward = headBone.InverseTransformDirection(root.forward).normalized; Vector3 localUp = headBone.InverseTransformDirection(root.up).normalized; Vector3 localRight = headBone.InverseTransformDirection(root.right).normalized; + // Measured from the head bone itself, and from nothing else. + // + // The previous version started from Character.m_eye, on the reasoning that it is the + // game's own answer to where a player's eyes are. It is not - it is where the camera + // goes, and the trace showed it sitting 0.51m straight above the head bone. That half + // metre was the entire drift: the offsets below are under a centimetre in local units + // and never stood a chance of mattering next to it. float raceScale = GetVisualScale(player); - Vector3 baseLocal = localEye - + localForward * (DvergarConfig.EyeForward * raceScale * toLocal) + Vector3 baseLocal = localForward * (DvergarConfig.EyeForward * raceScale * toLocal) + localUp * (DvergarConfig.EyeHeight * raceScale * toLocal); float eyeLocalSize = DvergarConfig.EyeSize * raceScale * toLocal; -- 2.52.0 From e512dcfb93d43b7481d7eaf7fa2dff4f2a497ea8 Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 20:51:11 +0200 Subject: [PATCH 13/30] 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. --- JotunnModStub/Dvergar/DvergarConfig.cs | 8 ++++++-- JotunnModStub/Dvergar/DvergarVisuals.cs | 11 +++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index 6078c2d..0498cd9 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -95,9 +95,13 @@ namespace RacesOfValheim // 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 - // 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 EyeForward = 0.095f; - public static readonly float EyeHeight = 0.070f; + public static readonly float EyeForward = 0.140f; + public static readonly float EyeHeight = 0.100f; public static readonly float EyeSize = 0.020f; // Base glow, before any star. The tiers replace it with the emissive colours the game diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index ffdac13..befdaef 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -281,11 +281,18 @@ namespace RacesOfValheim 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( $"[Dvergar] eye parent='{(eye.parent != null ? eye.parent.name : "none")}' " + $"localPos={eye.localPosition} localScale={eye.localScale} world={eye.position} " + - $"distFromHead={Vector3.Distance(eye.position, headBone.position):F3}m " + - $"worldSize={eye.lossyScale.x:F3}m"); + $"distFromHead={offset.magnitude:F3}m up={offset.y:F3}m " + + $"towardFace={towardFace:F2} worldSize={eye.lossyScale.x:F3}m"); } } -- 2.52.0 From 196e4135738270053e53793986980613367ce8b8 Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 20:54:30 +0200 Subject: [PATCH 14/30] fix(dvergar): measure the skull's axes once, so the eyes turn with the head The eyes were parented to the head bone and still ignored every head animation, which should have been impossible - a child cannot refuse its parent's rotation. It was not refusing it. It was being handed the exact opposite every frame. The offsets were built from directions computed as headBone.InverseTransformDirection(playerRoot.forward), and that was recomputed on every placement. As the head turns, the same world direction expressed in the head's local space rotates by exactly the negative of the head's rotation - so the local offset counter-rotated and cancelled the animation out. The eyes rode the head's position perfectly and its rotation not at all, which is exactly what it looked like from the first screenshot onwards. The axes are now measured once, at build time, while the head is still looking where the body is, and kept on the eye holder. Fixed in the skull's frame, they ride every animation for free - which was the whole point of parenting to the bone in the first place. --- JotunnModStub/Dvergar/DvergarVisuals.cs | 37 +++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index befdaef..5357b6a 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -111,6 +111,18 @@ namespace RacesOfValheim private const string EyesName = "DvergarEyes"; + /// + /// The skull's own idea of forward, up and right, measured once while the head is still + /// looking where the body is. Kept on the eye holder so it survives as long as the eyes + /// do, and so nothing is tempted to work it out again from a rig that has since moved. + /// + private class EyeFrame : MonoBehaviour + { + public Vector3 LocalForward = Vector3.forward; + public Vector3 LocalUp = Vector3.up; + public Vector3 LocalRight = Vector3.right; + } + private static Shader cachedGlowShader; private static bool glowShaderResolved; @@ -227,9 +239,19 @@ namespace RacesOfValheim // Metres -> the head bone's local units, which the armature authors at roughly 100x. float toLocal = 1f / lossy; - Vector3 localForward = headBone.InverseTransformDirection(root.forward).normalized; - Vector3 localUp = headBone.InverseTransformDirection(root.up).normalized; - Vector3 localRight = headBone.InverseTransformDirection(root.right).normalized; + // Read back, never recomputed. Deriving these from the player root every frame is + // what kept the eyes from turning with the head: as the head rotates, + // InverseTransformDirection returns a direction rotated by exactly the opposite + // amount, so the offset counter-rotated and cancelled the head's own movement out. + // The eyes moved with the head and never turned with it, which is precisely what it + // looked like. Measured once at build time, they are fixed in the skull's frame and + // ride every animation for free. + EyeFrame frame = holder.GetComponent(); + if (frame == null) return; + + Vector3 localForward = frame.LocalForward; + Vector3 localUp = frame.LocalUp; + Vector3 localRight = frame.LocalRight; // Measured from the head bone itself, and from nothing else. // @@ -310,6 +332,15 @@ namespace RacesOfValheim holder.transform.localRotation = Quaternion.identity; holder.transform.localScale = Vector3.one; + // The one moment worth asking the rig which way it faces: now, before an animation has + // had a chance to turn the head away from the body. From here on the answer is kept + // and the skull carries it around. + Transform root = player.transform; + EyeFrame frame = holder.AddComponent(); + frame.LocalForward = headBone.InverseTransformDirection(root.forward).normalized; + frame.LocalUp = headBone.InverseTransformDirection(root.up).normalized; + frame.LocalRight = headBone.InverseTransformDirection(root.right).normalized; + for (int i = 0; i < 2; i++) { float side = i == 0 ? -1f : 1f; -- 2.52.0 From 7c9c1ca63046ffb36773c8f5ffc888aac9bae934 Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 20:59:01 +0200 Subject: [PATCH 15/30] fix(dvergar): square the skull's axes so the eyes sit on the eye line The trace showed the offsets arriving tilted: 0.109m of forward and 0.078m of up came out as 0.124 forward and 0.059 up, which is the jaw rather than the eyes. towardFace read 0.99, so the direction was never wrong - only leaning. The axes are measured from whatever pose the head is in on the frame the eyes are built, and a head pitched a few degrees hands back a forward that leans down and an up that leans back. A bone's real axes are square, so the measurement is now rounded to the nearest one. The tilt was the pose at the moment of asking and nothing else. --- JotunnModStub/Dvergar/DvergarVisuals.cs | 29 ++++++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index 5357b6a..393a23d 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -318,6 +318,21 @@ namespace RacesOfValheim } } + /// + /// Rounds a direction to the nearest of the six axis directions. Whichever component is + /// largest wins, sign included. + /// + private static Vector3 SnapToAxis(Vector3 direction) + { + float x = Mathf.Abs(direction.x); + float y = Mathf.Abs(direction.y); + float z = Mathf.Abs(direction.z); + + if (x >= y && x >= z) return new Vector3(Mathf.Sign(direction.x), 0f, 0f); + if (y >= z) return new Vector3(0f, Mathf.Sign(direction.y), 0f); + return new Vector3(0f, 0f, Mathf.Sign(direction.z)); + } + private static Transform BuildEyes(Player player, Transform headBone) { Shader glow = ResolveGlowShader(); @@ -332,14 +347,16 @@ namespace RacesOfValheim holder.transform.localRotation = Quaternion.identity; holder.transform.localScale = Vector3.one; - // The one moment worth asking the rig which way it faces: now, before an animation has - // had a chance to turn the head away from the body. From here on the answer is kept - // and the skull carries it around. + // Ask the rig which way it faces, once - and then round the answer to the skull's own + // axes. The raw measurement is taken at whatever pose the head happens to be in on + // this frame, so it arrives tilted: a "forward" leaning 20 degrees down put the eyes + // at the jaw instead of the eye line. A bone's real axes are square, and the tilt is + // nothing but the pose at the moment of asking, so it is rounded away. Transform root = player.transform; EyeFrame frame = holder.AddComponent(); - frame.LocalForward = headBone.InverseTransformDirection(root.forward).normalized; - frame.LocalUp = headBone.InverseTransformDirection(root.up).normalized; - frame.LocalRight = headBone.InverseTransformDirection(root.right).normalized; + frame.LocalForward = SnapToAxis(headBone.InverseTransformDirection(root.forward)); + frame.LocalUp = SnapToAxis(headBone.InverseTransformDirection(root.up)); + frame.LocalRight = SnapToAxis(headBone.InverseTransformDirection(root.right)); for (int i = 0; i < 2; i++) { -- 2.52.0 From d752dba10d7de59382796f2b7b124b0a2b102878 Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 21:02:00 +0200 Subject: [PATCH 16/30] style(dvergar): raise the eyes to the eye line They were sitting at cheekbone height. Up from 0.100 to 0.140 before the race scale, which is about three centimetres on a Dvergar. --- JotunnModStub/Dvergar/DvergarConfig.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index 0498cd9..a0db05c 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -101,7 +101,7 @@ namespace RacesOfValheim // depth-tested shader then hid completely. public static readonly float EyeSeparation = 0.032f; // half the distance between them public static readonly float EyeForward = 0.140f; - public static readonly float EyeHeight = 0.100f; + public static readonly float EyeHeight = 0.140f; public static readonly float EyeSize = 0.020f; // Base glow, before any star. The tiers replace it with the emissive colours the game -- 2.52.0 From e323530a58db0731749159eeb05d16851bc6c374 Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 21:04:06 +0200 Subject: [PATCH 17/30] style(dvergar): raise the eyes again, onto the painted ones 0.140 to 0.200 before the race scale - about five centimetres on a Dvergar, half again as much as the last nudge, since the glow was still sitting a full eye below the ones on the skin. --- JotunnModStub/Dvergar/DvergarConfig.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index a0db05c..a50002d 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -101,7 +101,7 @@ namespace RacesOfValheim // depth-tested shader then hid completely. public static readonly float EyeSeparation = 0.032f; // half the distance between them public static readonly float EyeForward = 0.140f; - public static readonly float EyeHeight = 0.140f; + public static readonly float EyeHeight = 0.200f; public static readonly float EyeSize = 0.020f; // Base glow, before any star. The tiers replace it with the emissive colours the game -- 2.52.0 From 376000da49bf902f7c9e2a1c263f6abdc6a03f67 Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 21:06:13 +0200 Subject: [PATCH 18/30] style(dvergar): sink the eyes into the sockets EyeForward 0.140 to 0.115 - the axis is depth into the face, and 0.025 before the race scale is about the 2cm asked for on a Dvergar. In profile the glow was sitting off the front of the skull rather than in it. --- JotunnModStub/Dvergar/DvergarConfig.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index a50002d..300cb7d 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -100,7 +100,7 @@ namespace RacesOfValheim // 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 EyeForward = 0.140f; + public static readonly float EyeForward = 0.115f; public static readonly float EyeHeight = 0.200f; public static readonly float EyeSize = 0.020f; -- 2.52.0 From 8c004e3d7ffb1fb89a56115064a705a2dbd9d68f Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 21:09:02 +0200 Subject: [PATCH 19/30] style(dvergar): sink the eyes another centimetre EyeForward 0.115 to 0.105, about a centimetre on a Dvergar. Agreed on the profile - they were still reading as sitting on the face rather than in it. Also records the usable range, which is narrow: 0.095 buried them completely and 0.140 stood them off the skull, so the whole band is four centimetres and the eye is a two-centimetre ball. Most of it is meant to be inside. --- JotunnModStub/Dvergar/DvergarConfig.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index 300cb7d..1a8447e 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -95,12 +95,16 @@ namespace RacesOfValheim // 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 - // 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. + // These are pre-scale numbers: a Dvergar renders at 0.78, so 0.105 forward lands about + // 0.082m out from the bone at the base of the skull. + // + // EyeForward has less room than it looks. At 0.095 the eyes were placed correctly and + // vanished outright - the face surface was in front of them and the shader is + // depth-tested - while 0.140 had them standing off the skull in profile. The whole usable + // band is those four centimetres, and the eye is a two-centimetre ball, so most of it + // ends up buried by design and only the front cap shows. public static readonly float EyeSeparation = 0.032f; // half the distance between them - public static readonly float EyeForward = 0.115f; + public static readonly float EyeForward = 0.105f; public static readonly float EyeHeight = 0.200f; public static readonly float EyeSize = 0.020f; -- 2.52.0 From f4f575b1816665dfdd1da6b6fb83edc4497ca959 Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 21:29:28 +0200 Subject: [PATCH 20/30] style(dvergar): sink the eyes three centimetres EyeForward 0.105 to 0.067, which is 3cm on a Dvergar. This goes well past the depth that buried them before, but that reading was taken with the eyes 10cm lower and on tilted axes, so it does not necessarily describe the face at the eye line. If they vanish, the real floor at this height is now known and 0.105 is the way back. --- JotunnModStub/Dvergar/DvergarConfig.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index 1a8447e..93e78c8 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -104,7 +104,7 @@ namespace RacesOfValheim // band is those four centimetres, and the eye is a two-centimetre ball, so most of it // ends up buried by design and only the front cap shows. public static readonly float EyeSeparation = 0.032f; // half the distance between them - public static readonly float EyeForward = 0.105f; + public static readonly float EyeForward = 0.067f; public static readonly float EyeHeight = 0.200f; public static readonly float EyeSize = 0.020f; -- 2.52.0 From db482ede8721c2c446d88e3a916eb89edfa4c541 Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 21:31:09 +0200 Subject: [PATCH 21/30] style(dvergar): back to the deepest depth that still shows, and smaller eyes 0.067 buried them, so the floor at the eye line is now measured too: the usable band runs from just under 0.105 to about 0.140, and 0.105 is the far end of what reads as inset. Depth being spent, the remaining lever is size. What reads as protruding in profile is mostly the bloom halo rather than the ball, and both scale together - so EyeSize drops from 0.020 to 0.014, which pulls the halo in and leaves less cap standing out without moving the centre back onto the cheek. --- JotunnModStub/Dvergar/DvergarConfig.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index 93e78c8..37b4ab1 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -98,15 +98,18 @@ namespace RacesOfValheim // These are pre-scale numbers: a Dvergar renders at 0.78, so 0.105 forward lands about // 0.082m out from the bone at the base of the skull. // - // EyeForward has less room than it looks. At 0.095 the eyes were placed correctly and - // vanished outright - the face surface was in front of them and the shader is - // depth-tested - while 0.140 had them standing off the skull in profile. The whole usable - // band is those four centimetres, and the eye is a two-centimetre ball, so most of it - // ends up buried by design and only the front cap shows. + // EyeForward has less room than it looks, and both ends of it are measured rather than + // guessed: 0.067 buries the eyes completely behind the face, 0.140 stands them off the + // skull in profile. 0.105 is the far end of what still reads as inset. + // + // Which means depth is spent. Anything that still looks too proud is the glow halo, not + // the geometry - the ball is smaller than the bloom around it - so EyeSize is the lever + // for that, and it shrinks the halo and the protruding cap together without moving the + // centre out of the socket. public static readonly float EyeSeparation = 0.032f; // half the distance between them - public static readonly float EyeForward = 0.067f; + public static readonly float EyeForward = 0.105f; public static readonly float EyeHeight = 0.200f; - public static readonly float EyeSize = 0.020f; + public static readonly float EyeSize = 0.014f; // Base glow, before any star. The tiers replace it with the emissive colours the game // itself gives a starred dverger - RGBA(0, 4, 3.3) at one star and RGBA(12, 0, 8.8) at -- 2.52.0 From 38ba444f641e4f7586840a4afeff4f96abb1f64b Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 21:35:58 +0200 Subject: [PATCH 22/30] style(dvergar): make the eyes bigger and round again 0.014 was 11mm across on a Dvergar, which buried enough of the sphere that the visible cap read as a flat decal rather than an eye. Up to 0.026, past the 0.020 it started at, so more of the ball stands clear of the skull and gets its roundness back. --- JotunnModStub/Dvergar/DvergarConfig.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index 37b4ab1..7c4e93e 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -102,14 +102,15 @@ namespace RacesOfValheim // guessed: 0.067 buries the eyes completely behind the face, 0.140 stands them off the // skull in profile. 0.105 is the far end of what still reads as inset. // - // Which means depth is spent. Anything that still looks too proud is the glow halo, not - // the geometry - the ball is smaller than the bloom around it - so EyeSize is the lever - // for that, and it shrinks the halo and the protruding cap together without moving the - // centre out of the socket. + // Which means depth is spent, and size is the other lever - but it cuts both ways. Taking + // it down to 0.014 did pull the glow into the socket and cost the eye its volume with it: + // at 11mm across, most of the ball is behind the face and the visible cap is flat enough + // to read as a decal rather than an eye. Bigger leaves more sphere standing out of the + // skull, which is what gives it roundness. public static readonly float EyeSeparation = 0.032f; // half the distance between them public static readonly float EyeForward = 0.105f; public static readonly float EyeHeight = 0.200f; - public static readonly float EyeSize = 0.014f; + public static readonly float EyeSize = 0.026f; // Base glow, before any star. The tiers replace it with the emissive colours the game // itself gives a starred dverger - RGBA(0, 4, 3.3) at one star and RGBA(12, 0, 8.8) at -- 2.52.0 From fc608d677a33df96342b0ccdb578460eea76c565 Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 21:37:43 +0200 Subject: [PATCH 23/30] feat(dvergar): make the eye a buried ball showing only its cap Your idea, and a better shape for the problem than balancing a small sphere on the surface. A large ball centred well inside the skull breaks the face with a slice of itself, so the face bounds the glow, it cannot float off the cheek, and the visible size is set by how deep the centre sits rather than by the sphere alone. Sized from the two depths already measured: visible at a centre of 82mm with an 8mm radius, gone at 74mm with the same, which puts the face surface around 85-90mm from the head bone. A 30mm radius centred at 65mm clears that by about a centimetre. --- JotunnModStub/Dvergar/DvergarConfig.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index 7c4e93e..f13e600 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -102,15 +102,19 @@ namespace RacesOfValheim // guessed: 0.067 buries the eyes completely behind the face, 0.140 stands them off the // skull in profile. 0.105 is the far end of what still reads as inset. // - // Which means depth is spent, and size is the other lever - but it cuts both ways. Taking - // it down to 0.014 did pull the glow into the socket and cost the eye its volume with it: - // at 11mm across, most of the ball is behind the face and the visible cap is flat enough - // to read as a decal rather than an eye. Bigger leaves more sphere standing out of the - // skull, which is what gives it roundness. + // The eye is a large ball buried deep, not a small one balanced on the surface. What shows + // is the slice of it that breaks the face - a spherical cap - so the face itself decides + // the shape and the glow can never float off the cheek. Push the centre in to shrink the + // cap, pull it out to grow one. + // + // Sized off two measurements. At a centre of 82mm with an 8mm radius the eyes were + // visible; at 74mm with the same radius they were gone. So the face sits about 85-90mm + // from the head bone, and a 30mm radius centred at 65mm clears it by roughly a + // centimetre. All values here are pre-scale - a Dvergar renders at 0.78. public static readonly float EyeSeparation = 0.032f; // half the distance between them - public static readonly float EyeForward = 0.105f; + public static readonly float EyeForward = 0.083f; // centre ~65mm out public static readonly float EyeHeight = 0.200f; - public static readonly float EyeSize = 0.026f; + public static readonly float EyeSize = 0.077f; // ~60mm across, so a 30mm radius // Base glow, before any star. The tiers replace it with the emissive colours the game // itself gives a starred dverger - RGBA(0, 4, 3.3) at one star and RGBA(12, 0, 8.8) at -- 2.52.0 From aee34caafd73eeee5e2694ad37f43daba785427a Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 21:40:22 +0200 Subject: [PATCH 24/30] style(dvergar): shrink the cap from most of a face to an eye The buried-ball idea is right and the first sizing of it was not: a 30mm radius clearing the face by 9mm showed a 43mm cap. Radius halved to 15mm and the centre pulled out to keep about 4mm of clearance, which gives roughly a 20mm eye. Halving the radius also halves how hard the cap reacts to a millimetre of depth, which matters more than the size itself - the big ball made every adjustment an overshoot. --- JotunnModStub/Dvergar/DvergarConfig.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index f13e600..995139c 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -108,13 +108,18 @@ namespace RacesOfValheim // cap, pull it out to grow one. // // Sized off two measurements. At a centre of 82mm with an 8mm radius the eyes were - // visible; at 74mm with the same radius they were gone. So the face sits about 85-90mm - // from the head bone, and a 30mm radius centred at 65mm clears it by roughly a - // centimetre. All values here are pre-scale - a Dvergar renders at 0.78. + // visible; at 74mm with the same radius they were gone. So the face sits about 86mm from + // the head bone. All values here are pre-scale - a Dvergar renders at 0.78. + // + // The cap grows far faster than the depth that makes it, and faster still on a big ball: + // a 30mm radius clearing the face by 9mm showed a 43mm cap, most of a face. Radius is + // halved for that reason - it does not only shrink the cap, it halves how violently the + // cap answers to a millimetre of depth, which is the difference between tuning this and + // fighting it. 15mm of radius clearing by 4mm gives about 20mm of eye. public static readonly float EyeSeparation = 0.032f; // half the distance between them - public static readonly float EyeForward = 0.083f; // centre ~65mm out + public static readonly float EyeForward = 0.096f; // centre ~75mm out public static readonly float EyeHeight = 0.200f; - public static readonly float EyeSize = 0.077f; // ~60mm across, so a 30mm radius + public static readonly float EyeSize = 0.038f; // ~30mm across, so a 15mm radius // Base glow, before any star. The tiers replace it with the emissive colours the game // itself gives a starred dverger - RGBA(0, 4, 3.3) at one star and RGBA(12, 0, 8.8) at -- 2.52.0 From bd27bd8fd4fbbbbbbd96fa4d9543d502e84d9077 Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 21:44:50 +0200 Subject: [PATCH 25/30] chore(dvergar): retire the eye trace and the shader survey Both were built to answer questions and both answered them: the trace found the camera anchor sitting half a metre above the head bone, the counter-rotating axes, and the tilt that put the eyes at the jaw; the survey established that Custom/Player carries no desaturation control and never will make a pale Dvergar. Neither belongs in a session log now that the answers are known, so the trace goes and the survey's finding stays as the comment that stops anyone re-deriving it. The one-line reports that remain are the ones a game update could invalidate - which glow shader resolved, and the star offsets read off the creature prefab. --- JotunnModStub/Dvergar/DvergarPatches.cs | 3 - JotunnModStub/Dvergar/DvergarVisuals.cs | 105 ++++-------------------- 2 files changed, 16 insertions(+), 92 deletions(-) diff --git a/JotunnModStub/Dvergar/DvergarPatches.cs b/JotunnModStub/Dvergar/DvergarPatches.cs index a744e15..430ff2d 100644 --- a/JotunnModStub/Dvergar/DvergarPatches.cs +++ b/JotunnModStub/Dvergar/DvergarPatches.cs @@ -351,9 +351,6 @@ namespace RacesOfValheim if (__instance.m_bodyModel != null && __instance.m_bodyModel.material != null) { - // Once per session: settles whether this material can be desaturated properly - // or whether the multiplier tint is the ceiling. - DvergarVisuals.LogSkinShaderOnce(__instance.m_bodyModel.material); // Not the flat config colour any more: it carries the star shift a dverger of // this standing would wear, so the race visibly ages at Bonemass and again at diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index 393a23d..db165a4 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -274,48 +274,6 @@ namespace RacesOfValheim eye.localPosition = baseLocal + localRight * (side * DvergarConfig.EyeSeparation * raceScale * toLocal); eye.localScale = Vector3.one * eyeLocalSize; } - - LogEyeTrace(player, headBone, holder, lossy, raceScale); - } - - // Traced repeatedly rather than once. The arithmetic says these eyes land 7cm from the - // head bone, and the screen says they are metres away - so the useful question is no - // longer what the offsets are, but whether the objects are where they were put and whether - // they stay there. Position, parent and distance, several times over the first few - // seconds, answers both. - private static int eyeTraceCount; - private static float nextEyeTrace; - - private static void LogEyeTrace(Player player, Transform headBone, Transform holder, float lossy, float raceScale) - { - if (eyeTraceCount >= 6 || Time.time < nextEyeTrace) return; - eyeTraceCount++; - nextEyeTrace = Time.time + 2f; - - Transform eye = holder.childCount > 0 ? holder.GetChild(0) : null; - - Jotunn.Logger.LogInfo( - $"[Dvergar] trace {eyeTraceCount}: player={player.transform.position} head={headBone.position} " + - $"lossy={lossy:F2} race={raceScale:F2}"); - Jotunn.Logger.LogInfo( - $"[Dvergar] holder parent='{(holder.parent != null ? holder.parent.name : "none")}' " + - $"localPos={holder.localPosition} localScale={holder.localScale} world={holder.position}"); - - 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( - $"[Dvergar] eye parent='{(eye.parent != null ? eye.parent.name : "none")}' " + - $"localPos={eye.localPosition} localScale={eye.localScale} world={eye.position} " + - $"distFromHead={offset.magnitude:F3}m up={offset.y:F3}m " + - $"towardFace={towardFace:F2} worldSize={eye.lossyScale.x:F3}m"); - } } /// @@ -425,53 +383,22 @@ namespace RacesOfValheim // ─── Shader survey ─────────────────────────────────────────────────── - private static bool loggedSkinShader; - - /// - /// Reports what the player's body material can actually be asked to do, once per session. - /// - /// This was written to settle whether a pale Dvergar was reachable, and it settled it: - /// - /// Custom/Player, 13 properties, of which exactly one is a colour - _SkinColor. - /// No _Hue, no _Saturation, no _Value, no _Brightness, no _Grayscale. - /// - /// So the answer is no, and it is a property of the shader rather than of the numbers we - /// pick. A real dverger goes pale at two stars by way of saturation -1 on the creature - /// shader, which genuinely desaturates its texture. The player body has no such control: - /// _SkinColor multiplies the human skin map, and a multiply can darken or bias but never - /// desaturate - the pink is in the texture and survives being multiplied by grey. White - /// is the multiplier's identity, so "paler" and "more human" are the same direction. - /// - /// Getting there would mean replacing _MainTex with a desaturated copy of the skin - /// texture, which is a blit through a custom shader per player - far more machinery than a - /// cosmetic tier is worth. Kept as a check rather than deleted, in case a game update ever - /// changes the player shader. - /// - public static void LogSkinShaderOnce(Material material) - { - if (loggedSkinShader || material == null) return; - loggedSkinShader = true; - - Shader shader = material.shader; - Jotunn.Logger.LogInfo($"[Dvergar] Body shader: '{(shader != null ? shader.name : "null")}'"); - - if (shader != null) - { - int count = shader.GetPropertyCount(); - System.Text.StringBuilder sb = new System.Text.StringBuilder(); - for (int i = 0; i < count; i++) - { - sb.Append(shader.GetPropertyName(i)).Append(" (").Append(shader.GetPropertyType(i)).Append(") "); - } - Jotunn.Logger.LogInfo($"[Dvergar] Body shader has {count} properties: {sb}"); - } - - string[] wanted = { "_Hue", "_Saturation", "_Value", "_Brightness", "_Contrast", "_Grayscale", "_SkinColor" }; - foreach (string name in wanted) - { - Jotunn.Logger.LogInfo($"[Dvergar] HasProperty('{name}') = {material.HasProperty(name)}"); - } - } + // What the player's body material can be asked to do, surveyed once and recorded here + // rather than logged every session: + // + // Custom/Player, 13 properties, of which exactly one is a colour - _SkinColor. + // No _Hue, no _Saturation, no _Value, no _Brightness, no _Grayscale. + // + // Which settles why a pale Dvergar is out of reach, and settles it as a property of the + // shader rather than of the numbers anyone picks. A real dverger goes pale at two stars + // through saturation -1 on the creature shader, which genuinely desaturates its texture. + // The player body has no such control: _SkinColor multiplies the human skin map, and a + // multiply can darken or bias but never desaturate - the pink is in the texture and + // survives being multiplied by grey. White is the multiplier's identity, so "paler" and + // "more human" are the same direction, which is what every attempt walked into. + // + // Getting there would mean replacing _MainTex with a desaturated copy of the skin texture, + // a per-player blit through a custom shader. Disproportionate for a cosmetic tier. private static LevelEffects.LevelSetup GetStarSetup(int tier) { -- 2.52.0 From dae1f96852e53e3a402306d319a4977618c398b6 Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 21:47:41 +0200 Subject: [PATCH 26/30] style(dvergar): sink the eyes slightly and take the glare off them EyeForward 0.096 to 0.094, which sounds like nothing and is not: at this radius the ball clears the face by 4mm and shows a 20mm eye, and 2mm of clearance shows about 16mm. 0.090 would bury it outright, so depth is a fine adjustment here rather than a coarse one. Glow scaled to 0.65 as well. The colours are the game's own HDR values - one star is (0, 4, 3.3) - and everything past 1 clips to white before the bloom pass, which is why the centres read as white lamps instead of teal ones. Dimming them brings the colour back as much as it lowers the brightness. --- JotunnModStub/Dvergar/DvergarConfig.cs | 11 ++++++++++- JotunnModStub/Dvergar/DvergarVisuals.cs | 8 ++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index 995139c..aeca47d 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -116,11 +116,20 @@ namespace RacesOfValheim // halved for that reason - it does not only shrink the cap, it halves how violently the // cap answers to a millimetre of depth, which is the difference between tuning this and // fighting it. 15mm of radius clearing by 4mm gives about 20mm of eye. + // Depth is a fine adjustment at this radius, not a coarse one: 0.096 leaves the ball + // clearing the face by about 4mm and showing a 20mm eye, and 0.090 would bury it + // completely. 0.094 clears by 2mm and shows about 16mm. public static readonly float EyeSeparation = 0.032f; // half the distance between them - public static readonly float EyeForward = 0.096f; // centre ~75mm out + public static readonly float EyeForward = 0.094f; // centre ~73mm out public static readonly float EyeHeight = 0.200f; public static readonly float EyeSize = 0.038f; // ~30mm across, so a 15mm radius + // How hard the eyes burn. The colours the game gives a starred dverger are HDR - one star + // is (0, 4, 3.3) - and anything past 1 clips to white on the way to the bloom pass, which + // is why the centres read as white lamps rather than as teal. Scaling them down brings + // the colour back as much as it lowers the brightness. + public static readonly float EyeGlowStrength = 0.65f; + // Base glow, before any star. The tiers replace it with the emissive colours the game // itself gives a starred dverger - RGBA(0, 4, 3.3) at one star and RGBA(12, 0, 8.8) at // two, both far past 1, which is exactly what makes them bloom rather than just look diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index db165a4..8866589 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -213,9 +213,13 @@ namespace RacesOfValheim private static Color GetEyeColor(Player player) { LevelEffects.LevelSetup setup = GetStarSetup(GetStarTier(GetProgressionState(player))); - if (setup != null && setup.m_setEmissiveColor) return setup.m_emissiveColor; + Color glow = setup != null && setup.m_setEmissiveColor + ? setup.m_emissiveColor + : DvergarConfig.BaseEyeColor; - return DvergarConfig.BaseEyeColor; + // Dimmed on the way out. Alpha is left alone - it is not part of the brightness. + float strength = DvergarConfig.EyeGlowStrength; + return new Color(glow.r * strength, glow.g * strength, glow.b * strength, glow.a); } /// -- 2.52.0 From e3ade9aa6392c549aa05331d4c1b305de2974f4f Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 21:50:46 +0200 Subject: [PATCH 27/30] style(dvergar): sink the eyes a centimetre, drop them, and dim to half A centimetre deeper is a centimetre more radius. The ball cleared the face by 2mm at a 15mm radius, so moving the centre in on its own would have buried it - growing the radius to 24mm lets the centre sit at 63mm and still reach through. Same size of eye, deeper socket, flatter cap. Down about 15mm as well, and the glow scaled to 0.5 across all three tiers. --- JotunnModStub/Dvergar/DvergarConfig.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index aeca47d..7f038a8 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -116,19 +116,23 @@ namespace RacesOfValheim // halved for that reason - it does not only shrink the cap, it halves how violently the // cap answers to a millimetre of depth, which is the difference between tuning this and // fighting it. 15mm of radius clearing by 4mm gives about 20mm of eye. - // Depth is a fine adjustment at this radius, not a coarse one: 0.096 leaves the ball - // clearing the face by about 4mm and showing a 20mm eye, and 0.090 would bury it - // completely. 0.094 clears by 2mm and shows about 16mm. + // Depth and radius move together. The centre can only go deeper if the ball grows to + // reach the face from further back - sink one without the other and the eye is simply + // gone, since at a 15mm radius it cleared the face by 2mm and had nothing to spare. + // + // So a centimetre further in is a centimetre more radius: centre ~63mm out, radius ~24mm, + // still clearing by about 2mm. Same size of eye, sitting deeper, and the cap is flatter + // for it - which is what reads as set into the skull rather than resting on it. public static readonly float EyeSeparation = 0.032f; // half the distance between them - public static readonly float EyeForward = 0.094f; // centre ~73mm out - public static readonly float EyeHeight = 0.200f; - public static readonly float EyeSize = 0.038f; // ~30mm across, so a 15mm radius + public static readonly float EyeForward = 0.081f; // centre ~63mm out + public static readonly float EyeHeight = 0.181f; // ~15mm lower than before + public static readonly float EyeSize = 0.062f; // ~48mm across, so a 24mm radius // How hard the eyes burn. The colours the game gives a starred dverger are HDR - one star // is (0, 4, 3.3) - and anything past 1 clips to white on the way to the bloom pass, which // is why the centres read as white lamps rather than as teal. Scaling them down brings // the colour back as much as it lowers the brightness. - public static readonly float EyeGlowStrength = 0.65f; + public static readonly float EyeGlowStrength = 0.5f; // Base glow, before any star. The tiers replace it with the emissive colours the game // itself gives a starred dverger - RGBA(0, 4, 3.3) at one star and RGBA(12, 0, 8.8) at -- 2.52.0 From e6bf266eea01746c1ba6366fead31ff3fc442a70 Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 21:54:26 +0200 Subject: [PATCH 28/30] fix(dvergar): derive the sideways axis so both eyes sit at the same depth One eye reading correctly while the other creeps up the forehead is what an out-of-square frame looks like. The three axes were each rounded to the nearest one independently, which guarantees nothing about the angles between them - and a right that shares an axis with forward is no longer sideways, so the separation pushes one eye out of the face and pulls the other into it. Right is now a cross product of the other two, which cannot be anything but perpendicular to both. Symmetric by construction rather than by luck of the pose the head was in when the eyes were built. --- JotunnModStub/Dvergar/DvergarVisuals.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index 8866589..50c2344 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -318,7 +318,13 @@ namespace RacesOfValheim EyeFrame frame = holder.AddComponent(); frame.LocalForward = SnapToAxis(headBone.InverseTransformDirection(root.forward)); frame.LocalUp = SnapToAxis(headBone.InverseTransformDirection(root.up)); - frame.LocalRight = SnapToAxis(headBone.InverseTransformDirection(root.right)); + + // Right is derived, never snapped. Rounding all three independently guarantees + // nothing about the angles between them, and a "right" that shares an axis with + // forward stops being sideways: the separation then pushes one eye out of the face + // and pulls the other into it, which is one eye sitting proud of a forehead while its + // twin sits correctly. A cross product cannot be anything but perpendicular. + frame.LocalRight = Vector3.Cross(frame.LocalUp, frame.LocalForward).normalized; for (int i = 0; i < 2; i++) { -- 2.52.0 From ef8fae888a818f6053d87ee1cd31165c018153fe Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 21:59:26 +0200 Subject: [PATCH 29/30] style(dvergar): shrink the model's left eye on its own The pair is placed symmetrically and does not come out symmetrical, because the face is not flat: near the midline the skull juts forward, near the temple it falls away, and a 24mm ball spanning that curve shows more of itself on the receding side. Rather than shrink both and give back the socket depth just gained, the eye that comes out proud is taken to 0.85 on its own. If the wrong one shrinks, the sideways axis resolved the other way round and the multiplier belongs on the other index - which is written down where it is applied. --- JotunnModStub/Dvergar/DvergarConfig.cs | 13 +++++++++++++ JotunnModStub/Dvergar/DvergarVisuals.cs | 8 +++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index 7f038a8..adae154 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -134,6 +134,19 @@ namespace RacesOfValheim // the colour back as much as it lowers the brightness. public static readonly float EyeGlowStrength = 0.5f; + // Applied to the model's left eye alone - the one on your right as you look at it. + // + // The two are placed symmetrically and do not come out symmetrical, because the face they + // emerge through is not flat: nearer the midline the skull juts forward, nearer the temple + // it falls away, so a ball that meets the receding side shows more of itself. With a 24mm + // radius spanning that curve the difference is a visible few millimetres of cap. Rather + // than shrink both and lose the socket depth, the one that comes out proud is taken down + // on its own. + // + // If the wrong eye shrinks, the sideways axis resolved the other way round: apply this to + // index 1 in PlaceEyes instead of index 0. + public static readonly float LeftEyeSizeMultiplier = 0.85f; + // Base glow, before any star. The tiers replace it with the emissive colours the game // itself gives a starred dverger - RGBA(0, 4, 3.3) at one star and RGBA(12, 0, 8.8) at // two, both far past 1, which is exactly what makes them bloom rather than just look diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index 50c2344..6d71ec8 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -273,10 +273,16 @@ namespace RacesOfValheim for (int i = 0; i < holder.childCount; i++) { Transform eye = holder.GetChild(i); + + // Index 0 is offset against the right axis, so it is the model's left eye - the + // one on your right as you face it. It gets its own size, because the face is + // curved and the two sides do not present the same surface to a ball of this + // radius. float side = i == 0 ? -1f : 1f; + float size = i == 0 ? eyeLocalSize * DvergarConfig.LeftEyeSizeMultiplier : eyeLocalSize; eye.localPosition = baseLocal + localRight * (side * DvergarConfig.EyeSeparation * raceScale * toLocal); - eye.localScale = Vector3.one * eyeLocalSize; + eye.localScale = Vector3.one * size; } } -- 2.52.0 From c3c84941373af81d2e0e91fe825e77fabbfdd19e Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 22:02:07 +0200 Subject: [PATCH 30/30] style(dvergar): dim the eyes to 0.3 Applies to all three tiers, so the base teal, the one-star cyan and the two-star magenta come down together and keep their relative brightness. --- JotunnModStub/Dvergar/DvergarConfig.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index adae154..38c21f8 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -132,7 +132,7 @@ namespace RacesOfValheim // is (0, 4, 3.3) - and anything past 1 clips to white on the way to the bloom pass, which // is why the centres read as white lamps rather than as teal. Scaling them down brings // the colour back as much as it lowers the brightness. - public static readonly float EyeGlowStrength = 0.5f; + public static readonly float EyeGlowStrength = 0.3f; // Applied to the model's left eye alone - the one on your right as you look at it. // -- 2.52.0