Shader shSkyGradientsFGI (Legacy 3DS MAX)
- Last UpdatedApr 02, 2025
- 1 minute read
The shSkyGradientsFGI element will render a Sky with day/night gradients to use inside the FGI pipeline.
Explanation
The Sky Mesh needs no material, no UV coordinates, no Sky Dummies.
The Sky UV coordinates are calculated in real time using two parameters:
-
The current day/night value [0..1].
-
The Sun light position.
The gradient texture may look duplicated on the X axis, but actually the texture is split in two to simulate the Sun's position.

Notes
-
Params fTimeOfDay and vLightPosWS are set by the engine.
-
The mDiffuseMap and mDiffuseMap2 parameters must point to the same texture.
-
The shader uses an infinite z trick to always render when the camera zfar is small. For this to work, the user buffer includes the state depthCompareMode = lessEqual and also the state depthWrite = False (to prevent interfering with the zbuffer).
-
The shader uses bObjectSpace = True because it requires the mesh position to be valid. WorldSpace removes all the matrices.