Tidal Water Foam

I have a pretty nice shader going for a large lake in my scene, but I can’t figure out how to have foam appear at the edges. is killing the look. Is there a certain material node that can put textures on the edge of my material? Thanks!

Hey Allen,

There are a few ways of creating effect depending on how the lake is set up.

The simplest approach would be to paint on a foam texture, the Vehicle Game example project uses for it’s lake and responded on thread explaining how it was done.

Is your material translucent? If so I can provide an example of how I went about in my material as well, but it will not work with an Opaque material.

Thanks for the reply. Yes, it is reflective. Painting is fine, but is there another way to have foam on the edges via material node? If not, totally fine, just wondering. Also, my transparent material is not reflecting well at all. Any idea how to do both? Thanks again!

There is no single node to do , however an automatic approach to adding foam around the edge of the (translucent only! will not work with opaque) water surface is by using a DepthFade node like (see image 1). outputs the results shown in image 2.

To make work with your own material, you want to replace the Red color lerp input (in the first image) with your foam texture. The second lerp & DepthFade is not necessary, but allows you to use a second foam texture to help blend even further (replace the Green color lerp input). Your original water material nodes would be plugged in to the first lerp where the blue color is connected.

Using technique I get the results shown in the final image (which it won’t let me post, giving me a database error… will upload it when I can). The reflection you mention is the real problem with using a translucent water shader at the moment, but is something Epic has said will be addressed in future updates by implementing Forward Rendering + Planar Reflections for translucent surfaces. Increasing the specular (to 1) and the metallic (to like 0.35) with a SkyLight present in the level will give you some basic sky color reflections, but to go further you would want to use a ReflectionVector node with a cubemap (either created live with a SceneCaptureCube, or texture) but it depends on your level setup. Also make sure you use TLM_Surface in the translucency settings of the material.

You can download the project linked below in my signature if you want to play around with , I left in the reflection vector node mentioned above for reference.

Excellent idea .

Nice idea , almost solved one of my problems also!:slight_smile: I need to check how is working!

One thing to bear in mind is that using Depth based technique, you don’t get any foam unless the pixels of the intersecting object shares the same screen space as the water object. You can see the problem that occurs looking at the image below.

ShoreBlend2.jpg

also means that as you get closer to a top-down perspective, your foam will start to disappear. There is a way around that though. If you’re water doesn’t move very much and you don’t want the effect to be dynamic, you can export your scene as an .OBJ into a modelling program (though I use Houdini for process), and create an intersection mask. You can then apply grayscale mask texture to the entire ocean object, and the foam will always appear no matter what your viewing angle.

Yeah is the big problem with approach, I’m testing out some ideas for a better method at the moment as my water moves quite a bit, so far without any luck. It looks just fine for a shore foam (especially from a distance) however objects placed in the water get the hard edges as you pointed out, breaking the illusion.

Do you have any ideas for an ocean with more movement? I would like to stay away from vertex paint if possible, an automated approach would be ideal if it can be done. Thanks ! :smiley:

BTW: Allen, I finally got image to upload, is what it looks like:

there’s an easier way to fix the problem of top-down perspective: you modify the ‘spreading’ values of your foam based on the camera vector looking down. I came up with fix a while ago and works wonders for the case of camera going top-down.
for the foam disappearing ‘behind’ the rock instead of going around it, I’m afraid there’s no better way at the moment. eventually I’d like to research capturing the sea from a top-down view and blurring the contact outlines, but it might be expensive to do as well

hi there - texture looks great, i would love to use it for a personal project - is it available per ?

I believe is from 's community project: WIP Weather & Ocean Water Shader

Y’know, is pretty much the perfect use case for the new distance field sampling node.

When the distance field reports the ocean is within a few meters of the environment, start blending in the foam.

Yup, I was thinking the same thing zalo, it’d be great for clouds going through mountains and tall buildings as well.

It samples from distance fields which is the only, if you’re landscape or whatever the water is brushing up against doesn’t have a distance field, you get nout.

Works Like a charm. Here.

Here is with Ocean Shader implemented.

i tried a few times. Its not working at all.
Can you make a tutorial?

That looks amazing!

4.12 has landscape distance fields supported so that will work now. You’ll probably want to remap the distance values though.

“Final” Result