I am trying to write a shader using the refract pass that compares the depth at a given screen position with the depth at the same screen position from the previous passes. The goal being that I find the difference in depth between the object I am rendering and all others in the scene. Currently, this is what I am trying to do.
//this retrieves the previous depth at location
texture2D(sDepthBuffer, vScreenPos.xy).r;
//this retrieves the depth at the current fragment (this is done in the vertex and interpolated to the fragment)
GetDepth(gl_Position);
Perhaps this is not the correct way to achieve this. Could someone point me in the right direction? Thanks!
That would make sense, given that OpenGL does not allow buffers to written to and read in the same pass. Could you show me how I would structure a render path or technique to accomplish this? I still don’t quite understand how shaders/materials/render paths/techniques work together.