fix(dvergur): isolate the hood by bone collapse, and commit to a skin tone
The dump settled both. Skin: UpdateColors writes m_bodyModel.materials[0] _SkinColor, which is what the postfix already targeted, so the patch was never wrong - the colour was. _SkinColor multiplies the human skin texture rather than replacing it, and (0.72, 0.74, 0.82) is close enough to white to change nothing anyone can see. Every race that reads clearly commits to a channel, so the Dvergur now does too. Hood: the dvergr mesh reports zero triangles because it ships with Read/Write disabled, so its vertices and indices are unreachable at runtime and no submesh carving could ever have produced geometry. The rig does carry a hat1/hat2/hat3 chain that nothing but the hood is skinned to, so the hood is isolated without touching the mesh at all: instantiate the whole body, detach the hat chain from the skull, and collapse the armature root to zero scale, which pulls every vertex weighted to it into a single point and leaves only the hood standing. Alignment is computed rather than measured - the object is shifted by the gap between the hat bone and the player head bone - so there are no hand-tuned offsets, only optional nudges. Animator and LODGroup are stripped alongside the MonoBehaviours since neither is one and both would keep driving or hiding the rig, and the renderers are set to update when offscreen because the collapsed bones leave the skinned bounds meaningless.
This commit is contained in:
parent
d157a730a3
commit
244f2f5afc
2 changed files with 142 additions and 242 deletions
|
|
@ -40,11 +40,16 @@ namespace RacesOfValheim
|
|||
// ─── Skin ────────────────────────────────────────────────────────────
|
||||
// Written straight onto the body material's _SkinColor by the UpdateColors postfix, which
|
||||
// is the only thing that actually tints a player - see the comment on that patch.
|
||||
// Ashen grey with a blue cast, to read as one of the deep folk.
|
||||
public static readonly Color SkinColor = new Color(0.72f, 0.74f, 0.82f, 1f);
|
||||
//
|
||||
// This is a multiplier over the human skin texture, not a replacement, so a value near
|
||||
// (1,1,1) changes nothing anyone can see. The first attempt at (0.72, 0.74, 0.82) was
|
||||
// exactly that mistake: correct code, invisible result. Every race that reads clearly
|
||||
// commits to a channel - Trol (0.1, 0.6, 0.7), Furling (0.3, 0.8, 0.3) - so the Dvergur
|
||||
// does too: a cold, dark slate blue-grey.
|
||||
public static readonly Color SkinColor = new Color(0.42f, 0.52f, 0.68f, 1f);
|
||||
|
||||
// Dvergr are white-haired. The hood hides most of it, but the beard shows.
|
||||
public static readonly Color HairColor = new Color(0.88f, 0.88f, 0.90f, 1f);
|
||||
public static readonly Color HairColor = new Color(0.85f, 0.87f, 0.92f, 1f);
|
||||
|
||||
// ─── Cosmetic hood ───────────────────────────────────────────────────
|
||||
// The helmet slot itself stays free — whatever the player equips keeps all of its stats,
|
||||
|
|
@ -53,32 +58,30 @@ namespace RacesOfValheim
|
|||
// The hood is lifted straight off the Dvergr NPC rather than off the Dverger Circlet item:
|
||||
// the circlet is a metal band, not the hood the race is meant to wear.
|
||||
//
|
||||
// 'Dverger' turned out to carry a single renderer named 'dvergr' with the hood baked into
|
||||
// the same mesh as the body, so a whole-object lift was never going to work. Resolution now
|
||||
// tries, in order: a separate renderer object; a submesh of a combined mesh picked out by
|
||||
// its material; and finally an index pinned by hand below.
|
||||
// Two facts out of dumpdverger decide how this is done.
|
||||
//
|
||||
// The prefab holds one renderer, 'dvergr', whose mesh reports zero triangles - it ships
|
||||
// with Read/Write disabled, so its vertices and indices cannot be touched at runtime and
|
||||
// no amount of submesh carving will ever produce geometry.
|
||||
//
|
||||
// But its rig carries a dedicated hat1/hat2/hat3 bone chain under 'head'. The hood is
|
||||
// skinned to those bones and nothing else is, so the hood can be isolated by collapsing
|
||||
// every other bone to zero scale rather than by editing the mesh at all.
|
||||
public const string DvergerPrefabName = "Dverger";
|
||||
|
||||
// Scanned in order. The mage variants are included because they wear a different hood and
|
||||
// may well keep it as its own object.
|
||||
public static readonly string[] DvergerPrefabCandidates =
|
||||
{
|
||||
"Dverger", "DvergerMage", "DvergerMageFire", "DvergerMageIce", "DvergerMageSupport"
|
||||
};
|
||||
// The child of the prefab holding the armature and the renderer.
|
||||
public const string DvergerVisualName = "Visual";
|
||||
|
||||
// Matched against renderer object names, lowercased, by Contains.
|
||||
public static readonly string[] HoodRendererNames = { "hat", "hood", "helmet", "cap" };
|
||||
// Root of the hat bone chain, and the bone whose collapse hides everything else.
|
||||
public const string HoodBoneName = "hat1";
|
||||
public const string BodyRootBoneName = "Root";
|
||||
|
||||
// Matched against material names when the hood is a submesh of a combined mesh.
|
||||
public static readonly string[] HoodMaterialNames = { "hat", "hood", "helm", "cap", "head" };
|
||||
// Bone the hood is hung from on the player's own rig.
|
||||
public const string PlayerHeadBoneName = "Head";
|
||||
|
||||
// Escape hatch for when neither name matches: pin the prefab and the submesh index by hand
|
||||
// from what `dumpdverger` reports. An empty prefab or a negative index means "auto".
|
||||
public const string HoodForcedPrefab = "";
|
||||
public const int HoodForcedSubmeshIndex = -1;
|
||||
|
||||
// Applied on top of whatever the rig positions the hood at. Identity is correct when the
|
||||
// bone remap succeeds; these exist so a stubborn mesh can be nudged without a code change.
|
||||
// Nudges on top of the automatic alignment, which already puts the hat bone on the player's
|
||||
// head bone. Scale is the one most likely to need a look: the hood is authored for a Dvergr
|
||||
// skull, not a human one.
|
||||
public static readonly Vector3 HoodOffsetPosition = Vector3.zero;
|
||||
public static readonly Vector3 HoodOffsetRotation = Vector3.zero;
|
||||
public static readonly float HoodExtraScale = 1f;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue