Animated procedural stylized water ripple in Cycles material

I'm trying to find out how to create a procedural material that creates an animated diffuse ripple around any intersection or 'edge'.

e.g. cube lands on water surface, edge of water touching the side of a pot, etc.

On the top right of the picture below is a quick breakdown of a few of the elements.

1. A thick inner 'ring' ripple that wraps around the cube.
2. A thinner outer ring.
3. The foam at the edge of the water.

I'm not a math wizard, so I kinda followed a thread and got this node setup:

I hope I understood and got the description for the nodes right. Here's the result:

A few problems come up here.

1. Is there a way to 'distort' the circle into a wavy ripple around the cube as shown in the breakdown?

2. The ripples don't follow the shape of the cube since it's calculating from the origin point.

For problem #1, I'm thinking of using #noise.random() to generate random values which then goes into a sine math node but I have no idea how to make it only affect the edge of the circle.

For problem #2, I believe that I'll have to start over and use a different approach but before I do that, I'm hoping that there's someone here that knows where to go from here.

I did try to tinker with dynamic paint but it doesn't work with fluid sim. It outputs an error saying no UV data is found.

I don't want to ask too much, so if there's a solution just for making the circle 'distort' around the cube over time, that would be good enough. Thanks in advanced.

Cheers.

• Here is the thread that I mentioned in the post: blender.stackexchange.com/questions/26388/… Oct 14, 2017 at 5:18
• I don't think there is any way to achieve #2, at least not automatically. You can't access shape information, or geometry intersections from inside Cycles shaders as far as I know. You would have to manually define a "square shaped ripple". Have you looked into Dynamic Paint feature? Not sure if it is an option for you, but may greatly simplify your workflow. Oct 14, 2017 at 18:36
• Can you post a .blend file? Oct 14, 2017 at 21:25
• @DuarteFarrajotaRamos Since you suggested it, I looked deeper into the features and oo la la it can actually paint vertex weight. It solves problem #2 elegantly. I'll update the post about it later. Oct 15, 2017 at 5:36
• @ScottMilner Sure. Thanks for the link! I was looking for a place to upload the .blend file. Links to it should be in the post now. You have to bake the fluid sim yourself if you want to test it with the fluid animation but it shouldn't take long at that resolution. Oct 15, 2017 at 5:39

Distorting The Circle

I did some more experimenting and I got like a 50% success in distorting the circle.

I added 2 cross product nodes and 1 normalize node to screw around with the x y z values before plugging it into the multiply nodes which are now in the 'circles' node group.

The theory: The 'circle' node group draws an infinite amount of n unit lines from the origin of the cube, creating a sphere with a radius of n units. Where the sphere intersects the fluid, a circle of diffuse material appears on the fluid.

To achieve the distortion, a relative IRL suggests that I randomize the radius of the sphere by jumbling up the x y z location data of the cube. It should be able to mess up the radius enough to make a wavy looking circle. I used cross product because it was the one that came close to the desired result.

I wish I could explain this better, but then again, I'm no math wiz.

It looks close but when I render out the animation...

I got electricity instead. Coooooooooool but still not what my project team needs.

Aside from how it looks like electricity, it still doesn't hug around the cube as much as it should and there's very limited controls on how much it spreads out.

Trying Out Dynamic Paint

I never considered trying out the vertex format but as suggested, I looked deeper into what it does and it works like a charm for problem #2. The setup is shown below.

The node setup doesn't look like a nightmare anymore. Thanks, Duarte!

This is still an incomplete answer. I might update this answer as I find out more stuff. Feel free to add on top of this or come up with a better solution altogether.

What's Next: How to make the distortion behave properly (or find something else that behaves properly) and hopefully, apply that on top of the dynamic paint.

.blend file with the electric ripple thing:

.blend file with dynamic paint: