浏览代码

Merge branch 'UpdateAreaLightImpl'

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

7
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);

}
#ifndef DIFFUSE_LAMBERT_BRDF
// TODO: verify that we do not need to multiply by PI.
ltcValue *= preLightData.ltcDisneyDiffuseMagnitude;
#endif

ltcValue *= lightData.specularScale;
specularLighting = fresnelTerm * lightData.color * ltcValue;
}
// TODO: current area light code doesn't take into account artist attenuation radius!
#endif
}

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;
}

8
Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl


#define MERGE_NAME(X, Y) X##Y
// Acos in 14 cycles.
float res = -0.156583 * x + HALF_PI;
res *= sqrt(1.0 - x);
return (inX >= 0) ? res : PI - res;
float res = (0.0468878 * x + -0.203471) * x + 1.570796; // p(x)
res *= sqrt(1.0f - x);
return (inX >= 0) ? res : PI - res; // Undo range reduction
}
// Same cost as Acos + 1 FR

正在加载...
取消
保存