| 标签
o.zenithAngle.xyz = max(6e-2, t + 6e-2) + (max(0.0, -t) * _GroundColor.xyz);
o.zenithAngle.w = max(0, t);
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;

入射辐射和透射辐射之比值的自然对数。

// sky color
half3 extinction = exp(-( _BetaR * sR + _BetaM * sM ));

half3 rayleigh = lerp( extinction * gr, 1 - extinction, _SkyMultiplier.x);
#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;

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

上一篇: Objective-C 语法笔记
下一篇: Unity Unitystandardshader技术分析