NodeMaterial compile error when using sub surface scattering with clustered lights

Hey there!

I have been trying to use SSS inside a NodeMaterial with clustered lights but unfortunately the shader does not compile:

I think that might be a bug, or maybe there I missed a step to make it work ? :thinking:

cc @Evgeni_Popov

Thanks for the repro!

I found and fixed the Node Material compile issue when subsurface scattering is used together with clustered lights. The root cause was shader generation order: the clustered-light helper could be emitted before the subsurface-scattering declarations it depends on.

The fix is in this PR:

For the WebGPU version of the repro, make sure the Node Material snippet is loaded as WGSL, for example:

const material = await BABYLON.NodeMaterial.ParseFromSnippetAsync(
    "EPY8BV#619",
    scene,
    "",
    undefined,
    false,
    false,
    undefined,
    { shaderLanguage: BABYLON.ShaderLanguage.WGSL }
);

That keeps WebGPU on the clustered-light storage-buffer path instead of using the GLSL fallback path. The PR also fixes the WebGPU binding issue caused by texture blocks that declare texture resources but do not have textures assigned.

Thanks a lot for the fix! Can’t wait to try it :slight_smile: