LOD CrossFade Shader in URP

Hello,
I wanted to make some optimizations on my game and i tried LOD Group and it work perfectly, i gained 5-10 FPS.
Just a detail, it’s too obvious when the object disapear immediatly when culled, so i read about crossfade effect.
But i haven’t found an easy way to do it without replacing all the shaders i use, and even the documentation is not very detailed about how implement it in URP.
I’m new at shader so i prefer to don’t write custom shader and replace one by one all my materials with textures already associated.

Is there any way to simply “Upgrade” the standart URP shaders to take in account the crossfade with an alpha blending or something like that ?

And if not it could be very generous that feature is added to the URP Package :wink: .

Bump, nobody know how to do it ?

Have you played with this settings? It works for me.
6204984--681363--upload_2020-8-14_20-37-30.png
If this kind of fadings don’t work, maybe the LOD objects are too diferent.

Unfortunately it would come down to creating a custom shader that performs dithering based on the LOD fade value (unity_LODFade.x) passed by the LOD group. The default URP shaders don’t incorporate this, assuming because none of the default features (except SpeedTree) use this, so it isn’t on anyone’s rader.

The Boat Attack demo includes a LOD crossfade shader you can look into.

6205050–681378–OneDrive-2020-08-14.zip (67.2 KB)

3 Likes

@Kibelon It need object ? And when it culled completely ? I’m a bit more radical and removing some renderers so maybe because of that it’s not working.

6214223--683081--upload_2020-8-17_17-46-59.png

Thank you very much @StaggartCreations , i will try to incorporate the node in a custom shadergraph, but it need the renderer component to be on the same object than LOD group or not ?

EDIT : With this sub graph nothing happened, even with transparent it’s not working.

Well. After some digging, I’ve found a solution.Staggart Creations was actually pretty helpful.
To implement cross-fade you need to make your own shader, but you can use shadergraph. It’s pretty easy.
Add this to your shader:


And in the custom function add this

if(unity_LODFade.x > 0){
fadeValue = unity_LODFade.x;
}
else{
fadeValue = 1;
}

The random noise is to get a dithering effect.
Sadly, the exiting LOD still pops for some reason. The Unity team will have to answer that. But in your case it should work perfectly.

Also, I see in your picture the fade transition width is 0. This value is the distance width the fade out occurs. So it should be > 0.

Now all the fading in my game will be better. :wink:

1 Like

Oh wonderfull ! I will try it when i have time and i will see if all work.

Thanks @Kibelon and @StaggartCreations it work like a charm !
There is the actual shadergraph

One more thing maybe on the same subject, i try to do it with UI World Space but it seems LODGroup doesn’t worked with Canvas Renderer (yeah i use it in a very specific way), so i use a special layer culling distance, but it’s not quite what i want, and it doesn’t call a crossfade effect. It’s already great that LOD now work with MeshRenderer but any idea how to handle it ?

3 Likes