Fix a Toon Water with new Playcanvas Version

Good morning, I have started studying how to create custom shaders in Playcanvas and it is a very powerful framework.

I started from [PlayCanvas 3D HTML5 Game Engine] project and tried to fix the issue of changing the version of uDepthMap to uSceneDepthMap using pc.shaderChunks.screenDepthPS to reconstruct the logic of the foam lines in the water.

I am encountering problems in my shader because the error

Shader [Shader Id 3 WaterToon-proc] requires texture sampler [uSceneDepthMap] which has not been set, while rendering [Pass:RenderPassForward | Camera | World(OPAQUE) | Node: Untitled | Material: DynamicWater_Material | Untitled]

is reported during pre-loading script but then the shader does not seem to work.

Checking the camera’s requestSceneDepthMap property in CameraCompinent, it is activated, but non work.

My public project is and I am seeking assistance to better understand my error.

Thank you.

Just a guess. But the scene color / depth map is done inside the Depth layer.
Which means you can use shaders that use it only in the layer after the depth.
So make sure that is the case. For example if your material is transparent, it would be in the World Transparent layer after the Depth so all is good, but if it’s not transparent, it would render inside World Opaque layer, and cannot use the depth map.