[Community Project] WIP Weather & Ocean Water Shader


Reply train ahead… :stuck_out_tongue:

The problem is the positioning of the line, not the gradient.
I have not found a (cheap) way to match it exactly where the ocean plane clips the camera.

Dying Light uses a flat water plane from what I have seen which is really easy to calculate and mask (how convenient for them :p) just a straight line.
I might make a flat plane version sometime if there is enough interest.

Ya it’s nothing special… just a panning normal map with distorted uvs.
(It will be included in the update ofc.)

Anything is possible but something like this will not be easy to implement.
The article does not have any details about their implementation but essentially it’s like the fluid surface plugin (which its code is a bit too complicated for me at this point in time).

It might be a lot easier to use a projected texture mask with the shape of the hull to displace the ocean but that can not work for more than a ship or two at the same time and you won’t be able to generate kelvin wakes or anything like that that way.

I used the stencil buffer to do the half-in-half-out masking (mentioned a couple pages back) will be included in the upcoming update.

The upcoming update will be compiled for 4.10.4.
The ocean plane follows the camera which make it appear as infinite so there are no tile limits.

All things considered, the performance in the project is really good… it’s not a heavy project like the kite demo or anything :stuck_out_tongue: :stuck_out_tongue:
You could say it’s optimized for mid-range cards since I’m currently using a gtx 690 (which is like a 680 since UE4 doesn’t support SLI) so I’m trying to keep the performance at 60 fps for my card which probably translates to over twice the fps for the lucky 980 owners.

Sorry, I will only be providing 64bit windows binaries but it shouldn’t be an issue to compile for linux/mac.
However the shader is not currently compatible with opengl due to the 16 texture limitation (also no tessellation).
I am working on a “Lite” version of the shader though which should be compatible, not sure if that will make it to the upcoming update though.

Yeah, actually finding the correct line position is the part I’m not sure how to achieve, XD, that wasn’t clear. Or at least, not cheaply.

Wow with clouds and rain. Looking forward to this update. Not sure if the Linux/Mac stuff still makes much sense, thinking about the soon to arrive Vulkan support. Ships moving with wind and/or waves, also breaking waves and I’d be in heaven.

hello guys, I follow your project for months, and in addition to renew my congratulations, I have a question, others will come out short updates?



Can you give us a quick list of what will be included in the next update?

I am hoping some of the items on my short list will be fixed in the next release:

  1. The caustics should be visible when standing near shallow water, not just when under water. If I remove caustics from the Set Underwater Mode and put it in the PP Underwater volume blendables will that fix it?

  2. Need an integration of Ultra Dynamic Sky with this shader. The developer will not respond to e-mail. In the level BP, Set Underwater Mode, when using Ultra, the Ocean Wave Cue new volume will work, but the caustics and Set Intensity and Set Light Color do not, even when replacing the BP_Sky target intensity and color with an Ultra float and Linear Color to provide a new Sky Light Component. Also, tried plugging in the "Update sun’s rotation material parameter (SSS) into the “Ultra BP Set Material Variables”, can’t get that to work either.

  3. Or, add “Ultra like” clouds and shadows to the Skydome_BP.

  4. Swim and tread water animations

  5. Character buoyancy when breaking the water surface plain, so it bobs with the waves while treading or swimming.

  6. Water Line

  7. Landscape Height modulation so I can stop waves encroaching on shoreline, and add my own swash, backwash, and wet sand function

  8. Light rays integrated with the caustics during daylight hours.

  9. A blocking volume function so underwater assets “stay dry.”

  10. Function changing water color based on Z depth, like Black Flag.

Thanks for all your hard work. I understand, it is a spare time thing for you … I would gladly donate to speed things up or to get you to work on these issues … if people in the community like you do not work on this it will not get done.

