Skin spec maps as glTF channels and in the viewer's skin shading (#392, part 2) #446

Manually merged
github merged 5 commits from github-bot/gh-446 into gh-pr/446/base 2026-11-27 04:42:23 +00:00 AGit
Owner

@⁠holdmysocks on GitHub · 2026-11-27 03:10 UTC · original
holdmysocks:people-skin-shading → master · +172 −6 · 10 files · 5 commits · merged 2026-11-27 04:37 UTC

#392, part 2. Stacked on PR 435 (it carries that PR's two commits); merge PR 435 first.

What the game does

Read from the forward skin program PS_StudioPedTextured_Eight (the shader archive's forwardstudio technique):

  • speculartex G is roughness. GGX alpha = roughness squared. There is no metal.
  • F0 = 0.04 x (1 + fresnel), where fresnel is the material's specularfresnel constant (b5fe3acb). On body skin it is -0.3, so F0 = 0.028; f90 = saturate(49.5 x F0) = 1.
  • speculartex R (translucency) and B (occlusion) go only to the deferred G-buffer. speculartex2 R is the detail strength, and its G is a region index into engine-wide detail atlases.

What changes

  • GLB: each skin material's metallicRoughnessTexture is speculartex, with metallicFactor 0 and roughnessFactor 1. glTF reads roughness from G, and B is not read as metal. KHR_materials_specular.specularFactor = 1 + fresnel (0.7). extras.skin_spec keeps both raw maps and their channel meanings.
  • Viewer: skin uses speculartex G as roughness and the game's F0. speculartex2 is no longer read as a packed roughness/metal map; before, that put streaks on the torso and arms.
  • README and module docs updated.

Not carried (stated in the README)

  • The detail-normal and detail-control atlases are engine-wide. No mesh binds them.
  • The game scales F0 by a window on the albedo's brightness. Its bounds come from a per-frame buffer, so it is taken as 1 here.
  • Translucency and occlusion are used only by the deferred lighting pass, which is not decoded.

Checks

  • cargo test -p sixng-core (346 passed) and cargo test -p sixng-gui (53 passed). The release build has no warnings.
  • Exported cs_lucia and cs_jason (look 0). Every skin material (hands, feet, body pieces, teeth) has the texture and the extension, and extensionsUsed lists KHR_materials_specular.
  • Viewer on the RTX 4080:
    • Lucia's torso and arms lose the old streaks.
    • Legs, hands and feet shade evenly.
    • Jason's body, arms, hands and legs look right.
**@⁠holdmysocks** on GitHub · 2026-11-27 03:10 UTC · [original](https://github.com/holdmysocks/SixNG/pull/446) `holdmysocks:people-skin-shading` → `master` · +172 −6 · 10 files · 5 commits · merged 2026-11-27 04:37 UTC #392, part 2. Stacked on PR 435 (it carries that PR's two commits); merge PR 435 first. ## What the game does Read from the forward skin program `PS_StudioPedTextured_Eight` (the shader archive's `forwardstudio` technique): - `speculartex` G is roughness. GGX alpha = roughness squared. There is no metal. - F0 = 0.04 x (1 + `fresnel`), where `fresnel` is the material's `specularfresnel` constant (`b5fe3acb`). On body skin it is -0.3, so F0 = 0.028; f90 = saturate(49.5 x F0) = 1. - `speculartex` R (translucency) and B (occlusion) go only to the deferred G-buffer. `speculartex2` R is the detail strength, and its G is a region index into engine-wide detail atlases. ## What changes - **GLB:** each skin material's `metallicRoughnessTexture` is `speculartex`, with metallicFactor 0 and roughnessFactor 1. glTF reads roughness from G, and B is not read as metal. `KHR_materials_specular.specularFactor` = 1 + `fresnel` (0.7). `extras.skin_spec` keeps both raw maps and their channel meanings. - **Viewer:** skin uses `speculartex` G as roughness and the game's F0. `speculartex2` is no longer read as a packed roughness/metal map; before, that put streaks on the torso and arms. - README and module docs updated. ## Not carried (stated in the README) - The detail-normal and detail-control atlases are engine-wide. No mesh binds them. - The game scales F0 by a window on the albedo's brightness. Its bounds come from a per-frame buffer, so it is taken as 1 here. - Translucency and occlusion are used only by the deferred lighting pass, which is not decoded. ## Checks - `cargo test -p sixng-core` (346 passed) and `cargo test -p sixng-gui` (53 passed). The release build has no warnings. - Exported cs_lucia and cs_jason (look 0). Every skin material (hands, feet, body pieces, teeth) has the texture and the extension, and `extensionsUsed` lists `KHR_materials_specular`. - Viewer on the RTX 4080: - Lucia's torso and arms lose the old streaks. - Legs, hands and feet shade evenly. - Jason's body, arms, hands and legs look right.
The skin shader's speculartex and speculartex2 slots bind placeholders
on every main hand_/feet_ mesh. Each wardrobe texture state names a
Material asset id; the material assets (PSO asset sets in packs.rpf)
list the two spec maps under keys 179eb44a and 4cf41ef4. New skinspec
table (colour map -> material -> spec maps, cached in work/index), used
by the outfit and model exports to fill those slots. Shared colour maps
that name more than one material are left out. The maps are carried as
stored; their channel use in the skin program is not decoded.
speculartex: R translucency mask, G roughness (stored as 1 - roughness),
B occlusion. speculartex2: R detail strength mask, G skin region (high
nibble) that picks the detail normal / control atlas layer. Slot roles,
module docs, export note and README updated.
The game's forward skin program (PS_StudioPedTextured_Eight) reads
speculartex G as roughness (GGX alpha = roughness squared), has no metal,
and takes F0 = 0.04 x (1 + fresnel) from the material's specularfresnel
constant (-0.3 on body skin: F0 0.028).

- GLB: speculartex is the skin material's metallicRoughnessTexture
  (metallic 0, roughness 1) and KHR_materials_specular.specularFactor is
  1 + fresnel. extras.skin_spec keeps both raw maps and their channels.
- Viewer: skin reads speculartex G as roughness with the game's F0;
  speculartex2 is no longer read as a packed roughness/metal map, which
  put streaks on the torso and arms.
- README and module docs name what is not carried: the engine-wide detail
  atlases, the per-frame albedo window on F0, and translucency and
  occlusion, which only the deferred lighting uses.
# Conflicts:
#	README.md
#	crates/sixng-core/src/skinspec.rs
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 03:15:09 +00:00
github-bot changed target branch from master to gh-pr/446/base 2026-11-27 04:42:23 +00:00
github manually merged commit f120f90da9 into gh-pr/446/base 2026-11-27 04:42:23 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.