From 026def2fdebdc55f9f68c2cc8ed6cda70c1f1ccd Mon Sep 17 00:00:00 2001 From: kanym Date: Tue, 27 Oct 2026 15:01:44 +0100 Subject: [PATCH 01/10] fix(eyes): female face placement, smaller Dvergar/Aswid eyes, grey Alfar eyes The female body maps the painted eyes about 6 mm lower and a quarter closer together than the male one (read from bodymale/bodyfem and the skin UVs), so every race's male-tuned eyes sat on the female brow. PlayerFace moves them for the Dvergar, Aswid, Sverm and Alfar. Dvergar eyes shrink to an 18 mm radius. The Aswid's borrowed sockets are halved before the config multiplier and the smoke is off by default. Alfar eyes become slanted, wrapped black almonds with a wet sheen. They are placed in fixed head-local units: the live lossyScale under the non-uniform Alfar body drifted as the head turned, and the 0.5 s cosmetic pass made the eyes trail the face. --- JotunnModStub/Alfar/AlfarConfig.cs | 27 ++++++++----- JotunnModStub/Alfar/AlfarVisuals.cs | 52 +++++++++++++++---------- JotunnModStub/Aswid/AswidConfig.cs | 2 +- JotunnModStub/Aswid/AswidVisuals.cs | 24 ++++++++++-- JotunnModStub/Dvergar/DvergarConfig.cs | 4 +- JotunnModStub/Dvergar/DvergarVisuals.cs | 14 +++++-- JotunnModStub/PlayerFace.cs | 49 +++++++++++++++++++++++ JotunnModStub/Sverm/SvermVisuals.cs | 13 +++++-- 8 files changed, 141 insertions(+), 44 deletions(-) create mode 100644 JotunnModStub/PlayerFace.cs diff --git a/JotunnModStub/Alfar/AlfarConfig.cs b/JotunnModStub/Alfar/AlfarConfig.cs index 1769a1a..7d72e25 100644 --- a/JotunnModStub/Alfar/AlfarConfig.cs +++ b/JotunnModStub/Alfar/AlfarConfig.cs @@ -39,17 +39,26 @@ namespace RacesOfValheim public static ConfigEntry WidthScale; /// - /// 1 is the Sverm's size, which is what the design asked to try first ("se non va li - /// allarghiamo"). Raise it to enlarge the eyes: 1.6 is roughly a grey from the films. + /// Scales the almond eyes (EyeExtent). The default 0.8 is the tuned grey look; raise it for + /// bigger eyes. /// public static ConfigEntry EyeSizeMultiplier; - // The eye geometry is the Sverm's, unchanged (SvermVisuals): offsets are metres in the head - // bone's OWN frame, so they land on the same part of the face at any body scale. - public const float EyeSeparation = 0.032f; - public const float EyeForward = 0.081f; - public const float EyeHeight = 0.181f; - public const float EyeSize = 0.062f; + // A grey's eyes, on the Sverm's eye spot: offsets are metres in the head bone's OWN frame + // at human scale, so they land on the same part of the face at any body scale. + // Pushed apart and forward of the Sverm's, because an almond this wide would otherwise + // meet its twin over the nose and sink into the cheek. + public const float EyeSeparation = 0.037f; + public const float EyeForward = 0.086f; + public const float EyeHeight = 0.183f; + + // Full width, height and depth of one eye in metres at Eye Size Multiplier 1. The saved + // default of 0.8 makes that 50 x 28 x 18 mm. + public static readonly Vector3 EyeExtent = new Vector3(0.0625f, 0.035f, 0.0225f); + + // Degrees. Slant raises the outer corner; wrap turns each eye out toward its temple. + public const float EyeSlant = 22f; + public const float EyeWrap = 20f; // ─── Eitr: diet, shield, soft fall ─────────────────────────────────── @@ -152,7 +161,7 @@ namespace RacesOfValheim new AcceptableValueRange(0.7f, 1.2f))); EyeSizeMultiplier = config.Bind(look, "Eye Size Multiplier", 0.8f, - new ConfigDescription("1 = the Sverm's eye size; 0.8 is slightly smaller. Raise to enlarge the black eyes.", + new ConfigDescription("Scales the black almond eyes. 0.8 is the default look; raise it for bigger eyes.", new AcceptableValueRange(0.5f, 3f))); } } diff --git a/JotunnModStub/Alfar/AlfarVisuals.cs b/JotunnModStub/Alfar/AlfarVisuals.cs index 51d4cd1..c2f2065 100644 --- a/JotunnModStub/Alfar/AlfarVisuals.cs +++ b/JotunnModStub/Alfar/AlfarVisuals.cs @@ -161,35 +161,47 @@ namespace RacesOfValheim } if (eyes == null) return; - PlaceEyes(headBone, eyes); + PlaceEyes(player, eyes); } - private static void PlaceEyes(Transform headBone, Transform holder) + /// + /// A grey's eyes: wide black almonds, outer corners raised, wrapping round the sides of the + /// face. Each is a sphere squashed to an ellipsoid and turned in the skull's own frame. + /// + /// FIXED HEAD-LOCAL UNITS, never headBone.lossyScale. The Alfar Visual is scaled + /// non-uniformly, so the head's lossyScale is only an approximation that changes as the + /// head turns; recomputed on the 0.5s cosmetic pass it made the eyes trail the face. The + /// face is skinned to the same bone through the same matrices, so a constant local offset + /// stays glued to it at any body scale, and PlaceEyes only has to run when the eyes change. + /// + private static void PlaceEyes(Player player, Transform holder) { - Vector3 lossy = headBone.lossyScale; - if (Mathf.Abs(lossy.x) < 0.0001f || Mathf.Abs(lossy.y) < 0.0001f || Mathf.Abs(lossy.z) < 0.0001f) return; - EyeFrame frame = holder.GetComponent(); if (frame == null) return; - // The Visual is scaled non-uniformly (thinner than tall), so lossyScale has three - // different components and a single divisor would squash the spheres. Each axis is - // divided by its own. - Vector3 toLocal = new Vector3(1f / lossy.x, 1f / lossy.y, 1f / lossy.z); - float eyeSize = AlfarConfig.EyeSize * AlfarConfig.EyeSizeMultiplier.Value; + const float toLocal = PlayerFace.MetresToHeadLocal; - Vector3 baseOffset = frame.LocalForward * AlfarConfig.EyeForward + frame.LocalUp * AlfarConfig.EyeHeight; + float height = AlfarConfig.EyeHeight; + float separation = AlfarConfig.EyeSeparation; + float size = AlfarConfig.EyeSizeMultiplier.Value; + PlayerFace.AdjustEyes(player, ref height, ref separation, ref size); + + Vector3 baseOffset = frame.LocalForward * AlfarConfig.EyeForward + frame.LocalUp * height; + Vector3 extent = AlfarConfig.EyeExtent * (size * toLocal); + Quaternion facing = Quaternion.LookRotation(frame.LocalForward, frame.LocalUp); 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. + // Index 0 is offset against the right axis, so it is the model's left eye. The + // slant and the wrap are mirrored so both outer corners go up and back. float side = i == 0 ? -1f : 1f; - Vector3 offset = baseOffset + frame.LocalRight * (side * AlfarConfig.EyeSeparation); + Vector3 offset = baseOffset + frame.LocalRight * (side * separation); - eye.localPosition = Vector3.Scale(offset, toLocal); - eye.localScale = Vector3.Scale(Vector3.one * eyeSize, toLocal); + eye.localPosition = offset * toLocal; + eye.localRotation = facing * Quaternion.Euler(0f, AlfarConfig.EyeWrap * side, AlfarConfig.EyeSlant * side); + eye.localScale = extent; } } @@ -234,9 +246,8 @@ namespace RacesOfValheim } /// - /// Matte black, and nothing else: the colour is black, the emission is black, and the two - /// properties that make a lit shader shine are zeroed where the shader has them. The - /// Sverm's eyes burn; these must read as holes. + /// Black with a wet sheen: no emission, but smooth enough to catch a highlight, which is + /// what makes a grey's eyes read as eyes and not as two holes punched in the face. /// private static Material BlackMaterial(Shader shader) { @@ -244,10 +255,9 @@ namespace RacesOfValheim material.color = Color.black; if (material.HasProperty("_EmissionColor")) material.SetColor("_EmissionColor", Color.black); - if (material.HasProperty("_Glossiness")) material.SetFloat("_Glossiness", 0f); - if (material.HasProperty("_Smoothness")) material.SetFloat("_Smoothness", 0f); + if (material.HasProperty("_Glossiness")) material.SetFloat("_Glossiness", 0.8f); + if (material.HasProperty("_Smoothness")) material.SetFloat("_Smoothness", 0.8f); if (material.HasProperty("_Metallic")) material.SetFloat("_Metallic", 0f); - if (material.HasProperty("_SpecColor")) material.SetColor("_SpecColor", Color.black); return material; } diff --git a/JotunnModStub/Aswid/AswidConfig.cs b/JotunnModStub/Aswid/AswidConfig.cs index 1cf197b..ee02779 100644 --- a/JotunnModStub/Aswid/AswidConfig.cs +++ b/JotunnModStub/Aswid/AswidConfig.cs @@ -453,7 +453,7 @@ namespace RacesOfValheim new ConfigDescription("As above, around the third axis. The default half turn is what rights the borrowed socket, which arrives upside down on a player's head bone.", new AcceptableValueRange(-180f, 180f), new ConfigurationManagerAttributes { Order = 58 })); - EyeSmoke = config.Bind(eyes, "Eye Smoke", true, + EyeSmoke = config.Bind(eyes, "Eye Smoke", false, new ConfigDescription("Lights the smoke the creature carries inside its own sockets and leaves switched off. Tinted to match the eyes, so it turns with them at the last stage.", null, new ConfigurationManagerAttributes { Order = 50 })); EyeFlatColorShader = config.Bind(eyes, "Eye Flat Colour Shader", false, diff --git a/JotunnModStub/Aswid/AswidVisuals.cs b/JotunnModStub/Aswid/AswidVisuals.cs index b118424..8a6e047 100644 --- a/JotunnModStub/Aswid/AswidVisuals.cs +++ b/JotunnModStub/Aswid/AswidVisuals.cs @@ -58,6 +58,11 @@ namespace RacesOfValheim private const float BaseEyeHeight = 0.181f; private const float BaseEyeSeparation = 0.032f; + // The borrowed socket at the size the Skeleton wears it, times the config multiplier, was + // two green blocks on the face. This halves it before the multiplier, so a saved config + // keeps its meaning as "relative to the default" and the eyes read as two small points. + private const float BaseEyeScale = 0.5f; + // ─── Race check ───────────────────────────────────────────────────── /// @@ -99,6 +104,10 @@ namespace RacesOfValheim // built again rather than merely moved. public string SourceModel = ""; public bool FlatShader; + + // Which body the base pose was measured for: the female face puts the eyes elsewhere + // (PlayerFace), so a change of body model is a rebuild too. + public bool Female; } /// The pose an eye was authored at on the creature. Everything else is a delta on this. @@ -180,7 +189,8 @@ namespace RacesOfValheim EyeFrame existing = eyes.GetComponent(); if (existing == null || existing.SourceModel != AswidConfig.EyeSourceModel.Value || - existing.FlatShader != AswidConfig.EyeFlatColorShader.Value) + existing.FlatShader != AswidConfig.EyeFlatColorShader.Value || + existing.Female != PlayerFace.IsFemale(player)) { eyes.name = EyesName + "_Removed"; Object.Destroy(eyes.gameObject); @@ -424,6 +434,12 @@ namespace RacesOfValheim MeasureFrame(player, headBone, frame); frame.SourceModel = modelName; frame.FlatShader = AswidConfig.EyeFlatColorShader.Value; + frame.Female = PlayerFace.IsFemale(player); + + float baseHeight = BaseEyeHeight; + float baseSeparation = BaseEyeSeparation; + float baseSize = BaseEyeScale; + PlayerFace.AdjustEyes(player, ref baseHeight, ref baseSeparation, ref baseSize); // canonicalToFrame turns "face forward, as authored" into "face forward, on THIS // rig's own axes" - the rotation that carries the ordinary (X,Y,Z) convention onto @@ -458,8 +474,8 @@ namespace RacesOfValheim float toLocal = 1f / headBone.lossyScale.x; Vector3 basePosition = frame.LocalForward * (BaseEyeForward * toLocal) - + frame.LocalUp * (BaseEyeHeight * toLocal) - + frame.LocalRight * (side * BaseEyeSeparation * toLocal); + + frame.LocalUp * (baseHeight * toLocal) + + frame.LocalRight * (side * baseSeparation * toLocal); // The socket's own authored tilt is skipped for the same reason its position is - // canonicalToFrame alone (face forward, on this rig's axes) is what the config's @@ -481,7 +497,7 @@ namespace RacesOfValheim // this object at on a real skeleton. Divided into the new parent's scale, the pair // lands at exactly the size vanilla wears them, which is the whole point of // borrowing them instead of drawing spheres. - Vector3 baseScale = source.lossyScale * toLocal; + Vector3 baseScale = source.lossyScale * (toLocal * baseSize); // Remembered before anything moves it, because everything the config does is // expressed as a delta on this. diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index 745c748..3a41599 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -126,7 +126,9 @@ namespace RacesOfValheim public static readonly float EyeSeparation = 0.032f; // half the distance between them 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 + // Then cut down after playtest: at 0.062 the cap read as two lamps covering the face. An + // 18mm radius at the same depth leaves a cap of about 22mm on a 0.78 Dvergar. + public static readonly float EyeSize = 0.036f; // 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 diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index a6a694a..103f31d 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -277,10 +277,16 @@ namespace RacesOfValheim // 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 = localForward * (DvergarConfig.EyeForward * raceScale * toLocal) - + localUp * (DvergarConfig.EyeHeight * raceScale * toLocal); - float eyeLocalSize = DvergarConfig.EyeSize * raceScale * toLocal; + float height = DvergarConfig.EyeHeight; + float separation = DvergarConfig.EyeSeparation; + float eyeSize = DvergarConfig.EyeSize; + PlayerFace.AdjustEyes(player, ref height, ref separation, ref eyeSize); + + Vector3 baseLocal = localForward * (DvergarConfig.EyeForward * raceScale * toLocal) + + localUp * (height * raceScale * toLocal); + + float eyeLocalSize = eyeSize * raceScale * toLocal; for (int i = 0; i < holder.childCount; i++) { @@ -293,7 +299,7 @@ namespace RacesOfValheim float side = i == 0 ? -1f : 1f; float size = i == 0 ? eyeLocalSize * DvergarConfig.LeftEyeSizeMultiplier : eyeLocalSize; - eye.localPosition = baseLocal + localRight * (side * DvergarConfig.EyeSeparation * raceScale * toLocal); + eye.localPosition = baseLocal + localRight * (side * separation * raceScale * toLocal); eye.localScale = Vector3.one * size; } } diff --git a/JotunnModStub/PlayerFace.cs b/JotunnModStub/PlayerFace.cs new file mode 100644 index 0000000..15b3199 --- /dev/null +++ b/JotunnModStub/PlayerFace.cs @@ -0,0 +1,49 @@ +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// Where a player's painted eyes are, for the races that hang something over them (Alfar, + /// Aswid, Dvergar, Sverm). + /// + /// Every eye constant in this mod (0.081 forward, 0.181 up, 0.032 apart) was tuned on the MALE + /// body. The female body is a different mesh on the same rig and the same skin texture, and it + /// maps the painted eyes elsewhere: read offline from VisEquipment.m_models (bodymale vs + /// bodyfem, Valheim 1.0.20), by finding the dark socket pixels of PlayerCharacter_01 and + /// following the UVs back onto each mesh in head-bone space, the female eyes sit about 6mm + /// lower and a quarter closer together. Both are weighted 100% to Head, so once placed they + /// follow the head exactly; a sphere on the male spot simply sits on the brow, off the face. + /// + /// HEAD-LOCAL UNITS. The player armature is authored at 100x, so one metre at human scale is + /// 0.01 in the head bone's own space. That is a constant of the rig, not of this frame: + /// reading headBone.lossyScale live instead breaks under a non-uniform body scale (the Alfar), + /// where the value drifts as the head turns. + /// + public static class PlayerFace + { + public const float MetresToHeadLocal = 0.01f; + + // Female against male, measured as described above. + private const float FemaleHeightShift = -0.006f; + private const float FemaleSeparationScale = 0.75f; + private const float FemaleSizeScale = 0.9f; + + /// True while the body wears the female mesh (VisEquipment model index 1). + public static bool IsFemale(Player player) + { + VisEquipment vis = player != null ? player.GetComponent() : null; + if (vis == null || vis.m_bodyModel == null || vis.m_models == null || vis.m_models.Length < 2) return false; + return vis.m_bodyModel.sharedMesh == vis.m_models[1].m_mesh; + } + + /// Moves male-tuned eye numbers (metres) onto the female face; leaves a male face alone. + public static void AdjustEyes(Player player, ref float height, ref float separation, ref float size) + { + if (!IsFemale(player)) return; + + height += FemaleHeightShift; + separation *= FemaleSeparationScale; + size *= FemaleSizeScale; + } + } +} diff --git a/JotunnModStub/Sverm/SvermVisuals.cs b/JotunnModStub/Sverm/SvermVisuals.cs index f39e3ca..7dab089 100644 --- a/JotunnModStub/Sverm/SvermVisuals.cs +++ b/JotunnModStub/Sverm/SvermVisuals.cs @@ -251,10 +251,15 @@ namespace RacesOfValheim float scale = player.transform.localScale.x; - Vector3 baseLocal = frame.LocalForward * (EyeForward * scale * toLocal) - + frame.LocalUp * (EyeHeight * scale * toLocal); + float height = EyeHeight; + float separation = EyeSeparation; + float eyeSize = EyeSize; + PlayerFace.AdjustEyes(player, ref height, ref separation, ref eyeSize); - float eyeLocalSize = EyeSize * scale * toLocal; + Vector3 baseLocal = frame.LocalForward * (EyeForward * scale * toLocal) + + frame.LocalUp * (height * scale * toLocal); + + float eyeLocalSize = eyeSize * scale * toLocal; for (int i = 0; i < holder.childCount; i++) { @@ -264,7 +269,7 @@ namespace RacesOfValheim float side = i == 0 ? -1f : 1f; float size = i == 0 ? eyeLocalSize * LeftEyeSizeMultiplier : eyeLocalSize; - eye.localPosition = baseLocal + frame.LocalRight * (side * EyeSeparation * scale * toLocal); + eye.localPosition = baseLocal + frame.LocalRight * (side * separation * scale * toLocal); eye.localScale = Vector3.one * size; } } From a7e99964415fb1fe6444434526b19e77335e8a12 Mon Sep 17 00:00:00 2001 From: kanym Date: Tue, 27 Oct 2026 15:15:10 +0100 Subject: [PATCH 02/10] fix(eyes): lower female eyes further, push Alfar/Dvergar out, enlarge Aswid points Playtest on female characters: every race's eyes still sat about an eye-height above the painted ones. Female height shift goes from -6 to -14 mm. Alfar and Dvergar centres move 4 mm forward out of the face, and the Aswid socket goes from 0.5 to 0.75 of the borrowed size so it covers the painted eye. --- JotunnModStub/Alfar/AlfarConfig.cs | 2 +- JotunnModStub/Aswid/AswidVisuals.cs | 7 ++++--- JotunnModStub/Dvergar/DvergarConfig.cs | 2 +- JotunnModStub/PlayerFace.cs | 6 ++++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/JotunnModStub/Alfar/AlfarConfig.cs b/JotunnModStub/Alfar/AlfarConfig.cs index 7d72e25..558c0a7 100644 --- a/JotunnModStub/Alfar/AlfarConfig.cs +++ b/JotunnModStub/Alfar/AlfarConfig.cs @@ -49,7 +49,7 @@ namespace RacesOfValheim // Pushed apart and forward of the Sverm's, because an almond this wide would otherwise // meet its twin over the nose and sink into the cheek. public const float EyeSeparation = 0.037f; - public const float EyeForward = 0.086f; + public const float EyeForward = 0.090f; public const float EyeHeight = 0.183f; // Full width, height and depth of one eye in metres at Eye Size Multiplier 1. The saved diff --git a/JotunnModStub/Aswid/AswidVisuals.cs b/JotunnModStub/Aswid/AswidVisuals.cs index 8a6e047..0402d1e 100644 --- a/JotunnModStub/Aswid/AswidVisuals.cs +++ b/JotunnModStub/Aswid/AswidVisuals.cs @@ -59,9 +59,10 @@ namespace RacesOfValheim private const float BaseEyeSeparation = 0.032f; // The borrowed socket at the size the Skeleton wears it, times the config multiplier, was - // two green blocks on the face. This halves it before the multiplier, so a saved config - // keeps its meaning as "relative to the default" and the eyes read as two small points. - private const float BaseEyeScale = 0.5f; + // two green blocks on the face; at half it was smaller than the painted eye underneath, + // which then showed round it. Applied before the multiplier, so a saved config keeps its + // meaning as "relative to the default". + private const float BaseEyeScale = 0.75f; // ─── Race check ───────────────────────────────────────────────────── diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index 3a41599..03f0bad 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -124,7 +124,7 @@ namespace RacesOfValheim // 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.081f; // centre ~63mm out + public static readonly float EyeForward = 0.085f; // 0.081 left the smaller ball buried public static readonly float EyeHeight = 0.181f; // ~15mm lower than before // Then cut down after playtest: at 0.062 the cap read as two lamps covering the face. An // 18mm radius at the same depth leaves a cap of about 22mm on a 0.78 Dvergar. diff --git a/JotunnModStub/PlayerFace.cs b/JotunnModStub/PlayerFace.cs index 15b3199..4c6b39f 100644 --- a/JotunnModStub/PlayerFace.cs +++ b/JotunnModStub/PlayerFace.cs @@ -23,8 +23,10 @@ namespace RacesOfValheim { public const float MetresToHeadLocal = 0.01f; - // Female against male, measured as described above. - private const float FemaleHeightShift = -0.006f; + // Female against male. The UV reading gave -6mm, but in game the eyes still sat a full + // eye-height above the painted ones on every race (screenshots, 2026-10-27), so the + // height is the measured shift plus that. + private const float FemaleHeightShift = -0.014f; private const float FemaleSeparationScale = 0.75f; private const float FemaleSizeScale = 0.9f; From 8b2b5180ed9b612c5c7ff48b72c71fcd676f0606 Mon Sep 17 00:00:00 2001 From: kanym Date: Tue, 27 Oct 2026 15:21:19 +0100 Subject: [PATCH 03/10] feat(eyes): per-race eye position sliders in Configuration Manager One 'Eyes Position - ' section each for the Alfar, Aswid, Dvergar and Sverm, with a female and a male set: forward, height, separation and size, plus rotation X/Y/Z for the Alfar and Aswid. All are deltas on the computed placement (0 and size 1 change nothing), read live, and left local by ConfigSync because they only change how this client draws faces. --- JotunnModStub/Alfar/AlfarVisuals.cs | 20 ++++- JotunnModStub/Aswid/AswidVisuals.cs | 21 ++++-- JotunnModStub/ConfigSync.cs | 1 + JotunnModStub/Dvergar/DvergarVisuals.cs | 12 ++- JotunnModStub/EyePositionConfig.cs | 98 +++++++++++++++++++++++++ JotunnModStub/RacesOfValheim.cs | 2 + JotunnModStub/Sverm/SvermVisuals.cs | 12 ++- 7 files changed, 155 insertions(+), 11 deletions(-) create mode 100644 JotunnModStub/EyePositionConfig.cs diff --git a/JotunnModStub/Alfar/AlfarVisuals.cs b/JotunnModStub/Alfar/AlfarVisuals.cs index c2f2065..e281db9 100644 --- a/JotunnModStub/Alfar/AlfarVisuals.cs +++ b/JotunnModStub/Alfar/AlfarVisuals.cs @@ -186,7 +186,23 @@ namespace RacesOfValheim float size = AlfarConfig.EyeSizeMultiplier.Value; PlayerFace.AdjustEyes(player, ref height, ref separation, ref size); - Vector3 baseOffset = frame.LocalForward * AlfarConfig.EyeForward + frame.LocalUp * height; + float forward = AlfarConfig.EyeForward; + float wrap = AlfarConfig.EyeWrap; + float slant = AlfarConfig.EyeSlant; + float tilt = 0f; + EyePositionConfig.Tuning tuning = EyePositionConfig.For(AlfarConfig.RaceId, player); + if (tuning != null) + { + forward += tuning.Forward.Value; + height += tuning.Height.Value; + separation += tuning.Separation.Value; + size *= tuning.Size.Value; + tilt = tuning.RotX; + wrap += tuning.RotY; + slant += tuning.RotZ; + } + + Vector3 baseOffset = frame.LocalForward * forward + frame.LocalUp * height; Vector3 extent = AlfarConfig.EyeExtent * (size * toLocal); Quaternion facing = Quaternion.LookRotation(frame.LocalForward, frame.LocalUp); @@ -200,7 +216,7 @@ namespace RacesOfValheim Vector3 offset = baseOffset + frame.LocalRight * (side * separation); eye.localPosition = offset * toLocal; - eye.localRotation = facing * Quaternion.Euler(0f, AlfarConfig.EyeWrap * side, AlfarConfig.EyeSlant * side); + eye.localRotation = facing * Quaternion.Euler(tilt, wrap * side, slant * side); eye.localScale = extent; } } diff --git a/JotunnModStub/Aswid/AswidVisuals.cs b/JotunnModStub/Aswid/AswidVisuals.cs index 0402d1e..738170c 100644 --- a/JotunnModStub/Aswid/AswidVisuals.cs +++ b/JotunnModStub/Aswid/AswidVisuals.cs @@ -320,8 +320,15 @@ namespace RacesOfValheim float scale = GetPlayerScale(player) * toLocal; - Vector3 shift = frame.LocalForward * (AswidConfig.EyeForwardOffset.Value * scale) - + frame.LocalUp * (AswidConfig.EyeHeightOffset.Value * scale); + // The per-body sliders of "Eyes Position - Aswid", on top of the race's own offsets. + EyePositionConfig.Tuning tuning = EyePositionConfig.For("Aswid", player); + float forward = AswidConfig.EyeForwardOffset.Value + (tuning != null ? tuning.Forward.Value : 0f); + float height = AswidConfig.EyeHeightOffset.Value + (tuning != null ? tuning.Height.Value : 0f); + float separation = AswidConfig.EyeSeparationOffset.Value + (tuning != null ? tuning.Separation.Value : 0f); + float size = AswidConfig.EyeSizeMultiplier.Value * (tuning != null ? tuning.Size.Value : 1f); + + Vector3 shift = frame.LocalForward * (forward * scale) + + frame.LocalUp * (height * scale); for (int i = 0; i < holder.childCount; i++) { @@ -344,14 +351,14 @@ namespace RacesOfValheim // Pitch and roll are shared deliberately: both eyes looking up is a face looking // up, and mirroring either of those would cross them instead of aiming them. Quaternion twist = Quaternion.Euler( - AswidConfig.EyeRotationX.Value, - AswidConfig.EyeRotationY.Value * side, - AswidConfig.EyeRotationZ.Value); + AswidConfig.EyeRotationX.Value + (tuning != null ? tuning.RotX : 0f), + (AswidConfig.EyeRotationY.Value + (tuning != null ? tuning.RotY : 0f)) * side, + AswidConfig.EyeRotationZ.Value + (tuning != null ? tuning.RotZ * side : 0f)); eye.localPosition = authored.Position + shift + - frame.LocalRight * (side * AswidConfig.EyeSeparationOffset.Value * scale); + frame.LocalRight * (side * separation * scale); eye.localRotation = twist * authored.Rotation; - eye.localScale = authored.Scale * AswidConfig.EyeSizeMultiplier.Value; + eye.localScale = authored.Scale * size; } } diff --git a/JotunnModStub/ConfigSync.cs b/JotunnModStub/ConfigSync.cs index abbad38..0f9ac48 100644 --- a/JotunnModStub/ConfigSync.cs +++ b/JotunnModStub/ConfigSync.cs @@ -87,6 +87,7 @@ namespace RacesOfValheim if (section.EndsWith("Keybinds", StringComparison.OrdinalIgnoreCase)) return false; if (LocalSections.Contains(section, StringComparer.OrdinalIgnoreCase)) return false; + if (section.StartsWith(EyePositionConfig.SectionPrefix, StringComparison.OrdinalIgnoreCase)) return false; if (LocalKeyParts.Any(key.Contains)) return false; // Model pose nudges (rotation/offset/yaw) are cosmetic, but "Attack Reach Offset" is a diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index 103f31d..9ca8815 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -283,7 +283,17 @@ namespace RacesOfValheim float eyeSize = DvergarConfig.EyeSize; PlayerFace.AdjustEyes(player, ref height, ref separation, ref eyeSize); - Vector3 baseLocal = localForward * (DvergarConfig.EyeForward * raceScale * toLocal) + float forward = DvergarConfig.EyeForward; + EyePositionConfig.Tuning tuning = EyePositionConfig.For(DvergarConfig.RaceId, player); + if (tuning != null) + { + forward += tuning.Forward.Value; + height += tuning.Height.Value; + separation += tuning.Separation.Value; + eyeSize *= tuning.Size.Value; + } + + Vector3 baseLocal = localForward * (forward * raceScale * toLocal) + localUp * (height * raceScale * toLocal); float eyeLocalSize = eyeSize * raceScale * toLocal; diff --git a/JotunnModStub/EyePositionConfig.cs b/JotunnModStub/EyePositionConfig.cs new file mode 100644 index 0000000..bd4a942 --- /dev/null +++ b/JotunnModStub/EyePositionConfig.cs @@ -0,0 +1,98 @@ +using System.Collections.Generic; +using BepInEx.Configuration; + +namespace RacesOfValheim +{ + /// + /// Hand placement for every race that hangs eyes on the face: one "Eyes Position - race" + /// section each, with a female and a male set, because the two bodies put their painted eyes + /// in different places (PlayerFace). Every value is a delta on the placement the race's own + /// code computes, so all zeros (and size 1) is the shipped look. + /// + /// Local, never synced (ConfigSync): it only changes how this client draws faces. + /// + public static class EyePositionConfig + { + public const string SectionPrefix = "Eyes Position - "; + + /// One body's sliders for one race. + public sealed class Tuning + { + public ConfigEntry Forward; + public ConfigEntry Height; + public ConfigEntry Separation; + public ConfigEntry Size; + + // Only bound for races whose eyes are not spheres; null elsewhere. + public ConfigEntry RotationX; + public ConfigEntry RotationY; + public ConfigEntry RotationZ; + + public float RotX => RotationX != null ? RotationX.Value : 0f; + public float RotY => RotationY != null ? RotationY.Value : 0f; + public float RotZ => RotationZ != null ? RotationZ.Value : 0f; + } + + // [race] -> { male, female } + private static readonly Dictionary tunings = new Dictionary(); + + public static void Bind(ConfigFile config) + { + BindRace(config, AlfarConfig.RaceId, true); + BindRace(config, "Aswid", true); + BindRace(config, DvergarConfig.RaceId, false); + BindRace(config, SvermConfig.RaceId, false); + } + + /// The sliders for the body this player is wearing right now. + public static Tuning For(string race, Player player) + { + if (!tunings.TryGetValue(race, out Tuning[] pair)) return null; + return pair[PlayerFace.IsFemale(player) ? 1 : 0]; + } + + private static void BindRace(ConfigFile config, string race, bool rotation) + { + string section = SectionPrefix + race; + tunings[race] = new[] + { + BindBody(config, section, "Male", rotation, 100), + BindBody(config, section, "Female", rotation, 200), + }; + } + + private static Tuning BindBody(ConfigFile config, string section, string body, bool rotation, int order) + { + // Female first in the list: Order sorts high to low. + Tuning t = new Tuning(); + + t.Forward = config.Bind(section, body + " Forward", 0f, + new ConfigDescription($"{body} characters: moves both eyes out of (+) or into (-) the face, in metres.", + new AcceptableValueRange(-0.05f, 0.05f), new ConfigurationManagerAttributes { Order = order + 9 })); + t.Height = config.Bind(section, body + " Height", 0f, + new ConfigDescription($"{body} characters: moves both eyes up (+) or down (-), in metres.", + new AcceptableValueRange(-0.05f, 0.05f), new ConfigurationManagerAttributes { Order = order + 8 })); + t.Separation = config.Bind(section, body + " Separation", 0f, + new ConfigDescription($"{body} characters: pushes the eyes apart (+) or together (-), in metres. Each eye moves by this much.", + new AcceptableValueRange(-0.03f, 0.03f), new ConfigurationManagerAttributes { Order = order + 7 })); + t.Size = config.Bind(section, body + " Size", 1f, + new ConfigDescription($"{body} characters: scales both eyes. 1 is the default size.", + new AcceptableValueRange(0.2f, 3f), new ConfigurationManagerAttributes { Order = order + 6 })); + + if (rotation) + { + t.RotationX = config.Bind(section, body + " Rotation X", 0f, + new ConfigDescription($"{body} characters: tilts both eyes up or down, in degrees.", + new AcceptableValueRange(-90f, 90f), new ConfigurationManagerAttributes { Order = order + 5 })); + t.RotationY = config.Bind(section, body + " Rotation Y", 0f, + new ConfigDescription($"{body} characters: turns the eyes toward the temples (+) or the nose (-), in degrees. Mirrored between the two eyes.", + new AcceptableValueRange(-90f, 90f), new ConfigurationManagerAttributes { Order = order + 4 })); + t.RotationZ = config.Bind(section, body + " Rotation Z", 0f, + new ConfigDescription($"{body} characters: raises (+) or lowers (-) the outer corners, in degrees. Mirrored between the two eyes.", + new AcceptableValueRange(-90f, 90f), new ConfigurationManagerAttributes { Order = order + 3 })); + } + + return t; + } + } +} diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index f075a97..5eb3b9b 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -56,6 +56,8 @@ namespace RacesOfValheim // Not a race either: the faction truce and the faction merchants, which cut across // every race at once, so they bind last rather than inside the alphabetical run above. FactionsConfig.Bind(Config); + // Not a race either: the hand placement of every race's eyes, one section per race. + EyePositionConfig.Bind(Config); // After every Bind above: tags the gameplay entries for Jotunn's server-to-client sync. ConfigSync.Apply(Config); harmony.PatchAll(); diff --git a/JotunnModStub/Sverm/SvermVisuals.cs b/JotunnModStub/Sverm/SvermVisuals.cs index 7dab089..9cb6c82 100644 --- a/JotunnModStub/Sverm/SvermVisuals.cs +++ b/JotunnModStub/Sverm/SvermVisuals.cs @@ -256,7 +256,17 @@ namespace RacesOfValheim float eyeSize = EyeSize; PlayerFace.AdjustEyes(player, ref height, ref separation, ref eyeSize); - Vector3 baseLocal = frame.LocalForward * (EyeForward * scale * toLocal) + float forward = EyeForward; + EyePositionConfig.Tuning tuning = EyePositionConfig.For(SvermConfig.RaceId, player); + if (tuning != null) + { + forward += tuning.Forward.Value; + height += tuning.Height.Value; + separation += tuning.Separation.Value; + eyeSize *= tuning.Size.Value; + } + + Vector3 baseLocal = frame.LocalForward * (forward * scale * toLocal) + frame.LocalUp * (height * scale * toLocal); float eyeLocalSize = eyeSize * scale * toLocal; From 20c12724fde99007cae8f7462f549d36d7c3eca2 Mon Sep 17 00:00:00 2001 From: kanym Date: Tue, 27 Oct 2026 15:38:52 +0100 Subject: [PATCH 04/10] feat(eyes): female eye defaults from playtest The female slider values dialled in on screen for the Dvergar, Alfar and Aswid become the defaults of their Eyes Position sections, so a fresh install lands on the tuned faces. The Sverm keeps zeros: its helmet hides the eyes. --- JotunnModStub/EyePositionConfig.cs | 46 +++++++++++++++++++----------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/JotunnModStub/EyePositionConfig.cs b/JotunnModStub/EyePositionConfig.cs index bd4a942..be3b94e 100644 --- a/JotunnModStub/EyePositionConfig.cs +++ b/JotunnModStub/EyePositionConfig.cs @@ -7,7 +7,8 @@ namespace RacesOfValheim /// Hand placement for every race that hangs eyes on the face: one "Eyes Position - race" /// section each, with a female and a male set, because the two bodies put their painted eyes /// in different places (PlayerFace). Every value is a delta on the placement the race's own - /// code computes, so all zeros (and size 1) is the shipped look. + /// code computes: all zeros (and size 1) is the code's own placement, and the female + /// defaults below are the corrections found in game on top of it. /// /// Local, never synced (ConfigSync): it only changes how this client draws faces. /// @@ -38,10 +39,23 @@ namespace RacesOfValheim public static void Bind(ConfigFile config) { - BindRace(config, AlfarConfig.RaceId, true); - BindRace(config, "Aswid", true); - BindRace(config, DvergarConfig.RaceId, false); - BindRace(config, SvermConfig.RaceId, false); + // Female defaults dialled in on screen (playtest, 2026-10-27). The male ones are + // still the code's own placement; the Sverm's helmet hides its eyes, so it keeps it. + BindRace(config, AlfarConfig.RaceId, true, + new Defaults { Separation = 0.006f, RotX = -17.524f }); + BindRace(config, "Aswid", true, + new Defaults { Forward = -0.001f, Height = 0.001f, Separation = 0.006f, Size = 1.061f, + RotX = -4.543f, RotY = -1.514f, RotZ = -4.543f }); + BindRace(config, DvergarConfig.RaceId, false, + new Defaults { Forward = -0.011f, Separation = 0.005f, Size = 1.616f }); + BindRace(config, SvermConfig.RaceId, false, new Defaults()); + } + + /// Starting values for one body's sliders. + private sealed class Defaults + { + public float Forward, Height, Separation, RotX, RotY, RotZ; + public float Size = 1f; } /// The sliders for the body this player is wearing right now. @@ -51,43 +65,43 @@ namespace RacesOfValheim return pair[PlayerFace.IsFemale(player) ? 1 : 0]; } - private static void BindRace(ConfigFile config, string race, bool rotation) + private static void BindRace(ConfigFile config, string race, bool rotation, Defaults female) { string section = SectionPrefix + race; tunings[race] = new[] { - BindBody(config, section, "Male", rotation, 100), - BindBody(config, section, "Female", rotation, 200), + BindBody(config, section, "Male", rotation, 100, new Defaults()), + BindBody(config, section, "Female", rotation, 200, female), }; } - private static Tuning BindBody(ConfigFile config, string section, string body, bool rotation, int order) + private static Tuning BindBody(ConfigFile config, string section, string body, bool rotation, int order, Defaults d) { // Female first in the list: Order sorts high to low. Tuning t = new Tuning(); - t.Forward = config.Bind(section, body + " Forward", 0f, + t.Forward = config.Bind(section, body + " Forward", d.Forward, new ConfigDescription($"{body} characters: moves both eyes out of (+) or into (-) the face, in metres.", new AcceptableValueRange(-0.05f, 0.05f), new ConfigurationManagerAttributes { Order = order + 9 })); - t.Height = config.Bind(section, body + " Height", 0f, + t.Height = config.Bind(section, body + " Height", d.Height, new ConfigDescription($"{body} characters: moves both eyes up (+) or down (-), in metres.", new AcceptableValueRange(-0.05f, 0.05f), new ConfigurationManagerAttributes { Order = order + 8 })); - t.Separation = config.Bind(section, body + " Separation", 0f, + t.Separation = config.Bind(section, body + " Separation", d.Separation, new ConfigDescription($"{body} characters: pushes the eyes apart (+) or together (-), in metres. Each eye moves by this much.", new AcceptableValueRange(-0.03f, 0.03f), new ConfigurationManagerAttributes { Order = order + 7 })); - t.Size = config.Bind(section, body + " Size", 1f, + t.Size = config.Bind(section, body + " Size", d.Size, new ConfigDescription($"{body} characters: scales both eyes. 1 is the default size.", new AcceptableValueRange(0.2f, 3f), new ConfigurationManagerAttributes { Order = order + 6 })); if (rotation) { - t.RotationX = config.Bind(section, body + " Rotation X", 0f, + t.RotationX = config.Bind(section, body + " Rotation X", d.RotX, new ConfigDescription($"{body} characters: tilts both eyes up or down, in degrees.", new AcceptableValueRange(-90f, 90f), new ConfigurationManagerAttributes { Order = order + 5 })); - t.RotationY = config.Bind(section, body + " Rotation Y", 0f, + t.RotationY = config.Bind(section, body + " Rotation Y", d.RotY, new ConfigDescription($"{body} characters: turns the eyes toward the temples (+) or the nose (-), in degrees. Mirrored between the two eyes.", new AcceptableValueRange(-90f, 90f), new ConfigurationManagerAttributes { Order = order + 4 })); - t.RotationZ = config.Bind(section, body + " Rotation Z", 0f, + t.RotationZ = config.Bind(section, body + " Rotation Z", d.RotZ, new ConfigDescription($"{body} characters: raises (+) or lowers (-) the outer corners, in degrees. Mirrored between the two eyes.", new AcceptableValueRange(-90f, 90f), new ConfigurationManagerAttributes { Order = order + 3 })); } From ffba40650ed5df1716c3d33e071bde7b5e2d1478 Mon Sep 17 00:00:00 2001 From: kanym Date: Tue, 27 Oct 2026 15:40:52 +0100 Subject: [PATCH 05/10] fix(aswid): eye position sliders rotate on the face's axes The Eyes Position rotation was added to the Aswid's own twist, which works on the head bone's raw axes: bone X points out of the face and bone Z sideways, so Rotation X rolled the eyes and the mirrored Rotation Z tipped one eye up and the other down. The slider rotation is now conjugated by the face frame, so X tips, Y turns toward the temple and Z raises the outer corner on both eyes alike. The female rotation defaults go back to 0, since the old numbers meant other axes. --- JotunnModStub/Aswid/AswidVisuals.cs | 24 ++++++++++++++++++++---- JotunnModStub/EyePositionConfig.cs | 5 ++--- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/JotunnModStub/Aswid/AswidVisuals.cs b/JotunnModStub/Aswid/AswidVisuals.cs index 738170c..3fd25ba 100644 --- a/JotunnModStub/Aswid/AswidVisuals.cs +++ b/JotunnModStub/Aswid/AswidVisuals.cs @@ -350,14 +350,30 @@ namespace RacesOfValheim // // Pitch and roll are shared deliberately: both eyes looking up is a face looking // up, and mirroring either of those would cross them instead of aiming them. + // + // This twist is on the HEAD BONE's raw axes (it multiplies from the left), and on + // this rig those are not the face's: bone X points out of the face and bone Z + // sideways. The defaults were dialled in against that, so it stays as it is. Quaternion twist = Quaternion.Euler( - AswidConfig.EyeRotationX.Value + (tuning != null ? tuning.RotX : 0f), - (AswidConfig.EyeRotationY.Value + (tuning != null ? tuning.RotY : 0f)) * side, - AswidConfig.EyeRotationZ.Value + (tuning != null ? tuning.RotZ * side : 0f)); + AswidConfig.EyeRotationX.Value, + AswidConfig.EyeRotationY.Value * side, + AswidConfig.EyeRotationZ.Value); + + // The Eyes Position sliders turn the eye on the FACE's axes instead: conjugated by + // the face frame, X tips it, Y turns it toward the temple and Z raises the outer + // corner, the same on both eyes. Added to the bone-axis twist above, X rolled the + // eyes and a mirrored Z tipped one up and the other down. + Quaternion nudge = Quaternion.identity; + if (tuning != null) + { + nudge = authored.Rotation + * Quaternion.Euler(tuning.RotX, tuning.RotY * side, tuning.RotZ * side) + * Quaternion.Inverse(authored.Rotation); + } eye.localPosition = authored.Position + shift + frame.LocalRight * (side * separation * scale); - eye.localRotation = twist * authored.Rotation; + eye.localRotation = nudge * twist * authored.Rotation; eye.localScale = authored.Scale * size; } } diff --git a/JotunnModStub/EyePositionConfig.cs b/JotunnModStub/EyePositionConfig.cs index be3b94e..88f03d6 100644 --- a/JotunnModStub/EyePositionConfig.cs +++ b/JotunnModStub/EyePositionConfig.cs @@ -44,8 +44,7 @@ namespace RacesOfValheim BindRace(config, AlfarConfig.RaceId, true, new Defaults { Separation = 0.006f, RotX = -17.524f }); BindRace(config, "Aswid", true, - new Defaults { Forward = -0.001f, Height = 0.001f, Separation = 0.006f, Size = 1.061f, - RotX = -4.543f, RotY = -1.514f, RotZ = -4.543f }); + new Defaults { Forward = -0.001f, Height = 0.001f, Separation = 0.006f, Size = 1.061f }); BindRace(config, DvergarConfig.RaceId, false, new Defaults { Forward = -0.011f, Separation = 0.005f, Size = 1.616f }); BindRace(config, SvermConfig.RaceId, false, new Defaults()); @@ -96,7 +95,7 @@ namespace RacesOfValheim if (rotation) { t.RotationX = config.Bind(section, body + " Rotation X", d.RotX, - new ConfigDescription($"{body} characters: tilts both eyes up or down, in degrees.", + new ConfigDescription($"{body} characters: tips both eyes down (+) or up (-), in degrees.", new AcceptableValueRange(-90f, 90f), new ConfigurationManagerAttributes { Order = order + 5 })); t.RotationY = config.Bind(section, body + " Rotation Y", d.RotY, new ConfigDescription($"{body} characters: turns the eyes toward the temples (+) or the nose (-), in degrees. Mirrored between the two eyes.", From 132d7e034f47a1a61ef57a2b32f4e1c5faf2338d Mon Sep 17 00:00:00 2001 From: kanym Date: Tue, 27 Oct 2026 16:03:24 +0100 Subject: [PATCH 06/10] feat(eyes): per-eye sliders, Aswid female defaults from playtest Each Eyes Position section now has a set per body and per eye (the character's own left and right), because the face is not symmetric enough for one set to fit both eyes. The Aswid female defaults are the per-eye values dialled in on screen; Alfar and Dvergar copy their female values to both eyes. The old shared keys are dropped: they only ever existed in test builds. --- JotunnModStub/Alfar/AlfarVisuals.cs | 44 ++++++------ JotunnModStub/Aswid/AswidVisuals.cs | 20 +++--- JotunnModStub/Dvergar/DvergarVisuals.cs | 35 +++++----- JotunnModStub/EyePositionConfig.cs | 90 +++++++++++++++---------- JotunnModStub/Sverm/SvermVisuals.cs | 35 +++++----- 5 files changed, 124 insertions(+), 100 deletions(-) diff --git a/JotunnModStub/Alfar/AlfarVisuals.cs b/JotunnModStub/Alfar/AlfarVisuals.cs index e281db9..70b3f68 100644 --- a/JotunnModStub/Alfar/AlfarVisuals.cs +++ b/JotunnModStub/Alfar/AlfarVisuals.cs @@ -186,24 +186,6 @@ namespace RacesOfValheim float size = AlfarConfig.EyeSizeMultiplier.Value; PlayerFace.AdjustEyes(player, ref height, ref separation, ref size); - float forward = AlfarConfig.EyeForward; - float wrap = AlfarConfig.EyeWrap; - float slant = AlfarConfig.EyeSlant; - float tilt = 0f; - EyePositionConfig.Tuning tuning = EyePositionConfig.For(AlfarConfig.RaceId, player); - if (tuning != null) - { - forward += tuning.Forward.Value; - height += tuning.Height.Value; - separation += tuning.Separation.Value; - size *= tuning.Size.Value; - tilt = tuning.RotX; - wrap += tuning.RotY; - slant += tuning.RotZ; - } - - Vector3 baseOffset = frame.LocalForward * forward + frame.LocalUp * height; - Vector3 extent = AlfarConfig.EyeExtent * (size * toLocal); Quaternion facing = Quaternion.LookRotation(frame.LocalForward, frame.LocalUp); for (int i = 0; i < holder.childCount; i++) @@ -213,11 +195,33 @@ namespace RacesOfValheim // Index 0 is offset against the right axis, so it is the model's left eye. The // slant and the wrap are mirrored so both outer corners go up and back. float side = i == 0 ? -1f : 1f; - Vector3 offset = baseOffset + frame.LocalRight * (side * separation); + + // This eye's sliders from "Eyes Position - Alfar". + float forward = AlfarConfig.EyeForward; + float eyeHeight = height; + float eyeSeparation = separation; + float eyeSize = size; + float wrap = AlfarConfig.EyeWrap; + float slant = AlfarConfig.EyeSlant; + float tilt = 0f; + EyePositionConfig.Tuning tuning = EyePositionConfig.For(AlfarConfig.RaceId, player, side); + if (tuning != null) + { + forward += tuning.Forward.Value; + eyeHeight += tuning.Height.Value; + eyeSeparation += tuning.Separation.Value; + eyeSize *= tuning.Size.Value; + tilt = tuning.RotX; + wrap += tuning.RotY; + slant += tuning.RotZ; + } + + Vector3 offset = frame.LocalForward * forward + frame.LocalUp * eyeHeight + + frame.LocalRight * (side * eyeSeparation); eye.localPosition = offset * toLocal; eye.localRotation = facing * Quaternion.Euler(tilt, wrap * side, slant * side); - eye.localScale = extent; + eye.localScale = AlfarConfig.EyeExtent * (eyeSize * toLocal); } } diff --git a/JotunnModStub/Aswid/AswidVisuals.cs b/JotunnModStub/Aswid/AswidVisuals.cs index 3fd25ba..8d0aeef 100644 --- a/JotunnModStub/Aswid/AswidVisuals.cs +++ b/JotunnModStub/Aswid/AswidVisuals.cs @@ -320,16 +320,6 @@ namespace RacesOfValheim float scale = GetPlayerScale(player) * toLocal; - // The per-body sliders of "Eyes Position - Aswid", on top of the race's own offsets. - EyePositionConfig.Tuning tuning = EyePositionConfig.For("Aswid", player); - float forward = AswidConfig.EyeForwardOffset.Value + (tuning != null ? tuning.Forward.Value : 0f); - float height = AswidConfig.EyeHeightOffset.Value + (tuning != null ? tuning.Height.Value : 0f); - float separation = AswidConfig.EyeSeparationOffset.Value + (tuning != null ? tuning.Separation.Value : 0f); - float size = AswidConfig.EyeSizeMultiplier.Value * (tuning != null ? tuning.Size.Value : 1f); - - Vector3 shift = frame.LocalForward * (forward * scale) - + frame.LocalUp * (height * scale); - for (int i = 0; i < holder.childCount; i++) { Transform eye = holder.GetChild(i); @@ -342,6 +332,16 @@ namespace RacesOfValheim float side = Mathf.Sign(Vector3.Dot(authored.Position, frame.LocalRight)); if (side == 0f) side = i == 0 ? -1f : 1f; + // This eye's sliders from "Eyes Position - Aswid", on top of the race's own offsets. + EyePositionConfig.Tuning tuning = EyePositionConfig.For("Aswid", player, side); + float forward = AswidConfig.EyeForwardOffset.Value + (tuning != null ? tuning.Forward.Value : 0f); + float height = AswidConfig.EyeHeightOffset.Value + (tuning != null ? tuning.Height.Value : 0f); + float separation = AswidConfig.EyeSeparationOffset.Value + (tuning != null ? tuning.Separation.Value : 0f); + float size = AswidConfig.EyeSizeMultiplier.Value * (tuning != null ? tuning.Size.Value : 1f); + + Vector3 shift = frame.LocalForward * (forward * scale) + + frame.LocalUp * (height * scale); + // YAW IS MIRRORED, the other two are not. Turning both eyes the same way on Y // makes the pair look sideways - both point off the same shoulder, because a face // is symmetric about its centre line and yaw is the axis that crosses it. Negating diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index 9ca8815..b156fe2 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -283,21 +283,6 @@ namespace RacesOfValheim float eyeSize = DvergarConfig.EyeSize; PlayerFace.AdjustEyes(player, ref height, ref separation, ref eyeSize); - float forward = DvergarConfig.EyeForward; - EyePositionConfig.Tuning tuning = EyePositionConfig.For(DvergarConfig.RaceId, player); - if (tuning != null) - { - forward += tuning.Forward.Value; - height += tuning.Height.Value; - separation += tuning.Separation.Value; - eyeSize *= tuning.Size.Value; - } - - Vector3 baseLocal = localForward * (forward * raceScale * toLocal) - + localUp * (height * raceScale * toLocal); - - float eyeLocalSize = eyeSize * raceScale * toLocal; - for (int i = 0; i < holder.childCount; i++) { Transform eye = holder.GetChild(i); @@ -307,9 +292,25 @@ namespace RacesOfValheim // 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 * separation * raceScale * toLocal); + // This eye's sliders from "Eyes Position - Dvergar". + float forward = DvergarConfig.EyeForward; + float eyeHeight = height; + float eyeSeparation = separation; + float size = eyeSize * raceScale * toLocal; + EyePositionConfig.Tuning tuning = EyePositionConfig.For(DvergarConfig.RaceId, player, side); + if (tuning != null) + { + forward += tuning.Forward.Value; + eyeHeight += tuning.Height.Value; + eyeSeparation += tuning.Separation.Value; + size *= tuning.Size.Value; + } + if (i == 0) size *= DvergarConfig.LeftEyeSizeMultiplier; + + eye.localPosition = localForward * (forward * raceScale * toLocal) + + localUp * (eyeHeight * raceScale * toLocal) + + localRight * (side * eyeSeparation * raceScale * toLocal); eye.localScale = Vector3.one * size; } } diff --git a/JotunnModStub/EyePositionConfig.cs b/JotunnModStub/EyePositionConfig.cs index 88f03d6..26c9e2f 100644 --- a/JotunnModStub/EyePositionConfig.cs +++ b/JotunnModStub/EyePositionConfig.cs @@ -5,10 +5,13 @@ namespace RacesOfValheim { /// /// Hand placement for every race that hangs eyes on the face: one "Eyes Position - race" - /// section each, with a female and a male set, because the two bodies put their painted eyes - /// in different places (PlayerFace). Every value is a delta on the placement the race's own - /// code computes: all zeros (and size 1) is the code's own placement, and the female - /// defaults below are the corrections found in game on top of it. + /// section each, with a set of sliders per body and per eye. Per body because the two bodies + /// put their painted eyes in different places (PlayerFace); per eye because the face is not + /// symmetric enough for one set to fit both. Left and right are the character's own. + /// + /// Every value is a delta on the placement the race's own code computes: all zeros (and size + /// 1) is the code's own placement, and the female defaults below are the corrections found in + /// game on top of it. /// /// Local, never synced (ConfigSync): it only changes how this client draws faces. /// @@ -16,7 +19,7 @@ namespace RacesOfValheim { public const string SectionPrefix = "Eyes Position - "; - /// One body's sliders for one race. + /// One eye's sliders, for one body of one race. public sealed class Tuning { public ConfigEntry Forward; @@ -34,74 +37,89 @@ namespace RacesOfValheim public float RotZ => RotationZ != null ? RotationZ.Value : 0f; } - // [race] -> { male, female } + // [race] -> { male left, male right, female left, female right } private static readonly Dictionary tunings = new Dictionary(); public static void Bind(ConfigFile config) { // Female defaults dialled in on screen (playtest, 2026-10-27). The male ones are // still the code's own placement; the Sverm's helmet hides its eyes, so it keeps it. - BindRace(config, AlfarConfig.RaceId, true, - new Defaults { Separation = 0.006f, RotX = -17.524f }); + Defaults alfar = new Defaults { Separation = 0.006f, RotX = -17.524f }; + BindRace(config, AlfarConfig.RaceId, true, alfar, alfar); + BindRace(config, "Aswid", true, - new Defaults { Forward = -0.001f, Height = 0.001f, Separation = 0.006f, Size = 1.061f }); - BindRace(config, DvergarConfig.RaceId, false, - new Defaults { Forward = -0.011f, Separation = 0.005f, Size = 1.616f }); - BindRace(config, SvermConfig.RaceId, false, new Defaults()); + new Defaults { Forward = -0.002f, Height = -0.001f, Separation = 0.003f, Size = 1.142f, + RotX = 1.298f, RotY = 0.649f }, + new Defaults { Forward = -0.001f, Height = -0.001f, Separation = 0.009f, Size = 1.142f, + RotX = 1.298f, RotY = 0.649f, RotZ = -7.788f }); + + Defaults dvergar = new Defaults { Forward = -0.011f, Separation = 0.005f, Size = 1.616f }; + BindRace(config, DvergarConfig.RaceId, false, dvergar, dvergar); + + BindRace(config, SvermConfig.RaceId, false, new Defaults(), new Defaults()); } - /// Starting values for one body's sliders. + /// Starting values for one eye's sliders. private sealed class Defaults { public float Forward, Height, Separation, RotX, RotY, RotZ; public float Size = 1f; } - /// The sliders for the body this player is wearing right now. - public static Tuning For(string race, Player player) + /// + /// The sliders for one eye of the body this player is wearing right now. Side is the + /// races' own convention: negative is offset against the head frame's right axis, which is + /// the character's left eye. + /// + public static Tuning For(string race, Player player, float side) { - if (!tunings.TryGetValue(race, out Tuning[] pair)) return null; - return pair[PlayerFace.IsFemale(player) ? 1 : 0]; + if (!tunings.TryGetValue(race, out Tuning[] set)) return null; + return set[(PlayerFace.IsFemale(player) ? 2 : 0) + (side < 0f ? 0 : 1)]; } - private static void BindRace(ConfigFile config, string race, bool rotation, Defaults female) + private static void BindRace(ConfigFile config, string race, bool rotation, Defaults femaleLeft, Defaults femaleRight) { string section = SectionPrefix + race; + + // Female first in the list, left before right: Order sorts high to low. tunings[race] = new[] { - BindBody(config, section, "Male", rotation, 100, new Defaults()), - BindBody(config, section, "Female", rotation, 200, female), + BindEye(config, section, "Male", "Left", rotation, 200, new Defaults()), + BindEye(config, section, "Male", "Right", rotation, 100, new Defaults()), + BindEye(config, section, "Female", "Left", rotation, 400, femaleLeft), + BindEye(config, section, "Female", "Right", rotation, 300, femaleRight), }; } - private static Tuning BindBody(ConfigFile config, string section, string body, bool rotation, int order, Defaults d) + private static Tuning BindEye(ConfigFile config, string section, string body, string eye, bool rotation, int order, Defaults d) { - // Female first in the list: Order sorts high to low. + string prefix = $"{body} {eye} Eye "; + string who = $"{body} characters, {eye.ToLowerInvariant()} eye (the character's own {eye.ToLowerInvariant()})"; Tuning t = new Tuning(); - t.Forward = config.Bind(section, body + " Forward", d.Forward, - new ConfigDescription($"{body} characters: moves both eyes out of (+) or into (-) the face, in metres.", + t.Forward = config.Bind(section, prefix + "Forward", d.Forward, + new ConfigDescription($"{who}: moves the eye out of (+) or into (-) the face, in metres.", new AcceptableValueRange(-0.05f, 0.05f), new ConfigurationManagerAttributes { Order = order + 9 })); - t.Height = config.Bind(section, body + " Height", d.Height, - new ConfigDescription($"{body} characters: moves both eyes up (+) or down (-), in metres.", + t.Height = config.Bind(section, prefix + "Height", d.Height, + new ConfigDescription($"{who}: moves the eye up (+) or down (-), in metres.", new AcceptableValueRange(-0.05f, 0.05f), new ConfigurationManagerAttributes { Order = order + 8 })); - t.Separation = config.Bind(section, body + " Separation", d.Separation, - new ConfigDescription($"{body} characters: pushes the eyes apart (+) or together (-), in metres. Each eye moves by this much.", + t.Separation = config.Bind(section, prefix + "Separation", d.Separation, + new ConfigDescription($"{who}: moves the eye away from (+) or toward (-) the nose, in metres.", new AcceptableValueRange(-0.03f, 0.03f), new ConfigurationManagerAttributes { Order = order + 7 })); - t.Size = config.Bind(section, body + " Size", d.Size, - new ConfigDescription($"{body} characters: scales both eyes. 1 is the default size.", + t.Size = config.Bind(section, prefix + "Size", d.Size, + new ConfigDescription($"{who}: scales the eye. 1 is the default size.", new AcceptableValueRange(0.2f, 3f), new ConfigurationManagerAttributes { Order = order + 6 })); if (rotation) { - t.RotationX = config.Bind(section, body + " Rotation X", d.RotX, - new ConfigDescription($"{body} characters: tips both eyes down (+) or up (-), in degrees.", + t.RotationX = config.Bind(section, prefix + "Rotation X", d.RotX, + new ConfigDescription($"{who}: tips the eye down (+) or up (-), in degrees.", new AcceptableValueRange(-90f, 90f), new ConfigurationManagerAttributes { Order = order + 5 })); - t.RotationY = config.Bind(section, body + " Rotation Y", d.RotY, - new ConfigDescription($"{body} characters: turns the eyes toward the temples (+) or the nose (-), in degrees. Mirrored between the two eyes.", + t.RotationY = config.Bind(section, prefix + "Rotation Y", d.RotY, + new ConfigDescription($"{who}: turns the eye toward the temple (+) or the nose (-), in degrees.", new AcceptableValueRange(-90f, 90f), new ConfigurationManagerAttributes { Order = order + 4 })); - t.RotationZ = config.Bind(section, body + " Rotation Z", d.RotZ, - new ConfigDescription($"{body} characters: raises (+) or lowers (-) the outer corners, in degrees. Mirrored between the two eyes.", + t.RotationZ = config.Bind(section, prefix + "Rotation Z", d.RotZ, + new ConfigDescription($"{who}: raises (+) or lowers (-) the outer corner, in degrees.", new AcceptableValueRange(-90f, 90f), new ConfigurationManagerAttributes { Order = order + 3 })); } diff --git a/JotunnModStub/Sverm/SvermVisuals.cs b/JotunnModStub/Sverm/SvermVisuals.cs index 9cb6c82..350a153 100644 --- a/JotunnModStub/Sverm/SvermVisuals.cs +++ b/JotunnModStub/Sverm/SvermVisuals.cs @@ -256,30 +256,31 @@ namespace RacesOfValheim float eyeSize = EyeSize; PlayerFace.AdjustEyes(player, ref height, ref separation, ref eyeSize); - float forward = EyeForward; - EyePositionConfig.Tuning tuning = EyePositionConfig.For(SvermConfig.RaceId, player); - if (tuning != null) - { - forward += tuning.Forward.Value; - height += tuning.Height.Value; - separation += tuning.Separation.Value; - eyeSize *= tuning.Size.Value; - } - - Vector3 baseLocal = frame.LocalForward * (forward * scale * toLocal) - + frame.LocalUp * (height * scale * toLocal); - - float eyeLocalSize = eyeSize * scale * toLocal; - 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. float side = i == 0 ? -1f : 1f; - float size = i == 0 ? eyeLocalSize * LeftEyeSizeMultiplier : eyeLocalSize; - eye.localPosition = baseLocal + frame.LocalRight * (side * separation * scale * toLocal); + // This eye's sliders from "Eyes Position - Sverm". + float forward = EyeForward; + float eyeHeight = height; + float eyeSeparation = separation; + float size = eyeSize * scale * toLocal; + EyePositionConfig.Tuning tuning = EyePositionConfig.For(SvermConfig.RaceId, player, side); + if (tuning != null) + { + forward += tuning.Forward.Value; + eyeHeight += tuning.Height.Value; + eyeSeparation += tuning.Separation.Value; + size *= tuning.Size.Value; + } + if (i == 0) size *= LeftEyeSizeMultiplier; + + eye.localPosition = frame.LocalForward * (forward * scale * toLocal) + + frame.LocalUp * (eyeHeight * scale * toLocal) + + frame.LocalRight * (side * eyeSeparation * scale * toLocal); eye.localScale = Vector3.one * size; } } From a214a604e1ce26fe6adb9a3c00deb8a711fb1759 Mon Sep 17 00:00:00 2001 From: kanym Date: Tue, 27 Oct 2026 16:16:46 +0100 Subject: [PATCH 07/10] feat(eyes): Aswid and Alfar female per-eye defaults from playtest --- JotunnModStub/EyePositionConfig.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/JotunnModStub/EyePositionConfig.cs b/JotunnModStub/EyePositionConfig.cs index 26c9e2f..c238c7e 100644 --- a/JotunnModStub/EyePositionConfig.cs +++ b/JotunnModStub/EyePositionConfig.cs @@ -44,14 +44,15 @@ namespace RacesOfValheim { // Female defaults dialled in on screen (playtest, 2026-10-27). The male ones are // still the code's own placement; the Sverm's helmet hides its eyes, so it keeps it. - Defaults alfar = new Defaults { Separation = 0.006f, RotX = -17.524f }; - BindRace(config, AlfarConfig.RaceId, true, alfar, alfar); + BindRace(config, AlfarConfig.RaceId, true, + new Defaults { Separation = 0.006f, RotX = -17.524f }, + new Defaults { Separation = 0.015f, RotX = -17.524f }); BindRace(config, "Aswid", true, - new Defaults { Forward = -0.002f, Height = -0.001f, Separation = 0.003f, Size = 1.142f, - RotX = 1.298f, RotY = 0.649f }, - new Defaults { Forward = -0.001f, Height = -0.001f, Separation = 0.009f, Size = 1.142f, - RotX = 1.298f, RotY = 0.649f, RotZ = -7.788f }); + new Defaults { Forward = -0.006f, Height = -0.010f, Separation = 0f, Size = 1.314f, + RotX = -14.279f, RotY = -5.841f, RotZ = -1.298f }, + new Defaults { Forward = -0.006f, Height = -0.012f, Separation = 0.011f, Size = 1.324f, + RotX = 1.947f, RotY = 3.245f, RotZ = 4.544f }); Defaults dvergar = new Defaults { Forward = -0.011f, Separation = 0.005f, Size = 1.616f }; BindRace(config, DvergarConfig.RaceId, false, dvergar, dvergar); From 06b7fc165c9e760f91afcd17d6b450bc7a4a3fd2 Mon Sep 17 00:00:00 2001 From: kanym Date: Tue, 27 Oct 2026 16:17:03 +0100 Subject: [PATCH 08/10] feat(eyes): Dvergar female right-eye defaults from playtest --- JotunnModStub/EyePositionConfig.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/JotunnModStub/EyePositionConfig.cs b/JotunnModStub/EyePositionConfig.cs index c238c7e..ae8d4b8 100644 --- a/JotunnModStub/EyePositionConfig.cs +++ b/JotunnModStub/EyePositionConfig.cs @@ -54,8 +54,9 @@ namespace RacesOfValheim new Defaults { Forward = -0.006f, Height = -0.012f, Separation = 0.011f, Size = 1.324f, RotX = 1.947f, RotY = 3.245f, RotZ = 4.544f }); - Defaults dvergar = new Defaults { Forward = -0.011f, Separation = 0.005f, Size = 1.616f }; - BindRace(config, DvergarConfig.RaceId, false, dvergar, dvergar); + BindRace(config, DvergarConfig.RaceId, false, + new Defaults { Forward = -0.011f, Separation = 0.005f, Size = 1.616f }, + new Defaults { Forward = -0.015f, Separation = 0.013f, Size = 1.616f }); BindRace(config, SvermConfig.RaceId, false, new Defaults(), new Defaults()); } From f7a4494b3977f163b2f5131fb13393c2aa545c3c Mon Sep 17 00:00:00 2001 From: kanym Date: Tue, 27 Oct 2026 17:44:49 +0100 Subject: [PATCH 09/10] feat(eyes): male per-eye defaults from playtest Male Aswid, Alfar and Dvergar eye values dialled in on screen become the defaults of their Eyes Position sections, so male faces no longer start from the untuned code placement. --- JotunnModStub/EyePositionConfig.cs | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/JotunnModStub/EyePositionConfig.cs b/JotunnModStub/EyePositionConfig.cs index ae8d4b8..e08c257 100644 --- a/JotunnModStub/EyePositionConfig.cs +++ b/JotunnModStub/EyePositionConfig.cs @@ -42,23 +42,32 @@ namespace RacesOfValheim public static void Bind(ConfigFile config) { - // Female defaults dialled in on screen (playtest, 2026-10-27). The male ones are - // still the code's own placement; the Sverm's helmet hides its eyes, so it keeps it. + // Defaults dialled in on screen (playtest, 2026-10-27), per eye: female left, female + // right, male left, male right. The Sverm's helmet hides its eyes, so it keeps the + // code's own placement. BindRace(config, AlfarConfig.RaceId, true, new Defaults { Separation = 0.006f, RotX = -17.524f }, - new Defaults { Separation = 0.015f, RotX = -17.524f }); + new Defaults { Separation = 0.015f, RotX = -17.524f }, + new Defaults(), + new Defaults { Separation = 0.009f }); BindRace(config, "Aswid", true, new Defaults { Forward = -0.006f, Height = -0.010f, Separation = 0f, Size = 1.314f, RotX = -14.279f, RotY = -5.841f, RotZ = -1.298f }, new Defaults { Forward = -0.006f, Height = -0.012f, Separation = 0.011f, Size = 1.324f, - RotX = 1.947f, RotY = 3.245f, RotZ = 4.544f }); + RotX = 1.947f, RotY = 3.245f, RotZ = 4.544f }, + new Defaults { Height = -0.005f, Separation = -0.005f, Size = 1.273f, + RotX = 6.49f, RotY = 4.544f, RotZ = 4.544f }, + new Defaults { Forward = -0.002f, Height = -0.005f, Separation = 0.004f, Size = 1.444f, + RotZ = 6.49f }); BindRace(config, DvergarConfig.RaceId, false, new Defaults { Forward = -0.011f, Separation = 0.005f, Size = 1.616f }, - new Defaults { Forward = -0.015f, Separation = 0.013f, Size = 1.616f }); + new Defaults { Forward = -0.015f, Separation = 0.013f, Size = 1.616f }, + new Defaults { Forward = -0.003f, Size = 1.05f }, + new Defaults { Forward = -0.004f, Separation = 0.005f }); - BindRace(config, SvermConfig.RaceId, false, new Defaults(), new Defaults()); + BindRace(config, SvermConfig.RaceId, false, new Defaults(), new Defaults(), new Defaults(), new Defaults()); } /// Starting values for one eye's sliders. @@ -79,15 +88,16 @@ namespace RacesOfValheim return set[(PlayerFace.IsFemale(player) ? 2 : 0) + (side < 0f ? 0 : 1)]; } - private static void BindRace(ConfigFile config, string race, bool rotation, Defaults femaleLeft, Defaults femaleRight) + private static void BindRace(ConfigFile config, string race, bool rotation, + Defaults femaleLeft, Defaults femaleRight, Defaults maleLeft, Defaults maleRight) { string section = SectionPrefix + race; // Female first in the list, left before right: Order sorts high to low. tunings[race] = new[] { - BindEye(config, section, "Male", "Left", rotation, 200, new Defaults()), - BindEye(config, section, "Male", "Right", rotation, 100, new Defaults()), + BindEye(config, section, "Male", "Left", rotation, 200, maleLeft), + BindEye(config, section, "Male", "Right", rotation, 100, maleRight), BindEye(config, section, "Female", "Left", rotation, 400, femaleLeft), BindEye(config, section, "Female", "Right", rotation, 300, femaleRight), }; From 5b3b2ac88d29d152c16f75db4b915cd09b15e9f1 Mon Sep 17 00:00:00 2001 From: kanym Date: Tue, 27 Oct 2026 17:46:36 +0100 Subject: [PATCH 10/10] refactor(eyes): bake the tuned eye corrections in, drop the sliders The Eyes Position sections were a tuning tool. Their per-body, per-eye values from playtest now live in RaceEyeTuning as constants, so every player gets the tuned faces and Configuration Manager loses four sections. The Aswid - Eyes section stays for now. --- JotunnModStub/Alfar/AlfarVisuals.cs | 12 +- JotunnModStub/Aswid/AswidVisuals.cs | 14 +-- JotunnModStub/ConfigSync.cs | 1 - JotunnModStub/Dvergar/DvergarVisuals.cs | 12 +- JotunnModStub/EyePositionConfig.cs | 141 ------------------------ JotunnModStub/RaceEyeTuning.cs | 64 +++++++++++ JotunnModStub/RacesOfValheim.cs | 2 - JotunnModStub/Sverm/SvermVisuals.cs | 12 +- 8 files changed, 89 insertions(+), 169 deletions(-) delete mode 100644 JotunnModStub/EyePositionConfig.cs create mode 100644 JotunnModStub/RaceEyeTuning.cs diff --git a/JotunnModStub/Alfar/AlfarVisuals.cs b/JotunnModStub/Alfar/AlfarVisuals.cs index 70b3f68..aa6df6e 100644 --- a/JotunnModStub/Alfar/AlfarVisuals.cs +++ b/JotunnModStub/Alfar/AlfarVisuals.cs @@ -196,7 +196,7 @@ namespace RacesOfValheim // slant and the wrap are mirrored so both outer corners go up and back. float side = i == 0 ? -1f : 1f; - // This eye's sliders from "Eyes Position - Alfar". + // This eye's hand corrections (RaceEyeTuning). float forward = AlfarConfig.EyeForward; float eyeHeight = height; float eyeSeparation = separation; @@ -204,13 +204,13 @@ namespace RacesOfValheim float wrap = AlfarConfig.EyeWrap; float slant = AlfarConfig.EyeSlant; float tilt = 0f; - EyePositionConfig.Tuning tuning = EyePositionConfig.For(AlfarConfig.RaceId, player, side); + RaceEyeTuning.Eye tuning = RaceEyeTuning.For(AlfarConfig.RaceId, player, side); if (tuning != null) { - forward += tuning.Forward.Value; - eyeHeight += tuning.Height.Value; - eyeSeparation += tuning.Separation.Value; - eyeSize *= tuning.Size.Value; + forward += tuning.Forward; + eyeHeight += tuning.Height; + eyeSeparation += tuning.Separation; + eyeSize *= tuning.Size; tilt = tuning.RotX; wrap += tuning.RotY; slant += tuning.RotZ; diff --git a/JotunnModStub/Aswid/AswidVisuals.cs b/JotunnModStub/Aswid/AswidVisuals.cs index 8d0aeef..c0822ad 100644 --- a/JotunnModStub/Aswid/AswidVisuals.cs +++ b/JotunnModStub/Aswid/AswidVisuals.cs @@ -332,12 +332,12 @@ namespace RacesOfValheim float side = Mathf.Sign(Vector3.Dot(authored.Position, frame.LocalRight)); if (side == 0f) side = i == 0 ? -1f : 1f; - // This eye's sliders from "Eyes Position - Aswid", on top of the race's own offsets. - EyePositionConfig.Tuning tuning = EyePositionConfig.For("Aswid", player, side); - float forward = AswidConfig.EyeForwardOffset.Value + (tuning != null ? tuning.Forward.Value : 0f); - float height = AswidConfig.EyeHeightOffset.Value + (tuning != null ? tuning.Height.Value : 0f); - float separation = AswidConfig.EyeSeparationOffset.Value + (tuning != null ? tuning.Separation.Value : 0f); - float size = AswidConfig.EyeSizeMultiplier.Value * (tuning != null ? tuning.Size.Value : 1f); + // This eye's hand corrections (RaceEyeTuning), on top of the race's own offsets. + RaceEyeTuning.Eye tuning = RaceEyeTuning.For("Aswid", player, side); + float forward = AswidConfig.EyeForwardOffset.Value + (tuning != null ? tuning.Forward : 0f); + float height = AswidConfig.EyeHeightOffset.Value + (tuning != null ? tuning.Height : 0f); + float separation = AswidConfig.EyeSeparationOffset.Value + (tuning != null ? tuning.Separation : 0f); + float size = AswidConfig.EyeSizeMultiplier.Value * (tuning != null ? tuning.Size : 1f); Vector3 shift = frame.LocalForward * (forward * scale) + frame.LocalUp * (height * scale); @@ -359,7 +359,7 @@ namespace RacesOfValheim AswidConfig.EyeRotationY.Value * side, AswidConfig.EyeRotationZ.Value); - // The Eyes Position sliders turn the eye on the FACE's axes instead: conjugated by + // The RaceEyeTuning corrections turn the eye on the FACE's axes instead: conjugated by // the face frame, X tips it, Y turns it toward the temple and Z raises the outer // corner, the same on both eyes. Added to the bone-axis twist above, X rolled the // eyes and a mirrored Z tipped one up and the other down. diff --git a/JotunnModStub/ConfigSync.cs b/JotunnModStub/ConfigSync.cs index 0f9ac48..abbad38 100644 --- a/JotunnModStub/ConfigSync.cs +++ b/JotunnModStub/ConfigSync.cs @@ -87,7 +87,6 @@ namespace RacesOfValheim if (section.EndsWith("Keybinds", StringComparison.OrdinalIgnoreCase)) return false; if (LocalSections.Contains(section, StringComparer.OrdinalIgnoreCase)) return false; - if (section.StartsWith(EyePositionConfig.SectionPrefix, StringComparison.OrdinalIgnoreCase)) return false; if (LocalKeyParts.Any(key.Contains)) return false; // Model pose nudges (rotation/offset/yaw) are cosmetic, but "Attack Reach Offset" is a diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index b156fe2..c654a3a 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -293,18 +293,18 @@ namespace RacesOfValheim // radius. float side = i == 0 ? -1f : 1f; - // This eye's sliders from "Eyes Position - Dvergar". + // This eye's hand corrections (RaceEyeTuning). float forward = DvergarConfig.EyeForward; float eyeHeight = height; float eyeSeparation = separation; float size = eyeSize * raceScale * toLocal; - EyePositionConfig.Tuning tuning = EyePositionConfig.For(DvergarConfig.RaceId, player, side); + RaceEyeTuning.Eye tuning = RaceEyeTuning.For(DvergarConfig.RaceId, player, side); if (tuning != null) { - forward += tuning.Forward.Value; - eyeHeight += tuning.Height.Value; - eyeSeparation += tuning.Separation.Value; - size *= tuning.Size.Value; + forward += tuning.Forward; + eyeHeight += tuning.Height; + eyeSeparation += tuning.Separation; + size *= tuning.Size; } if (i == 0) size *= DvergarConfig.LeftEyeSizeMultiplier; diff --git a/JotunnModStub/EyePositionConfig.cs b/JotunnModStub/EyePositionConfig.cs deleted file mode 100644 index e08c257..0000000 --- a/JotunnModStub/EyePositionConfig.cs +++ /dev/null @@ -1,141 +0,0 @@ -using System.Collections.Generic; -using BepInEx.Configuration; - -namespace RacesOfValheim -{ - /// - /// Hand placement for every race that hangs eyes on the face: one "Eyes Position - race" - /// section each, with a set of sliders per body and per eye. Per body because the two bodies - /// put their painted eyes in different places (PlayerFace); per eye because the face is not - /// symmetric enough for one set to fit both. Left and right are the character's own. - /// - /// Every value is a delta on the placement the race's own code computes: all zeros (and size - /// 1) is the code's own placement, and the female defaults below are the corrections found in - /// game on top of it. - /// - /// Local, never synced (ConfigSync): it only changes how this client draws faces. - /// - public static class EyePositionConfig - { - public const string SectionPrefix = "Eyes Position - "; - - /// One eye's sliders, for one body of one race. - public sealed class Tuning - { - public ConfigEntry Forward; - public ConfigEntry Height; - public ConfigEntry Separation; - public ConfigEntry Size; - - // Only bound for races whose eyes are not spheres; null elsewhere. - public ConfigEntry RotationX; - public ConfigEntry RotationY; - public ConfigEntry RotationZ; - - public float RotX => RotationX != null ? RotationX.Value : 0f; - public float RotY => RotationY != null ? RotationY.Value : 0f; - public float RotZ => RotationZ != null ? RotationZ.Value : 0f; - } - - // [race] -> { male left, male right, female left, female right } - private static readonly Dictionary tunings = new Dictionary(); - - public static void Bind(ConfigFile config) - { - // Defaults dialled in on screen (playtest, 2026-10-27), per eye: female left, female - // right, male left, male right. The Sverm's helmet hides its eyes, so it keeps the - // code's own placement. - BindRace(config, AlfarConfig.RaceId, true, - new Defaults { Separation = 0.006f, RotX = -17.524f }, - new Defaults { Separation = 0.015f, RotX = -17.524f }, - new Defaults(), - new Defaults { Separation = 0.009f }); - - BindRace(config, "Aswid", true, - new Defaults { Forward = -0.006f, Height = -0.010f, Separation = 0f, Size = 1.314f, - RotX = -14.279f, RotY = -5.841f, RotZ = -1.298f }, - new Defaults { Forward = -0.006f, Height = -0.012f, Separation = 0.011f, Size = 1.324f, - RotX = 1.947f, RotY = 3.245f, RotZ = 4.544f }, - new Defaults { Height = -0.005f, Separation = -0.005f, Size = 1.273f, - RotX = 6.49f, RotY = 4.544f, RotZ = 4.544f }, - new Defaults { Forward = -0.002f, Height = -0.005f, Separation = 0.004f, Size = 1.444f, - RotZ = 6.49f }); - - BindRace(config, DvergarConfig.RaceId, false, - new Defaults { Forward = -0.011f, Separation = 0.005f, Size = 1.616f }, - new Defaults { Forward = -0.015f, Separation = 0.013f, Size = 1.616f }, - new Defaults { Forward = -0.003f, Size = 1.05f }, - new Defaults { Forward = -0.004f, Separation = 0.005f }); - - BindRace(config, SvermConfig.RaceId, false, new Defaults(), new Defaults(), new Defaults(), new Defaults()); - } - - /// Starting values for one eye's sliders. - private sealed class Defaults - { - public float Forward, Height, Separation, RotX, RotY, RotZ; - public float Size = 1f; - } - - /// - /// The sliders for one eye of the body this player is wearing right now. Side is the - /// races' own convention: negative is offset against the head frame's right axis, which is - /// the character's left eye. - /// - public static Tuning For(string race, Player player, float side) - { - if (!tunings.TryGetValue(race, out Tuning[] set)) return null; - return set[(PlayerFace.IsFemale(player) ? 2 : 0) + (side < 0f ? 0 : 1)]; - } - - private static void BindRace(ConfigFile config, string race, bool rotation, - Defaults femaleLeft, Defaults femaleRight, Defaults maleLeft, Defaults maleRight) - { - string section = SectionPrefix + race; - - // Female first in the list, left before right: Order sorts high to low. - tunings[race] = new[] - { - BindEye(config, section, "Male", "Left", rotation, 200, maleLeft), - BindEye(config, section, "Male", "Right", rotation, 100, maleRight), - BindEye(config, section, "Female", "Left", rotation, 400, femaleLeft), - BindEye(config, section, "Female", "Right", rotation, 300, femaleRight), - }; - } - - private static Tuning BindEye(ConfigFile config, string section, string body, string eye, bool rotation, int order, Defaults d) - { - string prefix = $"{body} {eye} Eye "; - string who = $"{body} characters, {eye.ToLowerInvariant()} eye (the character's own {eye.ToLowerInvariant()})"; - Tuning t = new Tuning(); - - t.Forward = config.Bind(section, prefix + "Forward", d.Forward, - new ConfigDescription($"{who}: moves the eye out of (+) or into (-) the face, in metres.", - new AcceptableValueRange(-0.05f, 0.05f), new ConfigurationManagerAttributes { Order = order + 9 })); - t.Height = config.Bind(section, prefix + "Height", d.Height, - new ConfigDescription($"{who}: moves the eye up (+) or down (-), in metres.", - new AcceptableValueRange(-0.05f, 0.05f), new ConfigurationManagerAttributes { Order = order + 8 })); - t.Separation = config.Bind(section, prefix + "Separation", d.Separation, - new ConfigDescription($"{who}: moves the eye away from (+) or toward (-) the nose, in metres.", - new AcceptableValueRange(-0.03f, 0.03f), new ConfigurationManagerAttributes { Order = order + 7 })); - t.Size = config.Bind(section, prefix + "Size", d.Size, - new ConfigDescription($"{who}: scales the eye. 1 is the default size.", - new AcceptableValueRange(0.2f, 3f), new ConfigurationManagerAttributes { Order = order + 6 })); - - if (rotation) - { - t.RotationX = config.Bind(section, prefix + "Rotation X", d.RotX, - new ConfigDescription($"{who}: tips the eye down (+) or up (-), in degrees.", - new AcceptableValueRange(-90f, 90f), new ConfigurationManagerAttributes { Order = order + 5 })); - t.RotationY = config.Bind(section, prefix + "Rotation Y", d.RotY, - new ConfigDescription($"{who}: turns the eye toward the temple (+) or the nose (-), in degrees.", - new AcceptableValueRange(-90f, 90f), new ConfigurationManagerAttributes { Order = order + 4 })); - t.RotationZ = config.Bind(section, prefix + "Rotation Z", d.RotZ, - new ConfigDescription($"{who}: raises (+) or lowers (-) the outer corner, in degrees.", - new AcceptableValueRange(-90f, 90f), new ConfigurationManagerAttributes { Order = order + 3 })); - } - - return t; - } - } -} diff --git a/JotunnModStub/RaceEyeTuning.cs b/JotunnModStub/RaceEyeTuning.cs new file mode 100644 index 0000000..ea55567 --- /dev/null +++ b/JotunnModStub/RaceEyeTuning.cs @@ -0,0 +1,64 @@ +using System.Collections.Generic; + +namespace RacesOfValheim +{ + /// + /// Hand corrections for every race that hangs eyes on the face, per body and per eye. Per body + /// because the two bodies put their painted eyes in different places (PlayerFace); per eye + /// because the face is not symmetric enough for one set to fit both. Left and right are the + /// character's own. + /// + /// Every value is a delta on the placement the race's own code computes: zeros (and size 1) + /// change nothing. They were dialled in on screen with Configuration Manager sliders + /// (playtest, 2026-10-27) and then written down here; the sliders are gone. + /// + public static class RaceEyeTuning + { + /// One eye's corrections. Metres for the offsets, degrees for the rotations. + public sealed class Eye + { + public float Forward, Height, Separation, RotX, RotY, RotZ; + public float Size = 1f; + } + + private static readonly Eye Untouched = new Eye(); + + // [race] -> { male left, male right, female left, female right } + private static readonly Dictionary tunings = new Dictionary + { + [AlfarConfig.RaceId] = new[] + { + new Eye(), + new Eye { Separation = 0.009f }, + new Eye { Separation = 0.006f, RotX = -17.524f }, + new Eye { Separation = 0.015f, RotX = -17.524f }, + }, + ["Aswid"] = new[] + { + new Eye { Height = -0.005f, Separation = -0.005f, Size = 1.273f, RotX = 6.49f, RotY = 4.544f, RotZ = 4.544f }, + new Eye { Forward = -0.002f, Height = -0.005f, Separation = 0.004f, Size = 1.444f, RotZ = 6.49f }, + new Eye { Forward = -0.006f, Height = -0.010f, Size = 1.314f, RotX = -14.279f, RotY = -5.841f, RotZ = -1.298f }, + new Eye { Forward = -0.006f, Height = -0.012f, Separation = 0.011f, Size = 1.324f, RotX = 1.947f, RotY = 3.245f, RotZ = 4.544f }, + }, + [DvergarConfig.RaceId] = new[] + { + new Eye { Forward = -0.003f, Size = 1.05f }, + new Eye { Forward = -0.004f, Separation = 0.005f }, + new Eye { Forward = -0.011f, Separation = 0.005f, Size = 1.616f }, + new Eye { Forward = -0.015f, Separation = 0.013f, Size = 1.616f }, + }, + // The Sverm's helmet hides its eyes, so it keeps the code's own placement. + }; + + /// + /// The corrections for one eye of the body this player is wearing right now. Side is the + /// races' own convention: negative is offset against the head frame's right axis, which is + /// the character's left eye. Never null. + /// + public static Eye For(string race, Player player, float side) + { + if (!tunings.TryGetValue(race, out Eye[] set)) return Untouched; + return set[(PlayerFace.IsFemale(player) ? 2 : 0) + (side < 0f ? 0 : 1)]; + } + } +} diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 5eb3b9b..f075a97 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -56,8 +56,6 @@ namespace RacesOfValheim // Not a race either: the faction truce and the faction merchants, which cut across // every race at once, so they bind last rather than inside the alphabetical run above. FactionsConfig.Bind(Config); - // Not a race either: the hand placement of every race's eyes, one section per race. - EyePositionConfig.Bind(Config); // After every Bind above: tags the gameplay entries for Jotunn's server-to-client sync. ConfigSync.Apply(Config); harmony.PatchAll(); diff --git a/JotunnModStub/Sverm/SvermVisuals.cs b/JotunnModStub/Sverm/SvermVisuals.cs index 350a153..dd18e5d 100644 --- a/JotunnModStub/Sverm/SvermVisuals.cs +++ b/JotunnModStub/Sverm/SvermVisuals.cs @@ -263,18 +263,18 @@ namespace RacesOfValheim // Index 0 is offset against the right axis, so it is the model's left eye. float side = i == 0 ? -1f : 1f; - // This eye's sliders from "Eyes Position - Sverm". + // This eye's hand corrections (RaceEyeTuning). float forward = EyeForward; float eyeHeight = height; float eyeSeparation = separation; float size = eyeSize * scale * toLocal; - EyePositionConfig.Tuning tuning = EyePositionConfig.For(SvermConfig.RaceId, player, side); + RaceEyeTuning.Eye tuning = RaceEyeTuning.For(SvermConfig.RaceId, player, side); if (tuning != null) { - forward += tuning.Forward.Value; - eyeHeight += tuning.Height.Value; - eyeSeparation += tuning.Separation.Value; - size *= tuning.Size.Value; + forward += tuning.Forward; + eyeHeight += tuning.Height; + eyeSeparation += tuning.Separation; + size *= tuning.Size; } if (i == 0) size *= LeftEyeSizeMultiplier;