LOD Cross-Fading Shaders - Implementation Guide
Implements fading between lod levels to hide "popping" effects.
Tired of popping in Unity LOD System?
LCFS is the final AAA solution for the Level of Detail transitions in Unity 3D (URP only, for the moment.).
It will reduce or even hide the popping for the Unity LOD System between different LOD levels, and even when the objects fades out in distance.
How does this works?
When the Unity LOD system replaces the 3d model to be rendered, a fading applied by dithering or transparency interpolates and hides any "popping effect".
You don't need any particular implementation, just set your LOD component to "Cross Fade" and apply an LCFS material to your model. The package comes with three setted up PBR materials with 3 different transitioning effects: Dithering, Half Dithering and Transparency.
And what if I am using a custom shader?
No problem at all!
You can edit any Shader Graph shader adding one of the CrossFading nodes to the alpha channel. Basically, any shader can integrate this system.
•Dithering: Best type of LOD fading, but sometimes creates artifacts on shadows during the transition.
•Half-Dithering: If you need more stable shadows this system will fade the LOD level in a more lightweight and stable way.
•Transparency: Works just like Half-Dithering, but using transparency instead. This is a little more GPU expensive, but supports transparent materials, like glass water and ice.
Your model can have different types of LCFS shaders in different LOD levels,
for example you may want to have a transparent LCFS shader in first LOD level, and a dithering one on other LOD levels.
To implement this system you need to add a
LOD Group component to your mode, and set Fade Mode to "Cross Fade". Then every mesh that will be affected from LOD System needs to have a shader that uses LCFS Nodes.
Package contains three PBR shaders already setted up that allows you to create the materials quickly. Just create a new material and set it as
Needs more advanced/customizable materials?
No problem. With the
CorvoNodes you can make any material compatible with this system. Just add the right node to your material. Follows the Shader Graph APIs to more info about how to set up LCFS nodes.
Differences between LCFS Shaders:
- Unity Standard / Other: Without using an LCFS node inside the shader, is not possible to get a smooth transition between LOD levels.
- Dithering: Dithering cross fading use a Dithering effect on alphaClipThreesold to fade out/in the material when LOD Group component switches between LOD levels. Using a dithering effect your material will use an opaque pass (lighter then a transparent pass). This won't allows you to render transparent materials such as glass or ice, but the fading is almost unnoticeable. Warning: Using this kind of transition may sometimes create artifacts on shadows during the fading.
- Half-Dithering: This cross-fading tecqniques is very similar to the (full) Dithering, but solves the problems on the shadows artifacts, and may result a little less GPU expensive too. However, the fading may not be perfectly clear and smoothed.
- Transparent: If you need to have transparent materials, this is the best option. Work similarly to the Half-Dithering but allows you to have transparency in materials. Since opaque materials are usually faster then transparent ones, this may use a little more of GPU power.
Frequently Asked Questions
"How does this work?"
Using custom nodes and Sub-Shaders, LCFS system will detect and apply transparency/dithering effects on materials during fading between lod leves, hiding any popping artifact.
You can use the already setted up shaders in any of your materials, or create your own PBR shader adding the LCFS nodes to add the fading effects.
"Will GPU performance be affected?"
Surely this will affect GPU performance, but from our tests we haven't noticed any particular frame drop. An extensive use (for example hundred of trees) may however impact framerate by 1-10 FPS.
"Can I use this on any custom shader?"
Just add the custom node you prefer on your shader to include the fading effect on your material. See the Shader Graph API for more details about how to implement it.