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.
51 lines
2.6 KiB
C#
51 lines
2.6 KiB
C#
using UnityEngine;
|
|
|
|
namespace RacesOfValheim
|
|
{
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
public static class PlayerFace
|
|
{
|
|
public const float MetresToHeadLocal = 0.01f;
|
|
|
|
// 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;
|
|
|
|
/// <summary>True while the body wears the female mesh (VisEquipment model index 1).</summary>
|
|
public static bool IsFemale(Player player)
|
|
{
|
|
VisEquipment vis = player != null ? player.GetComponent<VisEquipment>() : 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;
|
|
}
|
|
|
|
/// <summary>Moves male-tuned eye numbers (metres) onto the female face; leaves a male face alone.</summary>
|
|
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;
|
|
}
|
|
}
|
|
}
|