I don’t think EPIC gets it. Water is a big deal today. Even Unity and Blender are way ahead of us. UE4 is the only engine without it. I don’t need an engine that support a hundred square mile level, or better looking hair for our 1st person character, or planar reflections on only Samsung mobile apps. Maybe someone at the top of EPIC needs a baptism to understand our need for good water.

This article explains the systemic problems with UE4 in a very supportive way:

One of the most beautiful games of all time, The Vanishing of Ethan Carter, was developed on UE3. But to port it over to UE4 and Playstation 4 required their 8 person team to include a full time engine programmer to fix UE4 issues. In the article they talk about the same issues you face with this ocean shader, which are systemic to EPIC’s engine roadmap for UE4:

  1. “the way screen-space reflections are culled on the sides of the screen in a trapezoid shape”

  2. “depth-unaware blending of reflection cubemaps”

  3. “translucent mesh rendering … scene colour texture resolve is done per mesh element, not per entire mesh”

  4. “lightmaps are meant to contain indirect (bounced) lighting only … they don’t have specular highlights”

The “workarounds” in this ocean shader are great, but they create a form of spaghetti code that is not easy to work with and is just one engine upgrade away from not working.

Still, no pressure TK, but this project is our only hope for realistic water.

A lot of these are still very specific implementations that TBH youll probably never see anytime soon or for free. Even commerical ocean solutions have users do some of these on their own because the implemntations are project specific.

The update is planned for tomorrow (yay?) so wait for the changelog.

Most of the things you mention are either done, being worked on or planned (not sure what you mean in #8 tho).

About the sky/clouds… it’s not something I will be working on anytime soon since ultra dynamic sky works pretty well in my personal project.
It’s not difficult to implement the update light vector function to it, I might post some instructions later.

I’m working on a skylight manager blueprint though that will blend between multiple captured cubemaps for seamless day night cycles (that one won’t make it in the update) which will also have the option to update the sun vector, all you will have to do is connect the directional light from the level.

About char. buoyancy… to do this one properly it looks like we need a custom C++ CharacterMoventComponent so don’t expect this anytime soon either (working on swim anims though).

Thanks :stuck_out_tongue:
I wouldn’t feel very comfortable profiting from this project :rolleyes:, there are multiple people who have directly contributed (DotCam, Komodoman, Handkor etc.) or indirectly.

Yeah I read that article a while ago, it really is right on point isn’t it? if Epic solves most of the issues mentioned there (translucency, reflections, anti-aliasing) then it will be hands down the perfect engine for me.

I saw that! Whats up with that? mobiles will have graphical features not available on desktop now? (especially something as important as reflections) that can’t be right :eek:.

:wink: that or a vacation trip to Hawaii might do it :stuck_out_tongue:

@TK-Master - I wonder if you couldn’t use the stencil mask you’re already doing, downsize it and blur the crud out of it to mix the colors on the hard cut, then use that resulting mixed color as a mask for doing the gradient.

You are right, I am asking for a lot, but what else can we do? Hire an engine or shader programmer? If someone wants to “set us free” then support this community ocean project.

Surly EPIC can afford to take one engineer off of “hair” duty and assign them to integrating this ocean shader plug-in into the next engine release.

Not holding my breath, already waited for eight years.

Consequently, for some of us, this project is our only solution.

I have faith in you Nsomnia, TK and the others.

I think many of these issues have already been solved, they just need to get into the next release.

Do you know of another commercial ocean solution or Marketplace ocean solution that I could use with UE4?

“Swimming and treading water,” pretty standard animations and functions for projects with water, wouldn’t you agree?

Come on, you can do it.


Thanks TK

Number 8, I would like to submerge assets underwater, such as a moon pool, as you see in Subnautica. How can I keep the PP Underwater volume effects out of the room interiors?

I can’t wait. I might just stay up all night.

A quick note on where to update the Ultra sun vector would be the cherry on top!

You deserve the ticket to Hawaii for your commitment to this project!

Props TK

Mixamo has some swimming animations I think, maybe you can use those in your project if you need something for prototyping.

Thanks, I will check it out. Hope they are full body animations.

Been skipping on game-dev and practicing my C++ lately. Cant wait to finally get my fork going, TK youre too fast.

For anyone interested in Swim annimations, I noticed an Instant Swimmable Water on the Marketplace, comes with Swimidle/Swim animations.

Watched the video, it looks like a breaststroke, and good enough for prototyping.

Has anyone tried it out yet?

The Underwater Update

The 4.10 branch is now on GitHub!

New features in 4.10:

  • Underwater post process with exponential fog
  • Stencil-based underwater masking
  • Wet lens post process
  • Landscape heightmap-based displacement modulation
  • OceanStorm example map (40 Gerstner waves)
  • Advanced BuoyantMesh component by Nubtron (thanks again!)
  • Accurate height readback by accounting for x,y displacement
  • Harpoon gun with rope physics
  • Various code improvements
  • Various shader improvements

Release notes:

-Added IslandMap.

  • Large landscape with deep underwater sections, much nicer for prototyping.
  • Includes mounted harpoon gun and breakable rope example bp.
  • Includes the new ocean material with heightmap modulation.
  • Includes the new underwater post process.

-It is now possible to add multiple Gerstner 8-wave clusters.

  • Made all the necessary C++ changes.
  • In the material side however only 1 cluster is used so you will have to add them manually, check the material in OceanStorm map for a 40-Gerstner example.

-Added BP_Underwater.

  • Toggles the wet lens effect.
  • Includes optional directional light to be used with caustics light function (it’s a bit costly to have 2 directional lights but it’s the only way I have found so far to be able to mask the caustics so they are displayed only in shallow sections and not above sea level).
  • It can optionally be used (instead of the new stencil masking) to set the location of a post process volume to match the ocean (check OceanExampleMap_01 for an example of that).
  • It can optionally be used to set the location of the swim volume to match the ocean waves (currently not working properly in multiplayer mode for clients).

-Added OceanMasking map with a opacity capsule-mask material example (hope that helps you a bit Nsomnia :p).

-Added custom .usf files to fix Gaussian DOF (found under ShaderFilesToCopy folder).

  • It reads the scene depth + custom depth, instead of just the scene depth buffer.
  • You will need to manually copy and replace the files in the engine’s shader folder (4.10\Engine\Shaders).
  • (These can cause an engine crash if used with an incompatible engine version so I recommend you backup the original files first).

And as always, a few screenshots :stuck_out_tongue:

Looks awesome! Can’t wait to update and check it out :smiley:

Awesome, you are a true Champion :smiley:

Thanks TK.

I’m starting to think as I pour though my C++ lessons and get more comfortable with it before I make the jump to the UE4 api, could we start designing some of the systems like weather in a public google doc or something? Some psuedocode and references and ideas and such.

I’m stuck on my project ATM till I can mask the water out of boats but would love to doodle with everyone on ways to acheive the project goals and I can create debug widgets all day long, my specialty.


(hope that helps you a bit Nsomnia ).

hehe checking it out as I merge everything together after backing up. 6gb of content takes a long time to backup on a hdd.

Also one question, was BP_Sky changed at all or is that DC’s baby and un-touched? I made a ton of changes to the blueprint and its a large blueprint in itself so wondering if I should merge my changes into the new one or if there ar eno changes and to keep my old one?

Edit: Just replaced my under-> above water texture sliding off the screen with your PP underwater bpUNderwater parent setup, submarine going up/under is much more beautiful.

Edit: Anyone getting a crash due to physics constraints line 71 (stay upright constraint based) I fixed it by finding the class that had the actual BuyoancyForce component on it, deleting and compiling it, re-adding and compiling int, and then compiling all child and parent classes.

Next step learn how to create a masked shape a pixel smaller than my mesh and to move and rotate with the mesh, then I can start building a ship!

You are fantastic! Thank you all