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.

Hi @Evgeni_Popov @sebavan

This issue becomes a blocker for me. I created a PR to allow WGSL in ShaderMaterial to be used for ShadowDepthWrapper. I never created PR to BJS before. Could you review and let me know if there is anything I need to add to my PR.


Thanks, I will have a look asap!

1 Like

@Evgeni_Popov Thanks for your review. I have applied suggested updates and PR rebuild has passed checks.

1 Like

Hi @Evgeni_Popov

I see you approved my PR and all the checks are green now. But I don’t have write access to merge. Is there anything else required from my side?

Other people from the team are going to review the PR and will merge it. It should happen today or tomorrow at the latest.

1 Like