Materials: real shader names in the family table; plain alpha no longer glows; every constant in model.json (SIX-198) #262

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

@⁠holdmysocks on GitHub · 2026-11-25 12:11 UTC · original
holdmysocks:six-198-materials → master · +250 −98 · 4 files · 1 commits · merged 2026-11-25 12:22 UTC

Closes SIX-198.

Family labels

The family table in material.rs now holds each shader's real effect name, the same names sixng shader-bindings prints. A test checks every name against its hash, and checks that a family is emissive exactly when its shader is an emissive one.

Hash Shader Was Now
d9ec330c standard_alpha_inst emissive (light bulbs) alpha
5b775918 standard_anisotropy_dirt_alpha emissive (phone screens) alpha
e3ba3129 standard_alpha glass alpha
d5a93b6f standard_alpha_secmo glass alpha
db8b21bd standard_emissive_layer_alpha glass emissive
60643f2e signs_emissive_inst emissive, wrong description emissive
3a09c775 standard_emissive_layer_pxm_inst emissive, wrong description emissive

None of the first four shaders has an emissive input, so the GLB no longer gives them an emissiveFactor with the colour map as the emissive texture. The rest of the table checked out; only descriptions changed. classification now also carries shader.

What lights an emissive material

  • A material that binds emissivetex lights by that map only. If the map does not decode, the material does not light at all. Before, its colour map lit.
  • Shaders with no emissivetex keep lighting by their colour map: signs_emissive, standard_emissive, the LED strip, and emissive-layer materials that bind no emissivetex.
  • model.json, materials.json and the GLB extras record which case applies, as emissive_source (emissive_map, colour_map or none; null when the material does not light). The viewer follows it.

Constants in model.json

Every model.json material now has parameters: all of its constant values for every shader, not only four-layer. They are keyed by name, with the type from the shader archive (a scalar as a number, a vector as its components, int and bool as such), the same as in materials.json. parameters_not_read lists constants whose values lie outside the material's constant block.

These five names are added to the name dictionary, each checked against the shader archive's constant buffers: blendintensity, blendoffset, hardalphablend, grassopacity and puddleheightbias. With them, all ten constants the BeamNG mapping needs come out by name: emissiveMultiplier, BlendIntensity, BlendOffset, HardAlphaBlend, wetness, TintIntensity, GrassOpacity, PuddleHeightBias, fresnel and bumpiness.

Checked

  • Exported one model for each fixed shader, plus standard_alpha, prop_batch, prop_2lyr_batch and a four-layer ground model. The alpha shaders have no emissive in the GLB. The emissive layers light by their emissivetex. All ten constants are present by name where their shader has them.
  • cargo check --workspace --all-targets, and cargo test -p sixng-core -p sixng-gui --release, with new tests for the table, the relabelled families, the emissive source and the typed parameters.
**@⁠holdmysocks** on GitHub · 2026-11-25 12:11 UTC · [original](https://github.com/holdmysocks/SixNG/pull/262) `holdmysocks:six-198-materials` → `master` · +250 −98 · 4 files · 1 commits · merged 2026-11-25 12:22 UTC Closes SIX-198. ## Family labels The family table in `material.rs` now holds each shader's real effect name, the same names `sixng shader-bindings` prints. A test checks every name against its hash, and checks that a family is `emissive` exactly when its shader is an emissive one. | Hash | Shader | Was | Now | | -- | -- | -- | -- | | d9ec330c | standard_alpha_inst | emissive (light bulbs) | alpha | | 5b775918 | standard_anisotropy_dirt_alpha | emissive (phone screens) | alpha | | e3ba3129 | standard_alpha | glass | alpha | | d5a93b6f | standard_alpha_secmo | glass | alpha | | db8b21bd | standard_emissive_layer_alpha | glass | emissive | | 60643f2e | signs_emissive_inst | emissive, wrong description | emissive | | 3a09c775 | standard_emissive_layer_pxm_inst | emissive, wrong description | emissive | None of the first four shaders has an emissive input, so the GLB no longer gives them an `emissiveFactor` with the colour map as the emissive texture. The rest of the table checked out; only descriptions changed. `classification` now also carries `shader`. ## What lights an emissive material - A material that binds `emissivetex` lights by that map only. If the map does not decode, the material does not light at all. Before, its colour map lit. - Shaders with no `emissivetex` keep lighting by their colour map: `signs_emissive`, `standard_emissive`, the LED strip, and emissive-layer materials that bind no `emissivetex`. - model.json, materials.json and the GLB extras record which case applies, as `emissive_source` (`emissive_map`, `colour_map` or `none`; null when the material does not light). The viewer follows it. ## Constants in model.json Every model.json material now has `parameters`: all of its constant values for every shader, not only four-layer. They are keyed by name, with the type from the shader archive (a scalar as a number, a vector as its components, int and bool as such), the same as in materials.json. `parameters_not_read` lists constants whose values lie outside the material's constant block. These five names are added to the name dictionary, each checked against the shader archive's constant buffers: `blendintensity`, `blendoffset`, `hardalphablend`, `grassopacity` and `puddleheightbias`. With them, all ten constants the BeamNG mapping needs come out by name: emissiveMultiplier, BlendIntensity, BlendOffset, HardAlphaBlend, wetness, TintIntensity, GrassOpacity, PuddleHeightBias, fresnel and bumpiness. ## Checked - Exported one model for each fixed shader, plus `standard_alpha`, `prop_batch`, `prop_2lyr_batch` and a four-layer ground model. The alpha shaders have no emissive in the GLB. The emissive layers light by their `emissivetex`. All ten constants are present by name where their shader has them. - `cargo check --workspace --all-targets`, and `cargo test -p sixng-core -p sixng-gui --release`, with new tests for the table, the relabelled families, the emissive source and the typed parameters.
- The family table now holds each shader's real effect name, and a test checks
  every name against its hash. Six labels were wrong: standard_alpha_inst
  (d9ec330c) and standard_anisotropy_dirt_alpha (5b775918) were "emissive", and
  standard_alpha (e3ba3129) and standard_alpha_secmo (d5a93b6f) were "glass".
  All four are now "alpha", so the GLB no longer gives them an emissiveFactor
  with the colour map as the emissive texture. standard_emissive_layer_alpha
  (db8b21bd) is now "emissive". signs_emissive_inst and
  standard_emissive_layer_pxm_inst get correct descriptions. classification
  gains `shader`.
- An emissive material lights by its own emissivetex. If that map does not
  decode, it does not light at all, where before its colour map lit. Shaders
  with no emissivetex keep lighting by their colour map. model.json,
  materials.json and the GLB extras say which (`emissive_source`), and the
  viewer follows it.
- Every model.json material has `parameters`: all of its constant values for
  every shader, typed and keyed by name, as in materials.json, plus
  `parameters_not_read`.
- Name dictionary: blendintensity, blendoffset, hardalphablend, grassopacity
  and puddleheightbias, each checked against the shader archive's constant
  buffers.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:22:30 +00:00
github manually merged commit 9e528acb5b into gh-pr/262/base 2026-11-26 20:22:32 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.