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.
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?
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.
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?
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.
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!