[Lite] Shader error because of self-shadowing

I played around with the shadow system of Babylon lite and noticed that self shadowing generates a shader error and the shadows look broken:

Error while parsing WGSL: :93:44 error: unresolved type 'lightsUniforms'
@group(0) @binding(1) var<uniform> lights: lightsUniforms;

That only happens when using the PBR material. The standard material works correctly.

Working playground (standard): Babylon Lite Playground
Error playground (PBR): Babylon Lite Playground

The error is gone when line 48: torus.receiveShadows = true; is removed.

Let me check that :slight_smile:

Nice one ;D

I can confirm this is a Babylon Lite PBR shader-generation bug, not a self-shadowing limitation.
The shadow pass selects a single-light shader variant whose lightsUniforms declaration was not loaded, causing the WGSL compilation error. This explains why StandardMaterial works and disabling receiveShadows avoids the issue.
I’ll fix the variant preloading logic asap!

Stay tuned!

Here we are: fix(pbr): preload self-shadow caster shader variant by deltakosh · Pull Request #579 · BabylonJS/Babylon-Lite