浏览代码

Update the normalization of Baum's equation

/main
Evgenii Golubev 8 年前
当前提交
8de2e009
共有 2 个文件被更改,包括 22 次插入12 次删除
  1. 5
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/Lit.hlsl
  2. 29
      Assets/ScriptableRenderLoop/ShaderLibrary/AreaLighting.hlsl

5
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/Material/Lit/Lit.hlsl


// TODO: Disney
//#endif
// Divide all by 2 PI as it is Lambert integration for diffuse
diffuseLighting.rgb *= lightData.color * INV_TWO_PI * lightData.diffuseScale;
specularLighting.rgb *= lightData.color * INV_TWO_PI * lightData.specularScale;
diffuseLighting.rgb *= lightData.color * lightData.diffuseScale;
specularLighting.rgb *= lightData.color * lightData.specularScale;
// TODO: current area light code doesn't take into account artist attenuation radius!
#endif

29
Assets/ScriptableRenderLoop/ShaderLibrary/AreaLighting.hlsl


// Even though that replaced the switch with just some indexing and no branches, it became
// way, way slower - mem fetch stalls?
// clip
uint n = 0;
switch (config)
{

break;
}
if (n == 0)
return 0;
if (n == 3)
L[3] = L[0];
if (n == 4)
L4 = L[0];
if (n == 0) return 0;
L[3] = normalize(L[3]);
L4 = normalize(L4);
switch (n)
{
case 3:
L[3] = L[0];
break;
case 4:
L[3] = normalize(L[3]);
L4 = L[0];
break;
default: // 1, 2, 5
L[3] = normalize(L[3]);
L4 = normalize(L4);
break;
}
// 3. Integrate
float sum = 0;

if (n == 5)
sum += IntegrateEdge(L4, L[0]);
return twoSided > 0.0 ? abs(sum) : max(0.0, sum);
sum *= INV_TWO_PI; // Normalization of the Lambertian integral over the sphere
return twoSided ? abs(sum) : max(sum, 0.0);
}
float LTCEvaluate(float3 V, float3 N, float3x3 minV, float4x3 L, bool twoSided)

正在加载...
取消
保存