Under water / above water split view, is this possible?


I was wondering if anyone knows of some way to split post process effects over two halfs of your camera. I’ve been watching the new fluid simultations videos on the community hub and everytime they showcase water they have this insanely beautiful transition where your camera is at some point showing above water and the lower half is showing the underwater. They seem to have two seperate post process effects active and have them split by a mesh. This looks really really cool and I would kill (not really lol) to get this effect in my game project (signature).

Here is a screenshot I took from the fluid simulation by render target video.

Oh Unreal lords, please share your knowledge. I just need to have this in my project. xD

Cheers. :slight_smile:

EDIT: Waaiiit a min… Are they using a atmospheric fog for this? And just setting the altitude value at exactly the height of the water surface? Meaning it’s fake? Please tell me I’m wrong. Tell me there is some magical trick to do this. :smiley:

I did that material by using the world position of the near clip plane. Since doing screenpos-> transform caused a crash I had to create a custom node to do it. I have an image from my twitter feed where somebody asked this same question:


Note that the 10 is hardcoded to match the default near clip plane. In VR editor the near clip plane changes based on world to meters scale. There is a way to access the frame’s actual near clip if you need that but I will have to search for it later.

No atmospheric fog. Just manual shader fog using scene depth.

Thanks for answering yourself Ryan. I kind of semi-understand your approach. Not entirely sure how the near clipping planes gives you the water surface and how you apply a fog beneath it though. Or did you just hardcode it at a certain height? Which would mean it will not work at all with displaced water?

It gives you the world position to then access anything else you need. The start is to subtract the water Z, and then you add whatever displacement. You can map a world aligned texture to the world position of the screenpos and then use the result to offset the water Z. Then you have a black and white mask to blend between whatever you end up doing underwater and the raw SceneTexture for above water.

Sweet. I will definitely give this a try. I hope to God I can make it work. Would be so awesome. Thanks for the info! :slight_smile:

Hey, I have a slightly off-topic question:
Ryan, you helped me earlier with the underwater fog. Which was really nice.
However, Translucent sprites (Bubbles for example) that are near are occluded by this Fog. Is there a possibility to avoid this?

Normal fog and transparency works in this order. Opaque -> Fog -> Transparents with vertex fog.
So you just need to make sure that bubbles are rendered after water and then you need to reapply water fog to your bubbles at material level.

Are you guys going to share any material from gdc presentations? :slight_smile: It would be very very nice to have! Thanks!

I have been preparing it, but it has been going a bit slower than I expected. The main reason is that I am using some of this stuff in various game branches now and my changes I make there are not backwards compatible with the 4.14 version I am also polishing before release. So every few days I have to go back to the 4.14 version and redo my changes there. I still have materials to clean up but so far this is what the plugin is looking like:


The caustics stuff will be a lot harder to separate out so that will probably come much later.

Originally I was going to break this into 4 or 5 separate packs, but it has turned out many of the functions are re-used across them all so I think I am just going to group them together like above. Might name it something more general like ShaderBits GDC Pack 1 or something.

The Fog is a post Process though

Wow!! thank you so much!!!

Post process effect can be rendered before transparent.

Got it. Thanks :slight_smile:

Well, where can i download it ?

If you read my post, I was pretty clear that I am still preparing it and its a lot of work. Sometime in the next week or two is my goal.

Sorry, my English is not good! Anyway, thanks your reply

Awesome that you’re putting this together. Have these been released yet? If so where can they be (or will they be in the future) downloadable from? Thanks.

Would It be possible to have a screen grab of the material since it’s not in the GDC package.


This is what I’ve got so far but I don’t know how to setup a Blueprint that would automatically input the world position of the water plane and can’t figure out how to make the water line follow the mesh of the water plane.

Finally I don’t know why I didn’t figure this out yesterday but no need for a complicated pp here’s the solution if anyone was wondering. Thanks to Ryan.

That will work for basic tranlucency, but for the extinction you really want to multiply the scene color by the extinction color. I originally was doing that via a mesh material as above, but the engineers have reworked the translucency as of ~4.16 so that scene texture does not include any other translucency in it which makes modulative effects tricky. That is why I have suggested it as a post process but either can work depending on what you need.

To get the PP working, you just need to sample your displacement using the same screen to worldposition function and offset the Z of the result by whatever your wave displacement is.