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.
This commit is contained in:
parent
a927a6d4b3
commit
026def2fde
8 changed files with 139 additions and 42 deletions
|
|
@ -161,35 +161,47 @@ namespace RacesOfValheim
|
|||
}
|
||||
if (eyes == null) return;
|
||||
|
||||
PlaceEyes(headBone, eyes);
|
||||
PlaceEyes(player, eyes);
|
||||
}
|
||||
|
||||
private static void PlaceEyes(Transform headBone, Transform holder)
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
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<EyeFrame>();
|
||||
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
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue