Camera nearplane intersection with water plane.


Let say I have water surface in z = 0. normal = {0,0,1}
I also have perspective camera with near plane at 10cm. We can assume that camera can’t roll.
I have underwater post process effect which is used when camera is under the water. Problem is partial intersection where water plane is clipped by near plane. So I need to restrict underwater just to below that.
How can I calculate where is water surface vs near plane intersection. I need this intersection in normalized screen space.

Figure it out. It was really easy and quite cheap to do in material. And this method also support rolling camera.

Hey Jenny, that attachment was invalid, any chance you could re-upload the pic?

Very interested to see how you did it :slight_smile:

Need to wait for monday. So stay tuned.

Not sure if we used exactly the same method, but this does the same thing.

Oh nice, thanks for the link! I suppose if you did have vertex waves you could perform the same calculation and feed it the wave-part of the shader to calculate the offset from Z. If everythings in world-space that should work quite well.

This is my version of nearplane clipping.

How can i apply an water displacement to it?

You can’t use this method with displacement. You need to use somekind of stencil/custom depth method to mark pixels that are water.

pff… but if custom depth is written by multiple objects, then how could i get the water one … ?

i’ve also tested this method:

but the waves generated they just don’t match with the plane

ok… using custom stencil i can fill the water
but how do i get the near camera clip and fill what is under the front edge?