public static class PhysicalSkyA daylight sky, computed rather than painted: Preetham's analytic model, in cd/m².
Remarks
What "physically based sky" buys over a gradient. A gradient has to be re-authored every time the sun moves, and the two are then two opinions about the same weather — a sunset sky over a scene lit by a white noon sun. Here there is one input, the sun's direction, and the sky, the sun's colour and the sun's brightness all fall out of it. Move the sun down and the horizon reddens, the sky dims, the sun goes orange and its illuminance drops by a factor of ten, because all four are the same air mass.
Preetham et al. 1999, "A Practical Analytic Model for Daylight." A Perez sky luminance distribution fitted to spectral radiative-transfer simulations: five coefficients per channel as linear functions of turbidity, a zenith value per channel as a polynomial in the sun's zenith angle, and the ratio of the distribution at the view direction to the distribution at the zenith. Output is xyY, converted here to linear sRGB.
⚠ It is a daylight model, and DiffuseScale is what carries it past the end of daylight. The published fit's zenith luminance stops falling well before the sun reaches the horizon — it bottoms out near 1900 cd/m², about five times what a real sunset sky has — so a scene authored by moving the sun down gets a disc that dims by a factor of a thousand under a sky that does not dim at all. That scalar is the correction, and below the horizon it is an extrapolation which says so. A model that covered twilight properly would be Hosek-Wilkie with its own table, and this one is four dozen constants.
The sun is the same atmosphere seen the other way. SunIlluminance and SunTint come from Rayleigh and Mie transmittance along the same air mass the sky is computed for, so the disc's colour and the horizon's colour are one calculation. That is what keeps "golden hour" a position rather than a palette.
Fields and properties (1)
public const float SolarConstantLuminous solar constant at the top of the atmosphere, in lux.
Methods (5)
public static Vector3 Radiance(Vector3 direction, in SkyParameters sky)The luminance of one direction of sky, in cd/m².
public static float DiffuseScale(in SkyParameters sky)How much of the fit's daylight luminance a sky this low actually has.
public static float SunIlluminance(in SkyParameters sky)How much light the sun delivers to a surface facing it, in lux.
public static Color3 SunTint(in SkyParameters sky)What colour the sun is at this elevation, as a tint of unit luminance.
public static CubeImage Bake(int size, in SkyParameters sky)Bakes the whole sky into a cube, one texel at a time.
Used by (4)
- ArenaFrameThirdPersonShooter
- ArenaIlluminationThirdPersonShooter
- PreethamRadianceThirdPersonShooter
- PhysicalSkyTestsVixen.Rendering.Tests