浏览代码

Eliminate artifacts at the boundary of the area light

/Branch_Batching2
Evgenii Golubev 8 年前
当前提交
58917ffe
共有 2 个文件被更改,包括 7 次插入6 次删除
  1. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl
  2. 11
      Assets/ScriptableRenderPipeline/ShaderLibrary/AreaLighting.hlsl

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl


float3 unL = lightData.positionWS - positionWS;
[branch]
if (dot(lightData.forward, unL) >= 0)
if (dot(lightData.forward, unL) >= 0.0001)
{
// The light is back-facing.
return;

11
Assets/ScriptableRenderPipeline/ShaderLibrary/AreaLighting.hlsl


float cosSqOmega = cosOmega * cosOmega;
[branch]
if (cosSqOmega >= sinSqSigma)
if (cosSqOmega > sinSqSigma)
{
irradiance = sinSqSigma * saturate(cosOmega);
}

float x = sinSqOmega * tanSqSigma;
float y = -cosOmega * rsqrt(x);
float b = sqrt(sinSqOmega * tanSqSigma - cosSqOmega);
float a = b * cotSqSigma;
float a = sqrt(sinSqOmega * tanSqSigma - cosSqOmega);
float b = a * cotSqSigma;
irradiance = INV_PI * ((cosOmega * acos(y) - a) * sinSqSigma + atan(b));
irradiance = INV_PI * ((cosOmega * acos(y) - b) * sinSqSigma + atan(a));
}
#endif
return max(irradiance, 0);

F += INV_TWO_PI * ComputeEdgeFactor(V1, V2);
}
// Clamp invalid values (visual artifacts otherwise).
float sinSqSigma = sqrt(f2);
float sinSqSigma = min(sqrt(f2), 0.999);
float cosOmega = clamp(F.z * rsqrt(f2), -1, 1);
return DiffuseSphereLightIrradiance(sinSqSigma, cosOmega);

正在加载...
取消
保存