How to make a part of a single mesh fade depending on the distance of the camera?

Hello! I made a mesh of a long road that I need it farthest part not to be seen and fade away

I tried using ExponentialHeightFog but It didn’t work. Then I tried following this video:

The material works but still for some reason it doesn’t fade the farthest parts even if I change the paramaters.
I also tried Distance cull but it just didn’t work.

So I’m kinda out of ideas, I’m sorry for asking again but can someone please throw me a hint!
Thanks for taking your time reading my post!

Uv mapping and math would do it.

First you need a UV that covers the lenght of the mesh.
With that, you can map an alpha of how it should fade from 1 to 0 based on the distance from camera.

In theory, the math should automatically apply the same color value at the same diatance, so it should be all you need even with splines…

You can possibly try to use ths lightmap UV for this. But you need to check the UV orientation before you apply the math…

When UV fails you can probably straight up drive opacity out of WPO…
The math would be somerhing like
Wpo-camera = distance from camera.
Distance from camera/X as alpha to 1 to 0 lerp…

The x is probably some power of 2 value representing a length of a texture in meters or similar… try 1024/2560 as a start…

In fact, you can likely use the same exact fog math as the opacity mask input - set the material to masked and you should get what you need…

1 Like