浏览代码

Use FastACos for the area light code

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

3
Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/Lit.hlsl


// Area light specific
// UVs for sampling the LUTs
// TODO: Test with fastAcos
float theta = acos(dot(bsdfData.normalWS, V));
float theta = FastACos(dot(bsdfData.normalWS, V));
// Scale and bias for the current precomputed table - the constant use here are the one that have been use when the table in LtcData.DisneyDiffuse.cs and LtcData.GGX.cs was use
float2 uv = 0.0078125 + 0.984375 * float2(bsdfData.perceptualRoughness, theta * INV_HALF_PI);

10
Assets/ScriptableRenderLoop/ShaderLibrary/AreaLighting.hlsl


float IntegrateEdge(float3 v1, float3 v2)
{
float cosTheta = dot(v1, v2);
// TODO: Explain the 0.9999 <= precision is important!
cosTheta = Clamp(cosTheta, -0.9999, 0.9999);
// TODO: Experiment with fastAcos
float theta = acos(cosTheta);
float res = cross(v1, v2).z * theta / sin(theta);
// Clamp to avoid artifacts. This particular constant gives the best results.
cosTheta = Clamp(cosTheta, -0.9999, 0.9999);
float theta = FastACos(cosTheta);
float res = cross(v1, v2).z * theta / sin(theta);
return res;
}

正在加载...
取消
保存