Four-layer ground: layer order, weights and data maps confirmed from the shader code #161

Manually merged
github merged 1 commit from gh-pr/161/head into gh-pr/161/base 2026-11-26 20:14:26 +00:00
Owner

@⁠holdmysocks on GitHub · 2026-11-24 14:01 UTC · original
holdmysocks:claude/four-layer-from-shader → master · +17 −4 · 2 files · 1 commits · merged 2026-11-24 14:24 UTC

First result of reading layer blending in the shader code (SIX-68). Description and confidence only: the exporter's and viewer's behaviour is unchanged.

Read

One deferred pixel program of standard_uber_4lyr (about 5,400 instructions), with the texture slots and constant offsets from sixng shader-bindings. The other four-layer variants have the same 17 texture slots and use this same program for their alpha-clip pass; their own main programs were not read.

Confirmed from the code

  • Channel order: the lookup texture's R, G, B weight layers 0, 1, 2 and the remainder saturate(1 - r - g - b) weights layer 3. This was medium (R, G, B) and low (layer 3) confidence from a seam test; it is now read directly.
  • Combination: each layer is shaded on its own, multiplied by its weight, and the four are added. A layer whose weight is 0 is skipped.
  • Data maps: the four unnamed textures are one per layer (3022de38, 42110214, 0cd6179f, 3ea37b39 for layers 0 to 3), each sampled with its layer's UV right before that layer's colour and normal map. This matches the pairing found earlier by co-occurrence.

New

  • Vertex override: the weights are mix(lookup.rgb, colour.rgb, colour.a) with the second vertex colour set, so that set can replace the lookup texture per vertex.
  • Data map alpha is the layer's tint mask (the shader can use 1 - a by a material constant). G and B are read; B is also used as 1 - b later.

Changed

  • multilayer of a four-layer material in model.json: weights.vertex_override, weights.result, data_map_channels, and the confidence entries for channel order, layer 3 and data-map pairing set to high.
  • README row for multilayer materials.
  • cargo test -p sixng-core: 170 passed.

Not decoded, not checked

  • What the data maps' G and B channels do, the height-based blend, the per-layer tiling.
  • Which exported attribute holds the second vertex colour set was not checked on a mesh, and neither rule was compared with a rendered image.
  • The program also has a branch driven by world position and a per-material vec4 that diverts part of each weight to textures that are not the material's own; not read.
  • A wider finding for a follow-up: these materials have two constant buffers, and the values SixNG prints for their constants today do not line up with the buffer layout (the second buffer's values are missing). Not touched here.
**@⁠holdmysocks** on GitHub · 2026-11-24 14:01 UTC · [original](https://github.com/holdmysocks/SixNG/pull/161) `holdmysocks:claude/four-layer-from-shader` → `master` · +17 −4 · 2 files · 1 commits · merged 2026-11-24 14:24 UTC First result of reading layer blending in the shader code (SIX-68). Description and confidence only: the exporter's and viewer's behaviour is unchanged. ## Read One deferred pixel program of `standard_uber_4lyr` (about 5,400 instructions), with the texture slots and constant offsets from `sixng shader-bindings`. The other four-layer variants have the same 17 texture slots and use this same program for their alpha-clip pass; their own main programs were not read. ## Confirmed from the code - **Channel order**: the lookup texture's R, G, B weight layers 0, 1, 2 and the remainder `saturate(1 - r - g - b)` weights layer 3. This was medium (R, G, B) and low (layer 3) confidence from a seam test; it is now read directly. - **Combination**: each layer is shaded on its own, multiplied by its weight, and the four are added. A layer whose weight is 0 is skipped. - **Data maps**: the four unnamed textures are one per layer (`3022de38`, `42110214`, `0cd6179f`, `3ea37b39` for layers 0 to 3), each sampled with its layer's UV right before that layer's colour and normal map. This matches the pairing found earlier by co-occurrence. ## New - **Vertex override**: the weights are `mix(lookup.rgb, colour.rgb, colour.a)` with the second vertex colour set, so that set can replace the lookup texture per vertex. - **Data map alpha** is the layer's tint mask (the shader can use `1 - a` by a material constant). G and B are read; B is also used as `1 - b` later. ## Changed - `multilayer` of a four-layer material in `model.json`: `weights.vertex_override`, `weights.result`, `data_map_channels`, and the confidence entries for channel order, layer 3 and data-map pairing set to high. - README row for multilayer materials. - `cargo test -p sixng-core`: 170 passed. ## Not decoded, not checked - What the data maps' G and B channels do, the height-based blend, the per-layer tiling. - Which exported attribute holds the second vertex colour set was not checked on a mesh, and neither rule was compared with a rendered image. - The program also has a branch driven by world position and a per-material vec4 that diverts part of each weight to textures that are not the material's own; not read. - A wider finding for a follow-up: these materials have two constant buffers, and the values SixNG prints for their constants today do not line up with the buffer layout (the second buffer's values are missing). Not touched here.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:14:24 +00:00
github manually merged commit 0577151b5b into gh-pr/161/base 2026-11-26 20:14:26 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.