How do I enable the depth pass in a material plugin and get access to it on the shader?
In short, I want the depth value on the fragment shader, which seems to be vViewPos.z. I tried setting needDepthPrePass, but it wasn’t enough.
vViewPos.z
needDepthPrePass
My attempt in a PG: https://playground.babylonjs.com/#P8B91Z#33
You do not need a depth pass for this, you ll need to customize your vertex to add a varying and store the depth in that you would reuse from the fragment. you should not use the current pre path infra for this.
As @sebavan said. If the non linear z value is ok for you it’s easier as you simply need to read gl_FragCoord.z.
gl_FragCoord.z