Fade by Distance
Fade by Distance modulates the material’s alpha by the camera-to-surface distance. Genesis lets you fade in or out between smooth start and end bounds, and pairs with Dither Transparency for sort-free fades.
When to use it
- First-person hands and arms — fade out when too close to walls.
- Camera occluders — buildings between camera and player.
- Foliage culling — fade billboards in or out at draw distance.
- Proximity LODs — switch effects on as the player approaches.
Pair with Dither Transparency
How it works
The shader computes length(positionWS - _WorldSpaceCameraPos) per pixel, applies smoothstep(_FadeStart, _FadeEnd, distance) (or its inverse), and multiplies the result into the surface alpha. With _FadeInvert enabled the curve runs the other way, fading in instead of out.
Properties
Usage
- Enable Fade by Distance and set Start / End in world units.
- For FP arms, set Start = 0.6, End = 0.3, and Invert off so it fades as you get close.
- For distant foliage, set Start = 30, End = 50, and Invert on so it fades in as you approach.
- Combine with Dither Transparency if you need shadows.
material.SetFloat("_FadeByDistance", 1f);
material.SetFloat("_FadeStart", 0.6f);
material.SetFloat("_FadeEnd", 0.3f);Tips & gotchas
- Distance is measured to the surface, not the object center, so large meshes near the camera partially fade.
- Combine with cutout if you also have hard-edged transparency; Genesis evaluates both correctly.
- Cost is one
length()plus a smoothstep, so it is trivial on mobile. - Distance uses the average eye position in VR, which looks correct in stereo.
Related
- Dither Transparency — shadow-friendly fade.
- See-Through — silhouette behind walls.
- Surface Settings — blend mode controls fade behavior.
- Hologram — pair for sci-fi proximity reveals.
Last updated on