Is it possible to get the grab pass data in vertex shader ?

Hi

I need to do the depth based calculation that is posted below (for Fragment shader) in the vertex shader

half depth = SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.screenPos));

depth = LinearEyeDepth(depth);

Is that possible ?

The goal is to modulate vertices based on their distance to the terrain/objects below them.

Thanks

Interesting topic … some ideas
=> Not sure if unity build-in “_CameraDepthTexture” available in vertex shader. If it is a general texture, it should be available on graphics card which support VTF ( Vertex Texture Fetch ).
=> Another possible solution for your demand. How about calculate the distance on CPU side and then pass to GPU as a vertex shader input attribute ?

1 Like

Thanks for the suggestions.

I did the rendertexture idea, i now render depth to a rendertexture of my terrain and pass it to vertex shader to mudulate the waves.

I am mainly looking to see if i was missing a straight way to get that depth below the vertex directly inside the shader, from the main or maybe another camera view as well. That would be more efficient than using the rendertextures and the main reason why i thought it might be possible is because of the already possible depth test in fragment shader, so i will test the idea of using the _CameraDepthTexture as well.