o.zenithAngle.xyz = max(6e-2, t + 6e-2) + (max(0.0, -t) * _GroundColor.xyz);
o.zenithAngle.w = max(0, t);
zenith:天顶
天顶区域的偏振特性受整个大气层的影响,而且受环境光以及周围建筑地表的影响均较小,非大气散射光线相对较少
zenith angle: 天顶距
float cosTheta = dot( pos, _ROCLightDir1); // need precision float in iOS
half cosine = cosTheta;
// optical depth
half3 sR = 8.0 / i.zenithAngle.xyz;
half3 sM = 1.2 / i.zenithAngle.xyz;
optical depth: 光学深度
入射辐射和透射辐射之比值的自然对数。
// sky color
half3 extinction = exp(-( _BetaR * sR + _BetaM * sM ));
half3 rayleigh = lerp( extinction * gr, 1 - extinction, _SkyMultiplier.x);
消光 Extinction
瑞利散射 Rayleigh Scattering
#ifdef SKY_HQ
half3 mie = rayleigh * sM / rayleigh.r * _MieC;
// scattering phase
half miePhase = _MieG.x * pow(_MieG.y - _MieG.z * cosine, -1.5 );
half3 inScatter = ( rayleigh * 0.75 + mie * miePhase ) * (( 1.0 + cosine * cosine ) * _SkyMultiplier.y);
half sun = min(1e3, pow((1 - cosine) * _LightParams.x, -1.5));
half nocloud = 1 - step(1e-3, _CloudParams.z);
sun *= nocloud;
inScatter += sun * min(mie, i.zenithAngle.w) * extinction;
米氏散射 Mie Scattering
内散射 In-scattering
References:
1 https://developer.nvidia.com/gpugems/GPUGems2/gpugems2_chapter16.html
2 https://blog.csdn.net/wolf96/article/details/47144003
3 http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.192.1514&rep=rep1&type=pdf
4 https://gameinstitute.qq.com/community/detail/107336