Making waves from ocean modifier smaller near the lakefront

Hi all,

I’m working on a flyover scene of some small lakes. See following image for work-in-progress.

I baked the ocean modifier for all frames and added them as a vector displacement maps, using adaptive subdivision to make the displacement.

As for the next step, I would like to make the waves on the edges of the lake smaller. In real-life, the largest waves are always in the middle and they are much smaller near the lakefront, or even absent.

So I thought that using the Ambient Occlusion node would work as a mask to scale the waves. This is a perfect mask. Black means absent waves and then it transitions to white where the waves are full scale.

But I can’t seem to get it working… Whatever I do, whatever node setup I use, the ambient occlusion map does not influence the displacement generated by the ocean modifier.

I’ve tried (edit) three approaches:

  1. Adjusting generated displacement vector by multiplying it with the AO map. In theory this should work near the shoreline, a value of 0 is generated for no waves and a value of 1 is generated in the middle of the lake. However, it does not influence the wave height at all…

  1. Adjusting the baked ocean using a MixRGB node, making the vector displacement map darker near-shore. This also doesn’t seem to work…

  1. Using Open Shading Language and a script as distance instead of Ambient Occlusion. I found this useful script here: Is there a distance-based texture for Blender? - #11 by Laserschwert Unfortunately, this doesn’t work either…

Does anybody know a solution?

Thank you in advance!!

The ambient occlusion node works a bit different from the rest of the material nodes. It’s a complex, multi-sample effect that gets calculated at the same time as the material. Maybe it would react different if you baked the AO to a texture?

1 Like

I guess it works the same for that script I found. Both use the raytracing samples as input, which means it’s done after the displacement is calculated. Hence, it does not influence the displacement map…

It does work if I add a wave texture, but of course that’s not the solution, but just checking Blender isn’t broken or something :slight_smile:

I will try to bake it out next (though the scene is 1x1km large…), but it would be best of course if it’s possible to make it in a procedural manner using nodes, so you can reuse it for new scenes.

Any other ideas?

If you have it UV unwrapped, you can combine two linear gradients with multiply to get a darker area near the middle of the plane and lighter along the edges, but it won’t follow the curvature super well :thinking: what if you used geometry nodes to get the proximity of the water to the banks, put that in a custom property or attribute, and used that in your dander nodes?

1 Like

Using Geometry Nodes works!

You can use the Geometry Proximity node and the Map Range node to calculate the distance, and store it in an attribute. Then, you can use the attribute to mask the vector displacement map, so that the wave height is zero around the edges.

Result:

Geometry Nodes:

Shader nodes for the displacement:

This is the value that the attribute outputs:

2 Likes

Yeah that looks great, nice job!

1 Like