浏览代码

Optimize DisneyDiffuse()

/stochastic_alpha_test
Evgenii Golubev 7 年前
当前提交
c6261e9e
共有 2 个文件被更改,包括 10 次插入8 次删除
  1. 16
      ScriptableRenderPipeline/Core/ShaderLibrary/BSDF.hlsl
  2. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl

16
ScriptableRenderPipeline/Core/ShaderLibrary/BSDF.hlsl


return INV_PI;
}
float DisneyDiffuseNoPI(float NdotV, float NdotL, float LdotH, float perceptualRoughness)
float DisneyDiffuseNoPI(float NdotV, float NdotL, float LdotV, float perceptualRoughness)
float fd90 = 0.5 + 2 * LdotH * LdotH * perceptualRoughness;
// (2 * LdotH * LdotH) = 1 + LdotV
// float fd90 = 0.5 + 2 * LdotH * LdotH * perceptualRoughness;
float fd90 = 0.5 + (perceptualRoughness + perceptualRoughness * LdotV);
float viewScatter = F_Schlick(1.0, fd90, NdotV);
float viewScatter = F_Schlick(1.0, fd90, NdotV);
float DisneyDiffuse(float NdotV, float NdotL, float LdotH, float perceptualRoughness)
float DisneyDiffuse(float NdotV, float NdotL, float LdotV, float perceptualRoughness)
return INV_PI * DisneyDiffuseNoPI(NdotV, NdotL, LdotH, perceptualRoughness);
return INV_PI * DisneyDiffuseNoPI(NdotV, NdotL, LdotV, perceptualRoughness);
float facing = 0.5 + 0.5 * LdotV;
float facing = 0.5 + 0.5 * LdotV; // (LdotH)^2
// This constant is picked s.t. setting perceptualRoughness, albedo and all angles to 1
// This constant is picked s.t. setting perceptualRoughness, albedo and all cosines to 1
// allows us to match the Lambertian and the Disney Diffuse models. Original value: 0.1159.
float multiple = perceptualRoughness * (0.079577 * PI); // Rescaled by PI

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


#elif LIT_DIFFUSE_GGX_BRDF
float3 diffuseTerm = DiffuseGGX(bsdfData.diffuseColor, NdotV, NdotL, NdotH, LdotV, bsdfData.perceptualRoughness);
#else
float diffuseTerm = DisneyDiffuse(NdotV, NdotL, LdotH, bsdfData.perceptualRoughness);
float diffuseTerm = DisneyDiffuse(NdotV, NdotL, LdotV, bsdfData.perceptualRoughness);
#endif
diffuseLighting = bsdfData.diffuseColor * diffuseTerm;

正在加载...
取消
保存