Use _CameraDepthTexture for objects rendered by Graphics.DrawMeshInstancedIndirect

Hey, someone else has the exact problem like me. I’m using DrawMeshInstancedIndirect and need to sample depth in my shader. _CameraDepthTexture seems to be blank though. Are the rules different when using DrawMeshInstancedIndirect since it uses compute shaders? I know how to sample depth in a normal shader.

https://www.reddit.com/r/Unity3D/comments/yyifvl/im_using_drawmeshinstancedindirect_and_need_to/

My water voxels are rendered by Graphics.DrawMeshInstancedIndirect and I would like to sample _CameraDepthTexture in the shader.
For regular standard meshes (like the sphere below), it is OK.

9438164--1323791--upload_2023-10-29_14-4-10.png

I’ve been struggling with this exact issue too. I’m assuming you’re in URP or HDRP, so if not, then this post is worthless to you.

The guide below actually helped me get close to where I needed to be, but only to the point I realized it wasn’t even what I needed.

https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@11.0/manual/writing-shaders-urp-reconstruct-world-position.html

No, I am in built-in standard pipeline and forward rendering.

It is worth mentioning that screen point is OK and calculated correctly. I have colorized it

So am I, when learning https://github.com/GarrettGunnell/Grass project, I noticed something with grass is wrong