Underwater fog, half in and half out

Hi, in my game(first person) is possible to dive underwater, I currently have created a fog (exponentialheightfog) for underwater vision that I turn on-off whether the player’s head is above or below the water.It works well but there is a serious problem when the player’s head is underwater for half, if the fog is turned off I get a bad effect underwater and correct above, if instead the fog is turned on I get an unrealistic fog above and correct below. It would be easily solved with a “box volume fog” but it seems to me that there are not in UE4. I also tried using the postvolume but I have not solved the problem, it shows the effect on the entire screen when on and not a portion of the screen while coming in it… Anyone have any ideas for solve problem? I remember problem in popular games from a few years ago (maybe even early versions of Skyrim) but then they all resolved and there are many first person games that allow you to get in and out of the water, then I am confident there is an easy way to do it …

1 Like

Tesla Dev did it way: Unreal Engine 4 Tutorial - Quick Swimmable Water - YouTube

He does’t want to know how to add a post process volume, infact he wrote:

So he want not a gradually blendable post process effect, but a “masked” post process effect

I’m not in front it now but I think you would do with some of the fog functions on the water shader

Sorry that was a useless post - I mean the depth nodes I am sure I did something based on world pos with it but I can 't find the node - if I get a I’ll see if I can find it.

While I don’t have same problem, in curious too what solution you find to turning fog off in a region. I’d love to occluded the height fog.

Me too… A solution could be extended in many ways… Like in my case for an half/underwater postprocess

I’m wondering whether or not you handle the post processing entirely on the player character, and use WorldPosition to control the transition between (given that your water is essentially planar). I’d knock up a quick test, but I’m about to go to the cinema - may try when I get back…

Thank you Crow87… i’m waiting for an answer :smiley:

(my) theoretical implementation:
Given you can draw the fog yourself
1: Define a (Clip) Plane in worldspace, facing upwards.
2: A Postprocess runs over the Screen and checks if a ScreenPixel is in front or beyond that plane
3: For each pixel which is beyond the plane calculate the desired effect

And your practical one? :rolleyes:

Use a localized Post Process . I’ve done a quick tutorial about for spherical and rectangular volumes but using a fixed point one the world z-axis is way easier.

Create your own Fog material, for the most basic setup start with something like :

That looks like a great solution to me, I will give it a try tomorrow. Thanks for & all of the great tutorials on your blog! :slight_smile:

I am gonna try that soon…Thanks

Someone has one working solution?

I know is a bit late but recently wanted to do the same and couldn’t find a solution. Did it in blueprint and post.

how it looks with super basic material and art.

blueprint that does the interesting bit

basic post material set up.
Takes the world position of the blueprint, uses its Z height for the waterline. Works out where position intersects with the camera planes highest and lowest point in the world then outputs as a float between 0 and 1.
The literal float is the near clip distance, which you can get from engine.ini or default engine depending on if it has been modified. Might not work properly if you have the game running minimized. Could do extra material set up to make work
regardless of screen size.

Thank you for fianally having a solution for .
Just wondering which engine version you are using because I cannot find the Radial Blur node in my material editor.

just made from scratch to include waves and not draw on top of a stencil

the gist of it is

A = Abs world - Z value (which isn’t world z btw, I had to hand adjust) - B Mask
B = Z value straight up
A>B = 0


connect to another if:

A = Custom Stencil - Mask R
B = Number of stencil for water
A>B = 0
A==B = 0
A<B = 1

is your Lerp Mask (between 0 Not there and 1, masked) so you plug the result of the second nested if into Lerp.
The rest is the colors of the post-process via Scene Texture input multiplications.

many thanks to** @** for the theoretical :stuck_out_tongue: