[Community Project] FREE Ocean Water Shader

The code is found at the source code file: FRotator ATimeManager::CalculateMoonAngle() and FRotator ATimeManager::CalculateSunAngle() at TimeManager.cpp at the following folder “Plugins\OceanPlugin\Source\OceanPlugin\Private\Sky”, so you can check those algorithms and if you have better ones which you can contribute to the project I will make the necessary adjustments to the source code.

The Sky was a contribution to the project made long ago (2014 to be precise, I was not even using Unreal at that time), since the project is really intended to be a Ocean Project. Everything else, boats, buoys, ships, fishes are all contributions.

There is a plan for my branch on this project and bellow is what it is going to happen over the next months:

  • separate Ocean project into single plugin
  • everything else in a secondary plugin (ie: Sky, fishflock, etc)
  • plugin will be modified to allow it to be exposed to blueprint and instructions to compile it as if it was a Marketplace plugin will be added, along with Youtube video.
  • sample project will be added with the plugin outside package to show how it works (see previous item)
  • landscape modulation will check if texture is set correctly and try to change its attributes while in Editor once it is changed
  • landscape modulation will work for World Composition
  • masking water inside objects (with example meshes). You add that mesh(actor) into a list of meshes to mask
  • masking underwater inside objects. You add that mesh(actor) into a list of meshes to mask
  • masking objects underwater (with example meshes). You add that mesh(actor) into a list of meshes to mask
  • several changes into caustics, since currently you can’t remove caustics from inside objects like ships and boats
  • improvement on underwater effects to better reflect vision from camera point of view against deep water and when looking up at sky direction.
  • infinite ocean system will be remade with quadtree

The repository will receive updates per new feature added, so keep an eye in this post and Discord server for news.

Hi i want to package the project using this great plugin but i get this error when starts,

Error: System.IO.DirectoryNotFoundException: Cant find…
‘C:\Program Files\Epic Games\UE_4.21\Engine\Plugins\Runtime\OceanPlugin\Intermediate\Build\Win64\UE4\Shipping\OceanPlugin\OceanPlugin.precompiled’

is there any way to fix it?

I just packaged it successfully in 4.21. Which is the release version you are trying to package? Which branch at GitHub you picked? If you didn’t pick this one https://github.com/UE4-OceanProject/OceanProject/tree/OceanProjectNilsonLima please do.

Ohhh, i just try to compile myself using Visual Studio or UAT but i couldnt do it, thanks

One more question, how underwater effect works?, how can a configure to do the underwater blue effect?

You can watch this video for a start and understand the whole underwater settings and materials. After that you can just go inside the material and change the color as you please. There are several videos at my Youtube channel in a playlist about this asset, there are tons of information there.

Hello Nilson,

first I would like to thank you for your work and your dedication for this community project. It has really grown into something amazing, you and all the other contributors can be proud!

I recently started to use the Ocean Project and I was not able to solve a problem I have encountered, I hope you or somebody else who has experience with the Ocean Project can help me solve this:

The problem I have is that translucent and additive materials do not get rendered between the water surface and the terrain. Please find below an image where I have displayed my problem and also show the material setups for this test.

I have pinpointed the cause for this down to the “BP_Ocean”, meaning if I set “BP_Ocean” to “Invisible” or “Hidden in Game”, the materials render as expexted.

I would be glad if you could explain to me the necessary steps so that translucent and additive materials get rendered, when under water.

Thanks for your time and all the best to you!

You need to set the value for Translucency Sort Priority at the Rendering section of you mesh (the instance, not the mesh at the content browser) to have a value higher than the value in use by the ocean plane (which is currently zero). It will work for you to see the a material with translucency features to completely be rendered on top of any other translucent material. The additive material behaves like a translucency material, so the solution works for both. If you ever want to mask the material at the surface, then you will need to use stencil, but in this case stencil with lower values has priority at rendering. The stencil way is explained in the video few posts above I have use to explain how to mask the water from inside the boat.

Thanks for your quick response. Unfortunately changing the translucency sort priority did not fix my problem.

I dug a little deeper and I think the reason why translucent and additive materials are not rendered underwater (on top of the fog) is the stencil setup of the “M_Underwater_PP” material, used in “PP_Global”. Your stencil video regarding masking the surface (for boats and stuff) did not help me unfortunately, as my problem is not to “cut out” something, but render a translucent or additive material on top of the underwater fog.

I just did some experiments and make this small video. Note that one of the results where you kill completely whats behind the material, you will need to write the depth on your own inside the material to give the look you are wanting.

Hi Nilson. Thanks for your video. I think you are right regarding the additive materials, I think they look fine, it’s more the translucent materials that I would like to get working when rendered on top of the underwater fog. Here a few examples where translucency would be required:

  • Underwater Dust / Plankton Particles
  • Underwater Air Bubble Particles
  • Fake God Ray Meshes (for underwater caves for example)

I have attached a screenshot where you can see how a translucent material with enabled “Allow Custom Depth Writes” in the Material and “Custom Depth Stencil Value = 1” in the mesh instance looks like.

I thought about adding all the fog stuff from “M_Underwater_PP” to the material of my mesh, but as the material domain of “M_Underwater_PP” is “Post Process” and because it uses exclusive nodes for that material domain, I can not replicate everything I would need for my material with the domain “Surface”.

In the second image I made a mockup in photoshop to show you what I would like to achieve in the engine.

I will try some experiments and will let you know.

Thank you! Looking forward to your potential solution.

Hello,
I checked out previous pages and the old closed thread, I met with the “Lake” problem, how to create lakes instead of infinite ocean. I modified the C++ source a little bit to switch off infinite component so I got a sphere plane scaleable. After it the resize of plane works well but unfortunately near waves were broken. I tried set the parameters but there are many :slight_smile: and I dont know its fixable even with tweaking. Well, I tried the Reactive Dynamic Water asset too and though it looks good for lakes, it has very simple buoyancy and I need some boats on my lake and Ocean shader does it better with buoyancy points. Though I dont know for now which is more complicated to find out why Ocean shader waves break after rescale or adding better buoyancy to the another asset. If you have any idea how can I fix the waves without infinite component pls let me know, thx :slight_smile:

I have made this video some time ago and there I mess with the parameters that you use to make the water calm as a lake if you need to.

Thanks but the wave calmness is just my 2nd problem :slight_smile:
With infinite component ON, the lake “floods” my entire landscape, I would like small lakes on certain locations. (an area what a plane cuts to landscape). My landscape is mixed from various ones, and I have a desert lowland, which is completely filled with ocean with infinite component.
But seems the correct waves requires infinite component tick where it rescales and relocates the plane.
Why I dont use another asset for lake? :slight_smile: Simply, because its the best, plus I didnt find similar properly working solution for buoyancy for objects more than a sphere or box.

Okay I think with plane scale 1.0 Im getting waves without problem with infinity component OFF. Though its too big, but manageable with some landscape sculpting. (Scales smaller than 1.0 seems break the waves.)
Thanks for the wave tweak video, I continue now with that.
Buoyancy works wonderfully. I added a canoe to my lake with 8 test points and its very nice.
(Except water inside boat… Btw any idea how to get water out from boats inside? :slight_smile: )

You gotta get good amount of vertices at that whole plane to make the waves good enough. Since you have a landscape done, you can make one shape which is fit for the water placement, it doesn’t need to be a circle, thou it is easier to do one.

The water out of the boat I am working on it, but it is not easy and right now I am with hands full from doing other stuff. But it is on the plan.

Unfortunately if I change ocean top plane to any other mesh, Im getting large holes… :frowning:
Scaling the plane still gives weird results like triangular waves… (though as I tweaked them to smaller waves not just disturbing, but they are still there)