浏览代码

Save 4 cycles in DiffuseSphereLightIrradiance()

/Branch_Batching2
Evgenii Golubev 8 年前
当前提交
05b6659e
共有 1 个文件被更改,包括 8 次插入8 次删除
  1. 16
      Assets/ScriptableRenderPipeline/ShaderLibrary/AreaLighting.hlsl

16
Assets/ScriptableRenderPipeline/ShaderLibrary/AreaLighting.hlsl


// N.b.: this function accounts for horizon clipping.
float DiffuseSphereLightIrradiance(float sinSqSigma, float cosOmega)
{
#if 0 // Ref: Area Light Sources for Real-Time Graphics, page 4 (1996).
#if 0 // Ref: Area Light Sources for Real-Time Graphics, page 4 (1996).
float cosSqSigma = saturate(1 - sinSqSigma);
float sinSqGamma = saturate(cosSqSigma / sinSqOmega);
float cosSqGamma = saturate(1 - sinSqGamma);

irradiance = INV_PI * (g + h);
}
}
#else // Ref: Moving Frostbite to Physically Based Rendering, page 43 (2015).
float sinOmega = sqrt(saturate(1 - cosOmega * cosOmega));
#else // Ref: Moving Frostbite to Physically Based Rendering, page 47 (2015).
float irradiance;
if (cosOmega * cosOmega > sinSqSigma)

else
{
float x = sqrt(1 / sinSqSigma - 1);
float y = -x * (cosOmega / sinOmega);
float z = sinOmega * sqrt(1 - y * y);
irradiance = INV_PI * ((cosOmega * acos(y) - x * z) * sinSqSigma + atan(z / x));
float a = 1 / sinSqSigma - 1;
float w = rsqrt(a);
float x = sqrt(a);
float y = -x * cosOmega * rsqrt(sinSqOmega);
float z = sqrt(sinSqOmega * (1 - y * y));
irradiance = INV_PI * ((cosOmega * acos(y) - x * z) * sinSqSigma + atan(z * w));
}
#endif
return max(irradiance, 0);

正在加载...
取消
保存