Water Caustics

Hello everyone,

Here’s a quick tutorial on how I created a underwater caustic effect.

1 - Add in a World position node
2- then a multiple node: give “A” a value of 1 and “B” a value of 64
3- Divide those two together: “A” = World position node “B” = Multiply node
4- Plug the divide node into a component mask and mask off the red and green channels
5- Add in a Panner node and plug the mask into the coordinate connection then add a Time node and plug that into the time connection
6- Now you’ll need to find and add “Motion_4wayChaos” it’s found under “Engine Content/Functions/Engine_MaterialFunctions03/ComplexMotion”
7- Once you add that in plug your Panner into the coordinates(V2) connection
8- Create a parameter and name it “Speed” set it to 1 and plug it into the “Speed” connection
9- Add in your texture sample then convert it to a Texture Object and plug it into the Texture connection
10- Multiply all this by a parameter to control the intensity of the effect and plug it into the Emissive channel
11- Change your Material domain from “Surface” to " Light Function"
12- Add a spotlight to your scene
13- Under it’s properties turn off cast shadows
14- Then scroll down to “Light Functions” and add in your Caustics material.

Add that’s it!

I hope someone found this useful.

Caustics Texture

3 Likes

Thank you! it would be good to see an image of how it looks in a scene, do you have any you could post?

Yea would be nice :slight_smile:

Here’s a screen shot of the effect in action.

Also it might be helpful to change the “B” value of the first Multiply to a parameter so that you can adjust the scaling of the effect.

Very nice. :slight_smile:
Thank you

Very cool tutorial, I think I can need that :slight_smile:

EDIT: So basically it just pans the texture in a given direction… Wouldn’t it be more realistic to have some deforming and distortion effects? As if the water surface would be in motion? (Although Iam not sure about how to achieve that at the moment)
How does your setup look in real time?

EDIT2: Or is the Motion_4wayChaos dealing with that already?

Here’s a video of the effect in action.

[video]caustics-test - YouTube

Thanks for the tutorial, very useful for material novices such as myself. It definitely works well on flat surfaces, but I noticed that the effect stretches into thin lines along the Z axis regardless of the light’s directional angle. What can you do to make the light function work on vertical surfaces as well?

By the way, is the caustics texture free to use? It looks more natural than the one I had in my library.

Yes the texture is free to use. As far a the vertical surface problem goes, I’ll have to look into that because I honestly have not tried projecting it that way.

Week before last, before I came down with the flu, I was trying to experiment with creating fractal designs in the material editor… and while I failed miserably, I did wind up with an animated design that looked exactly like a water caustics. If I can manage to come up with it again, could we compare?

That would be great!

I’m pretty new to UE4 and i can’t find the “Motion_4wayChaos” node. I’m not even sure where to look for it

Look at step 6 :wink:

In the content browser, go to view options, check “Show engine content”, go to the path specified in step 6 and there you go.

The real question is whether or not it’s possible to create a material that applies the caustics to the geometry “below” it. I know it’s ppssible to mask out deep regions of the geometry below based on screen depth, but having caustics conform to the geometry of the water bed is obviously a different matter.

Since this is a light function, which essentially is just an animated light mask. The pattern will behave just like a light shining on the surface of the geometry.

Thanks for the tutorial.

Here is the result:

3b63636b458ca79c7b475e75608d52fcb8ff06e9.jpeg

Thanx for this man! Really saved me a tone of time.
Would it be ok if I use your Caustics Texture in a Commercial Game?

1_FishGibble_LevelTesting_Scaled.png

You’re welcome! I’m glad to help. Also it’s absolutely fine to use the texture.

Hey papptimus!

I’m loving what you’ve created here! It’s perfect for the game I’m making, and I’d love to add it to one of my levels. That being said, I can’t get it to work in my game. I followed your tutorial to the letter, and I even tried another light function tutorial with the same results, so I’m pretty sure the code is good. Whenever I apply the material to the light function slot my light doesn’t change at all, and just continues to look like a normal light. All I can figure is that I have something incorrect in the detail panel somewhere, so I’ve attached a screenshot of my current settings. My material is set to be a light function, and the light itself is set to stationary in the viewport, and to not cast static shadows. If you can shed any light in the situation (no pun intended) I’d be most appreciative. Thanks in advance!

Added the texture to my UE4 resources page :smiley:

THX for sharing this HQ texture and tut :slight_smile: