浏览代码

Optimize IntegrateLD() by using D_GGX_Inverse()

/main
Evgenii Golubev 8 年前
当前提交
65fc4234
共有 2 个文件被更改,包括 13 次插入2 次删除
  1. 11
      Assets/ScriptableRenderLoop/ShaderLibrary/BSDF.hlsl
  2. 4
      Assets/ScriptableRenderLoop/ShaderLibrary/ImageBasedLighting.hlsl

11
Assets/ScriptableRenderLoop/ShaderLibrary/BSDF.hlsl


return INV_PI * D_GGXNoPI(NdotH, roughness);
}
float D_GGX_Inverse(float NdotH, float roughness)
{
roughness = max(roughness, UNITY_MIN_ROUGHNESS);
float a2 = roughness * roughness;
float f = (NdotH * a2 - NdotH) * NdotH + 1.0;
float g = (f * f) / a2;
return PI * g;
}
// Ref: http://jcgt.org/published/0003/02/03/paper.pdf
float V_SmithJointGGX(float NdotL, float NdotV, float roughness)
{

4
Assets/ScriptableRenderLoop/ShaderLibrary/ImageBasedLighting.hlsl


// - OmegaS : Solid angle associated to a sample
// - OmegaP : Solid angle associated to a pixel of the cubemap
float pdf = D_GGX(NdotH, roughness) * 0.25;
float omegaS = 1.0 / (sampleCount * pdf); // Solid angle associated with the sample
float invPdf = D_GGX_Inverse(NdotH, roughness) * 4.0;
float omegaS = rcp(sampleCount) * invPdf; // Solid angle associated with the sample
// invOmegaP is precomputed on CPU and provide as a parameter of the function
// float omegaP = FOUR_PI / (6.0f * cubemapWidth * cubemapWidth); // Solid angle associated with the pixel of the cubemap
mipLevel = 0.5 * log2(omegaS * invOmegaP) + 1.0; // Clamp is not necessary as the hardware will do it

正在加载...
取消
保存