Skip to Content
DocumentationFeaturesFade by Distance

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.

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

Inspector labelShader propertyTypeDefaultDescription
Enable Fade_FadeByDistanceToggleOffMaster toggle.
Fade Start_FadeStartFloat (0–100)5.0Distance where the fade begins.
Fade End_FadeEndFloat (0–100)20.0Distance at full transparency (or full opacity if inverted).
Invert_FadeInvertToggleOffOff = fade out when far, On = fade in when far.
Curve_FadeCurveEnumSmoothstepLinear or Smoothstep.
Min Alpha_FadeMinAlphaFloat (0–1)0.0Floor the alpha will not drop below.

Usage

  1. Enable Fade by Distance and set Start / End in world units.
  2. For FP arms, set Start = 0.6, End = 0.3, and Invert off so it fades as you get close.
  3. For distant foliage, set Start = 30, End = 50, and Invert on so it fades in as you approach.
  4. 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.
Last updated on