TerraGemini renders oceanic reflection and planetary atmosphere using a raytraced billboard quad covering the screen-space bounding disc of the planet (u2+v2≤1.0).
1. Spherical Normal Reconstruction
For any fragment (u,v)∈[−1,1]2, fragments outside r2=u2+v2≤1.0 are discarded. The unit normal N on the sphere surface is derived analytically:
N=u−v1.0−r2
2. Solar Vector & Half-Angle Glint
With solar azimuth θsun and constant solar elevation α=0.35 rad, the normalized light vector L is constructed. Blinn-Phong specular intensity is calculated using the half-angle vector H=∥L+V∥L+V with an exponent of s=38.0:
Ispec=(max(N⋅H,0.0))38⋅step(0.001,N⋅L)
The step function guarantees that the unlit hemisphere receives zero specular highlight.
3. Rayleigh Atmospheric Limb & Composite
Limb scattering Ilimb=(1.0−1.0−r2)2.6 produces an atmospheric rim halo. The final composited fragment combines diffuse ocean tone, specular glint, and atmospheric scattering in a single pass: