Four-layer ground: layer UVs from the material's constants (128 per unit, not 64) #171

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

@⁠holdmysocks on GitHub · 2026-11-24 15:44 UTC · original
holdmysocks:claude/ground-detail-scale → master · +38 −3 · 2 files · 1 commits · merged 2026-11-24 16:05 UTC

What

A four-layer ground material's description (multilayer in model.json and materials.json) said every layer tiles as TEXCOORD_0 * 64. That was an assumption. Each layer's UV is now taken from the material's own constants, which became readable with #163.

  • 724bed95 (one value per layer): 1 = the layer uses the first UV set, anything else the second.
  • 4344d2cc: scale (xy) and offset (zw) of the first set. 9ecaaa1e: the same for the second.
  • multilayer.layers[k] now carries uv_set, uv_scale, uv_offset and uv_source; detail_uv.recommended follows layer 0 and says the values are per layer.

Evidence

  • Shader code: two deferred pixel programs (the base standard_uber_4lyr one and the main one of standard_uber_4lyr_dpm_dm_hbb, the most used variant) both compute uv0 * 4344d2cc.xy + zw and uv1 * 9ecaaa1e.xy + zw and pick one per layer by comparing the layer's 724bed95 component with 1.
  • Data: 16,365 four-layer materials sampled from the map archive, 719 distinct combinations. The first set's scale is (128, 128) in 14,509 of them (89 %; offsets 0 or 128, i.e. whole repeats). The per-layer choice is 1 or 2, and mixed within a material in 4,054 of them, so a single scale for all four layers was wrong for those too.
  • A re-exported map section shows TEXCOORD_0, 128, offset 0 or 128 on all four layers of its materials.

Changed

  • material.rs: four_layer_uv fills the layers from the constants; the fallback without constants is 128 and says it is assumed; the text about per-layer tiling is updated.
  • README row for multilayer materials.
  • cargo test -p sixng-core: 174 passed (the four-layer test covers a material whose layer 1 uses the second set).

Not done, not checked

  • Not compared with a rendered image of the game. The viewer does not blend the four layers, so there is no before and after picture; the change is in the exported description only.
  • The shader has a branch that samples a layer again at another scale (constant 26cc8f94); not decoded.
  • Which exported attribute is "the second UV set" is the same per-variant guess as before (alt_uv_set).
  • A fifth four-layer shader hash (0ad54cb9) shows the same constants in the survey but is not in this description's list; not touched.
**@⁠holdmysocks** on GitHub · 2026-11-24 15:44 UTC · [original](https://github.com/holdmysocks/SixNG/pull/171) `holdmysocks:claude/ground-detail-scale` → `master` · +38 −3 · 2 files · 1 commits · merged 2026-11-24 16:05 UTC ## What A four-layer ground material's description (`multilayer` in `model.json` and `materials.json`) said every layer tiles as `TEXCOORD_0 * 64`. That was an assumption. Each layer's UV is now taken from the material's own constants, which became readable with #163. - `724bed95` (one value per layer): 1 = the layer uses the first UV set, anything else the second. - `4344d2cc`: scale (xy) and offset (zw) of the first set. `9ecaaa1e`: the same for the second. - `multilayer.layers[k]` now carries `uv_set`, `uv_scale`, `uv_offset` and `uv_source`; `detail_uv.recommended` follows layer 0 and says the values are per layer. ## Evidence - **Shader code**: two deferred pixel programs (the base `standard_uber_4lyr` one and the main one of `standard_uber_4lyr_dpm_dm_hbb`, the most used variant) both compute `uv0 * 4344d2cc.xy + zw` and `uv1 * 9ecaaa1e.xy + zw` and pick one per layer by comparing the layer's `724bed95` component with 1. - **Data**: 16,365 four-layer materials sampled from the map archive, 719 distinct combinations. The first set's scale is (128, 128) in 14,509 of them (89 %; offsets 0 or 128, i.e. whole repeats). The per-layer choice is 1 or 2, and mixed within a material in 4,054 of them, so a single scale for all four layers was wrong for those too. - A re-exported map section shows `TEXCOORD_0`, 128, offset 0 or 128 on all four layers of its materials. ## Changed - `material.rs`: `four_layer_uv` fills the layers from the constants; the fallback without constants is 128 and says it is assumed; the text about per-layer tiling is updated. - README row for multilayer materials. - `cargo test -p sixng-core`: 174 passed (the four-layer test covers a material whose layer 1 uses the second set). ## Not done, not checked - **Not compared with a rendered image of the game.** The viewer does not blend the four layers, so there is no before and after picture; the change is in the exported description only. - The shader has a branch that samples a layer again at another scale (constant `26cc8f94`); not decoded. - Which exported attribute is "the second UV set" is the same per-variant guess as before (`alt_uv_set`). - A fifth four-layer shader hash (`0ad54cb9`) shows the same constants in the survey but is not in this description's list; not touched.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:15:07 +00:00
github manually merged commit 6c2d97d222 into gh-pr/171/base 2026-11-26 20:15:10 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.