ShadowDepthWrapper error with WGSL shader syntax


I am facing an error with ShadowDepthWrapper when my vertex and fragment shader are written in WGSL. The code works fine without ShadowDepthWrapper. But adding shadowDepthWrapper causes GLSL compilation error.

I am able to reproduce the error in a PG. The same error is thrown with empty main() function in WGSL syntax in dev console.

I think I know the root cause.

Even if I set parameter doNotInjectCode: true, babylon.js still injects this line into WSGL code: precision highp float;

This line seems to cause the error Tint WGSL reader failure: :20:1 error: unexpected token.

I debugged into this a bit and it looks like this is not implemented for WebGPU, yet. @Evgeni_Popov will know more about this than me, though.

1 Like

Indeed, ShadowDepthWrapper does not currently support custom WGSL shaders.

It’s not in our top priorities, but if someone wants to contribute we are all for it!

1 Like

Hi @Evgeni_Popov @docEdub

Thanks for looking into this. I most likely need customized version of vertex shaders for the shadow depth wrappers. And fragment shader for shadow is pretty much empty anyway. I can live with GLSL for now.