#9407·engine

Decide where StandardMaterial ambientSH lives once light probes exist (last value outside the material uniform buffer)

Author: mvaligurskyCreated Sep 16, 2026Updated Sep 17, 2026
Labelsenhancementarea: graphics

StandardMaterial#ambientSH is the one material value deliberately left out of the material uniform buffer after #6157 and the PRs that closed it. Every other value of a standard material lives in the buffer; the spherical harmonics still go through the scope as ambientSH[0], which on WebGPU means 144 bytes written into the per-draw mesh uniform buffer for every draw of a material that uses them.

It was left as is on purpose: per-material SH is rarely used, and light probe support (see #2484 for reflection probes) will likely change the requirements. The data may come from textures, be selected per mesh instance, or move to the scene or view level rather than the material. When probes are designed, decide where the SH data lives and move it out of the per-draw path at the same time. The options considered:

  • a presence-gated array member of the material uniform buffer (9 vec3, 144 bytes, only on materials with an SH array; presence already selects the shader's ambient source),
  • the view uniform buffer, if SH becomes a scene or camera level term,
  • a texture, if probe data is sampled.

Details for whoever does it:

  • The shader processor matches a parsed uniform by its plain name, while a uniform buffer format keys an array member as name[0], so an array member of the material buffer needs a small lookup fix in ShaderProcessorOptions.getUniformBindGroup first; otherwise the shader keeps reading the SH as a mesh uniform.
  • LitMaterial has its own ambientSH parameter that stays on the parameter path.
  • In-place edits of the Float32Array are live today because the scope holds the reference; a buffer member would compare the 27 floats in update() to keep that.