- Home /
Intersection Highlight Shader
I'm trying to create a simple shader for water. The main feature I want is for the shader to change color near the intersection with other objects.
The way I have understood that this should be done is using the depth buffer. Basically, I'm trying to read the depth buffer before rendering the object, and then compare that value to the depth of the object itself. If they're close enough, then the objects are intersecting.
I'm having trouble getting the values from the depth buffer. I'm not very familiar with shaders, so I'm probably just missing something simple. I tried using the shader code found here, but I can't get it to work.
I should mention that I would prefer to use a surface shader (as I already have a surface shader with custom lighting), but a vert/frag shader would work as well.
Any help is greatly appreciated. Thanks!