Blue noise requires a blue noise texture and thus an extra texture lookup. There is no good way of calculating blue noise in real-time. Thus the Bayer-matrix dithering is more performant in general.
Unity uses a lookup texture for its bayer matrix. My blue noise dither implementation is the exact same code (with a different number in the math for the differing dimensions), and a different texture. There is no performance difference (trust me, I’ve run it through many profilers)
Hey so I uploaded everything you’ll need to do this yourself. All you need to do is bang the texture in resources (so that the script can load it always), and include that cginc in any of your surface shaders which use the “dithercrossfade” generation option. If you don’t use surface shaders, I’m sure you can figure it out. Let me know if it doesn’t work for you.
Also @SebLagarde do you have throughts about this small change? Seems a large quality improvement.
Have you try the lod fade provide in HDRP? it is not the bayer pattern of Unity.
We are always worrying about performance, and adding a texture fetch for cross fade purpose is not in our plan
void LODDitheringTransition(uint3 fadeMaskSeed, float ditherFactor)
{
// Generate a spatially varying pattern.
// Unfortunately, varying the pattern with time confuses the TAA, increasing the amount of noise.
float p = GenerateHashedRandomFloat(fadeMaskSeed);
// We want to have a symmetry between 0…0.5 ditherFactor and 0.5…1 so no pixels are transparent during the transition
// this is handled by this test which reverse the pattern
// TODO: replace the test (ditherFactor >= 0.5) with (isLod0) to avoid the distracting pattern flip around 0.5.
p = (ditherFactor >= 0.5) ? p : 1 - p;
clip(ditherFactor - p);
}
Would recommend that whatever you do, validate it work in Unity for mesh Lod transition (Getting the symmetry right when transitioning is not always straightforward) and that it is working correctly when TAA is enabled.
hi , any tip on applying this effect on shader graph as a custom function node?
the current dither node in shader graph is really bad and too obvious to the eye.
Would like to bump that again @SebLagarde - just tried to improve the look of dithering (not for LODs, but in general) by running Forward + MSAA but seems that Alpha to Coverage isn’t possible at all right now - no matter what I do, I end up with full 0/1 pixels after alpha clipping. Am I missing something?
Can you reconsider adding it now:
URP itself has blue noise crossfading now, it noticeably improves LOD transitions. I was wondering why URP crossfade looks better then found out they have support for two modes, one being blue noise.
Unity Japan also recommends using blue noise method, relating to performance they said the following: “I personally think it’s a level you don’t have to worry about, the difference is about sampling a tiny noise texture at most once”