Affecting the texture of my lake according to "depth"

I’ve made a lake using a plane with a Solidify modifier. For texturing I’m using a mix of Glass and Glossy for the surface and Scatter and Absorption for the volume.

Rather than a procedural texture for the movement, I’m using a displace modifier so that the water moves against the shoreline. Here’s an example:

As can be seen from the video, the problem is that along the shoreline, the water looks more like oil because of the glossiness and lack of transparency. So I’d like to find a way to factor the mix shader, saturation, value etc. all according to the apparent “depth” of the water.

But of course the water is really all the same depth!

So I can see basically two choices:

  1. Get a measurement of the distance between each vertex of the water and the nearest vertex of the landscape its sitting in. In this thread ( there are two methods shown of using distance between objects to affect materials nodes; however I’d like to know if it’s possible to get that information per vertex.

  2. Change my water object to a cube and actually shape it to sit in the landscape using a Shrinkwrap modifier. Then I should be able to use a Fresnel input to at least make the water clearer nearer the edges.

The first option, if it’s possible, should be more realistic. There are some parts where there is a very steep drop into the water, while others are more gentle, so simply making the water clearer at the edges is very much a fallback option.

So my question is: Is there a way to use Drivers, Texture Coordinates or something else to get per vertex distance information?

Well this is turning out to be a lot easier, and more straightforward, than I expected. I’ve only tried this in my “lab layer” so far, but the effect is basically what I was after. All I had to do was create a height-map of my “lake bed”. Then use that as the factor to control the relative strength of the nodes.

Here is a screenshot of my experiment. The bottom left pane shows the two indentations I made in the bed. The top right, the resulting height-map, and the bottom right the “lake”, with relatively clear water in the shallows but darkening in the deeper parts.

As can be seen from the node setup, there are no volume shaders yet, so after adding them, the water should look pretty real.

I’ll update again when I’ve applied this to my scene.

I’m still getting a feel for how the various controls interact with each other, but the results are encouraging so far. In fact I decided to remodel the lake bed before tweaking the material any further.

Here is a before/after comparison.

No height-map:

With height-map:

Note how much clearer the water is in the shallows directly in front of the camera.

Here’s my current node set-up. I may add a Volume Scatter node back in eventually, but I had to simplify to get my head around the controls.

It’s probably worth noting that the landscape is baked, so the colours tend to be a lot darker, with higher saturation than they would be otherwise.

But - using PBR models, and given that water is pretty much the same whatever the depth, you shouldn’t need a height control. If you have the water texture correct, it will work naturally.

EDIT: This worked well for me for a stream.

Roken, he’s doing a variable ripple across the surface. The deeper parts of the water have different properties than the shallower parts.

Thanks Roken and SterlingRoth for the responses. Roken’s example setup is a bit more refined, but not too different in principal from what I started with, which was based on the tutorial at:

Once animated, it looked strange that no matter how strong the wave effect, the water remained static against the banks, so I stripped the material of the wave and noise textures and moved them to a displace modifier.

I do agree with Roken that: “If you have the water texture correct, it will work naturally,” and noticed that increasing the density of the Volume Absorption node helped a lot. One problem with the height-map on the surface texture is parallax error. When viewed from an angle, the darker water does not appear exactly above the deeper parts of the lake.

So I will experiment to see if I can get the effect I’m after purely through volume nodes.

So glad that I tried playing with the volume shaders!

I re-added the Volume Scatter node, and spent quite a bit of time just playing with that and the Volume Absorption node without any surface shaders plugged in. Unfortunately, once the surface shaders came back in, I had to really crank up the volume shaders so my careful tweaking went out the window. :frowning:

However, buy that time, I’d worked out how they interact and what they can do together so it wasn’t wasted time.

Apart from that, I took another couple of ideas from Roken’s setup - I replaced the Glass BSDF with Refraction, and changed the colours of the surface shaders to white, so that all the colour is now coming from the volume shaders.

What I really like about this setup is that each control is specific, so if I don’t like something, I have a pretty good idea of what to adjust.

I did keep the height-map, but only to factor the Glossy and Refraction nodes so that there’s little reflection in the shallows.

Here’s the current setup:

And here’s a couple of samples. The first is with calm water (i.e. the Displace modifier turned down):

And with the water a lot choppier:

Next test is to retry the animation.

Just to tie up this thread, here is the video test of the water with the new texture:

It’s certainly an improvement over the first one, although it can still do with some tweaking.

Thanks especially to Roken for the advice. Even though I cherry-picked his material setup, the phrase: “If you have the water texture correct, it will work naturally,” really helped to crystallise misgivings I had with the path I was heading in.