Tree leaves disappear in distance

Hi, during the creation of my scene in Unreal Engine, I imported my tree which was perfectly fine and nothing was missing, but the moment I textured it and flew the camera a little further I found that the leaves were disappearing due to the distance I was looking for all over the forums and nothing helped me. But I found that the error was in the Opacity Mask. And since I was already desperate, I didn’t know what to do, but before that I tried to change one setting, which surprisingly worked.

Here is what work for me:
You have to go to your material (leaves) then click on Opacity Mask and on the left just below the material preview you have to find (Material Expression Texture Sample) there you will have 5 settings:

MipValueMode = MipLevel(absolute, 0 is full resolution)
Sampler Source = From texture asstes
Automatic View = Checked
Const Coordinate = 0
Const Mip Value = 0

Hope it helps :Dd

1 Like

I strongly recommend against setting the MIP value to always render at the largest level. This will make performance absolutely tank when you have more objects in the scene.

Instead, generate the MIP maps such that they work correctly with your asset. If the default MIP filtering ends up cutting out too many pixels, make the MIP levels have more opacity.

Or, perhaps better, use blending (translucency) instead of opacity mask. (Yes, this means you have to worry about sorting triangles. Nothing is free!)

Hi, thank you for your reply, yes I am aware that this will cause a load on the GUP and CPU. However, the problem is that this is the only setting that works for me. I don’t know if it’s a bug or I missed something. I tried basically everything I could find on the internet. Fortunately, the project I’m working on is only for a scene that will be rendered afterwards, it’s not a game that would require a lot of optimization.

As I said: the problem is likely that your cut-out (masking) mode and the alpha values in your texture don’t agree. This has been a common problem for foliage (and fences!) for graphics in the distance for a long time, in all game engines.
The solutions available are typically:

  1. Use FSAA and 8x samples or better
  2. Create MIP maps explicitly, with the alpha values set to not mask out too many pixels further away
  3. Use translucent/blended instead of masked/cut-out blending mode

Reducing the opacity mask clip value in the material down to 0.3(or lower, depending on the padding of your albedo) from 0.333 can also help.

Sharpening the mips(in the texture window) will help a ton as well. Tthat’s my go-to for just about everything to avoid things getting muddy.

You missed the most important part…

  1. don’t be lazy and create light maps that use pixel corners so that mips just automatically always work…

Around 90% of marketplace stuff lacks this very basic Best Practice…
(at least they won’t accept your stuff if you don’t use power of 2 textures! XD)

And - because say you rendered hair out of blender, the opacity mask on that will never be right anyway - You can always bump mips up or down at the material level without forcing the highest possible.

PS:
Anyone reading this and wondering wtf do lightmaps have to do with anything.
You’d be right. This applies to any UV.
In this case, the one you use to bake from an actual object to a transparency map - On top of lightmaps…

If you want to be OCD about this, you place each UV corner in the center of an 8x8 pixel square. E g, if your DCC tool has an 8x8 grid when mapping UVs, each UV corner should be exactly in the center of each of those. This will give you three MIP levels of “crisp” filtering before you start blending with other nearby charts.

1 Like

Hey, I had that problem and could solve it by enabling the “Preserve area” property under the Nanite settings on each mesh. Hope it helps!

1 Like

I solved it by changing the Mip Gen Settings for leaf textures to either Unfiltered or Angular (depending on the leaf).

2 Likes

Thanks, that helped me too!