I have a screen effect for when the camera is underwater. If the camera is positioned in such a way that the waterline passes through the center of the view I would like the effect to only apply to the area underneath the waterline, though I’m not sure how to approach this problem.
My current water effect has a few components to it while underwater. The waters surface is drawn. It writes to the stencil buffer as it is drawn. Then when the screen space water effect is drawn it does not draw wherever the stencil has been written to. This is important for making the waters surface look as is intended.
I suppose one solution might be to make an invisible mesh descending from the edges of the water, capped off, that writes to the stencil as well, and then the underwater effect can only be drawn if it both fails a test with the water surface and succeeds a test with the additional mesh, but I worry about how multiple volumes might interfere with each other and I wonder if there is a better way.
This must be a problem others have encountered, so rather than continuing to try and find my own solution I was wondering if anyone has any insight into what a standard approach to this might be.
Example in my game. Underwater effect is succesfully applied to underwater portions and culled from the waters surface, but comes with the undesired effect of drawing above water as well.
Example in Fortnite, someones figured it out