Switch texture object based on distance

Hi everyone

I have a landscape material which is dirt. On this, I have grass foliage. I’m not a fan of flat grass ground textures. That’s why my ground material is dirt. But far away, when the grass is not rendered anymore, the landscape is of course dirt brown. Therefor my question:
How can I switch which texture is used based on distance. In distance I want the flat, green grass ground texture, close up I want it to be dirt. What makes this all much harder is that the landscape material is based on texture objects, material function call nodes and such. Because of that I cannot use texture samples - which means no nodes like “lerp” can be used. I need to stay with this landscape material solution. So is there any way to achieve this? On the screenshot you can see the blueprint and where I would like to have two different texture objects based on distance.

Thanks to everyone!

You’d be better off making that a function of your dirt material - so it fades to grass depending on the distance from camera.

Many thanks for the very fast reply. Unfortunately, I was not able to build it. I can line trace or even check the distance - but all I would know how to achieve is simply switch the material. But this would also switch the material up close. Can you maybe help me a little more and show me into the right direction? Thanks!

Something like this. You’d want to do the same thing for the Normal and other Textures as well…

Thanks! I did now like that

But still, the Material Function is not compatible with the texture object node.

Your solution has the same problem all the nodes are not compatible. The landscape material blueprint look like this (ending in result node):



The material function must have two base texture inputs, and the lerp must be performed inside the function.

I had a feeling that would happen. I don’t have that ProLandscape kit, but it’s using Material Attributes which are handy.

Change it to after the Layer Function, and use the Material Attributes rather than the texture and use “BlendMaterialAttributes” rather than Lerp. That way you don’t have to worry about normals etc too…

And just making it in photoshop, it would look something like:

1 Like

Yes! This was the solution! Thanks a lot!

2 Likes