Materials: read constant values from their buffer at their byte offset #163
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/holdmysocks--SixNG!163
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/163/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@holdmysocks on GitHub · 2026-11-24 14:38 UTC · original
holdmysocks:claude/material-constants→master· +119 −51 · 4 files · 2 commits · merged 2026-11-24 15:14 UTCProblem
The values SixNG printed for a material's constants (in
model.jsonunderdrawable.shaders[].constants, inmaterials.jsonunderparameters, and in the four-layermultilayer.params) were wrong for nearly every constant. The reader took a descriptor's offset as a float index into the constant block itself, with 8 bits. Found while checking a shader reading against real ground materials.Layout, as read from the data
components << 22 | byte offset << 8 | buffer: 1 to 4 floats, a 14-bit byte offset, and which constant buffer (0x03; 0x07 on materials with a second one).sixng shader-bindings): for example the four-layer ground's second buffer has4344d2cc(float4) at 0 and1c1acf8c(float) at 640 in both.Checked on the game data
(128, 128)with offset 0, the per-layer UV selector(1, 1, 1, 1), selector scalars 0 or 1.cargo test -p sixng-core: 171 passed (new tests for the reader and the four-layer split).Changed
drawable.rs: the reader;ShaderConstgainsbufferandcount, andoffsetis now the byte offset.materials.json: a scalar is one number, a vector its own 2 to 4 components (records without a count keep four).multilayer.params: float4 constants are split per layer (as the shader code uses them), the two UV transforms and the scalars are listed with the material, and the old per-layer notes are removed: they described values read from the wrong offsets.Not done