Materials: each constant's type from the shader tables; integers written as integers #183

Manually merged
github merged 3 commits from gh-pr/183/head into gh-pr/183/base 2026-11-26 20:16:11 +00:00
Owner

@⁠holdmysocks on GitHub · 2026-11-24 17:14 UTC · original
holdmysocks:claude/param-types → master · +145 −20 · 5 files · 3 commits · merged 2026-11-24 17:36 UTC

What

A material constant's descriptor in a drawable gives its size and place but not its type, so integer parameters were printed as floats (a value such as 4785 came out as a tiny float). The type is now joined from the shader archive's own tables (#147).

  • shaderfx::ParamIndex: per effect, each material constant's type code and shader-variable hash, by parameter hash. Built from shaders.rpf on first use (about 2 s) and kept in <work>/index/shader_params.json; rebuilt when the archive is newer.
  • The exporter fills type on each entry of drawable.shaders[].constants (float to float4, int, int3 ...).
  • materials.json and the four-layer multilayer.params write integer types as the integers their bits hold.

Type codes

Checked on real materials (two archives, about 1.1 million values): code 0x01 is zero or a small integer in all of about 20,000 values and never float-looking; code 0x03 always takes three components and holds byte patterns; 0x09 to 0x0c are float to float4. 0x02 and 0x04 are named int2 and int4 by that pattern only. Other codes stay type_xx and are written as unsigned integers.

Checked

  • A re-exported ground material: all 86 constants get a type (53 float, 32 float4, 1 int), and the integer one reads 4785 in model.json, materials.json and the four-layer parameters.
  • The index holds 577 effects.
  • cargo test -p sixng-core: 178 passed (new tests for the index, the type names and the typed output).

Not done

  • No boolean type was seen among material constants, so none is named.
  • 325 of the surveyed values belong to parameters that are not in their effect's table; they keep no type and are written as floats.
  • The first export after this change reads shaders.rpf once to build the index; if the archive is missing, constants simply keep no type.
  • Parameter names from the tables' variable hashes are stored in the index but not used yet.
**@⁠holdmysocks** on GitHub · 2026-11-24 17:14 UTC · [original](https://github.com/holdmysocks/SixNG/pull/183) `holdmysocks:claude/param-types` → `master` · +145 −20 · 5 files · 3 commits · merged 2026-11-24 17:36 UTC ## What A material constant's descriptor in a drawable gives its size and place but not its type, so integer parameters were printed as floats (a value such as 4785 came out as a tiny float). The type is now joined from the shader archive's own tables (#147). - `shaderfx::ParamIndex`: per effect, each material constant's type code and shader-variable hash, by parameter hash. Built from `shaders.rpf` on first use (about 2 s) and kept in `<work>/index/shader_params.json`; rebuilt when the archive is newer. - The exporter fills `type` on each entry of `drawable.shaders[].constants` (`float` to `float4`, `int`, `int3` ...). - `materials.json` and the four-layer `multilayer.params` write integer types as the integers their bits hold. ## Type codes Checked on real materials (two archives, about 1.1 million values): code 0x01 is zero or a small integer in all of about 20,000 values and never float-looking; code 0x03 always takes three components and holds byte patterns; 0x09 to 0x0c are float to float4. 0x02 and 0x04 are named `int2` and `int4` by that pattern only. Other codes stay `type_xx` and are written as unsigned integers. ## Checked - A re-exported ground material: all 86 constants get a type (53 `float`, 32 `float4`, 1 `int`), and the integer one reads 4785 in `model.json`, `materials.json` and the four-layer parameters. - The index holds 577 effects. - `cargo test -p sixng-core`: 178 passed (new tests for the index, the type names and the typed output). ## Not done - No boolean type was seen among material constants, so none is named. - 325 of the surveyed values belong to parameters that are not in their effect's table; they keep no type and are written as floats. - The first export after this change reads `shaders.rpf` once to build the index; if the archive is missing, constants simply keep no type. - Parameter names from the tables' variable hashes are stored in the index but not used yet.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:16:08 +00:00
github manually merged commit f634a10f70 into gh-pr/183/base 2026-11-26 20:16:11 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.