Repository navigation
fix: Declare the dynamic refraction resources in the lit shader - #9691
Conversation
The lit shader's dynamic refraction reads the scene color map, screen_size and (GLSL) matrix_viewProjection, but only the StandardMaterial declarations declared them, so a LitMaterial with dynamic refraction failed to compile. Move the declarations into the lit forward declarations and remove the unused WGSL private matrix_viewProjection.
Build size reportThis PR changes the size of the minified bundles.
|
mvaligursky
left a comment
There was a problem hiding this comment.
Automated PR review by Codex (OpenAI AI agent), posted through the account holder's authorized automated review process.
Reviewed the full diff at a2c081921afdb9bb2509499d9e0b7f27fc8ab92a. No actionable findings. Moving the resource declarations into the shared forward-lit declarations fixes the front-end dependency at its source. The existing feature guards are preserved, and the removed WGSL private matrix was unused: dynamic refraction reads the view-buffer matrix instead. No public API changes or additional render-loop work were introduced.
Validation:
- Reproduced the baseline LitMaterial failure on WebGL2 (
uSceneColorMapundeclared) and WebGPU (cannot use address space 'uniform' as valueatuniform.screen_size). The PR compiles and renders successfully on both backends, including dynamic refraction, dispersion, and refraction combined with iridescence/clearcoat; no GPU validation errors or unset-uniform warnings remained in the configured tests. - StandardMaterial byte-exact comparison: 0 / 294,912 differing pixels on WebGPU and 0 / 294,912 on WebGL2. Repeated baselines were also identical. Covered non-refractive, dynamic-refraction, dispersion and combined-feature materials at two camera poses plus a motion phase.
- Unit suite: 3,971 passing, 28 pending. Changed-file lint, debug/release ESM builds, declaration build and consumer type tests passed; GitHub CI is green.
Non-blocking testing suggestion: add a permanent regression test with both LitMaterial.hasRefraction and LitMaterial.dynamicRefraction enabled. The existing LitMaterial dispersion test does not enable that branch, so it would not catch these missing declarations returning.
A
LitMaterialwith dynamic refraction failed to compile on both WebGL2 and WebGPU. The lit shader's dynamic refraction code reads the scene color map,screen_sizeand, in GLSL,matrix_viewProjection. The lit shader enables their declarations withLIT_SCENE_COLOR,LIT_SCREEN_SIZEandLIT_TRANSFORMS, but only theStandardMaterialdeclarations declared them, so other front ends left them undeclared. On WebGPU the shader failed with "cannot use address space 'uniform' as value" atuniform.screen_size.Changes:
screen_sizeand GLSLmatrix_viewProjectiondeclarations move from theStandardMaterialdeclarations into the lit shader's forward declarations, next to the code that reads them.var<private> matrix_viewProjectionis removed, as the WGSL refraction readsuniform.matrix_viewProjectionfrom the view uniform buffer.StandardMaterialshaders are unchanged, apart from where these declarations sit in the source.