Calculating where an object hits the camera? Gerstner waves and underwater post processing

I have a water material complete with 11 gerstner waves and my question is, how can I calculate where the water is hitting the camera, and from that point down, play a post processing effect while the top half is still rendering the un-post processed world? I’ve tried simply enabling the post process once the camera collides with the water level at a certain point, but the problem is that it consumes the whole screen, popping in and out rapidly as the waves hit the camera.

The effect would be similar to the one found in Rust. Picture for reference of the desired effect.

you have to compute the collision line in screenspace and “mask” where the effect applies.

sketch of it… be aware if you wanna fancy it up you can add the camera rotation. that allows for swivel and tilt motion and visuals.

sketch

and ofc you can add procedural waves in screen space.

Thanks for the response! Where would I start exactly with computing the collision line in screen space? You don’t have to go super in depth just some pointers would help.

You would create a niagara system, that does one simulation stage, where it writes out data to a 1d render target, 1xScreenWidth in pixels.

For each pixel, using camera data interface, perform a raycast, starting at top left corner of camera near plane, directed in camera down direction. Write out a distance to the water surface to a render target.

Then in in post process material, sample this texture, and check if pixel is below or above stored distance.

Raycast against sum of gerstner waves typically involves sampling horizontal displacement, moving in its negative direction, repeating the process several times and only sampling height at final position.

I’m having some trouble understanding quite what you mean. What would I be simulating in the niagara system, and how would I achieve a 1d render target? I’ve used 2d render targets a little, but I was unaware of 1d render targets. Also where would I be performing the raycast? Inside of the BP that contains my desired camera, such as my character? I’m sorry if I’m being dense I’m just a bit lost.