浏览代码

Avoid explicitly using `roughness` in the IBL code

Doesn't seem to help as the compiler still caches roughness, but it's a start.
/main
Evgenii Golubev 7 年前
当前提交
6f67ae21
共有 2 个文件被更改,包括 9 次插入8 次删除
  1. 14
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/ImageBasedLighting.hlsl
  2. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl

14
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/ImageBasedLighting.hlsl


}
// Ref: "Moving Frostbite to PBR", p. 69.
real3 GetSpecularDominantDir(real3 N, real3 R, real roughness, real NdotV)
real3 GetSpecularDominantDir(real3 N, real3 R, real perceptualRoughness, real NdotV)
real a = 1.0 - roughness;
real p = perceptualRoughness;
real a = 1.0 - p * p;
real lerpFactor = (s + roughness) * a;
real lerpFactor = (s + p * p) * a;
real lerpFactor = (s + roughness) * saturate(a * a + lerp(0.0, a, NdotV * NdotV));
real lerpFactor = (s + p * p) * saturate(a * a + lerp(0.0, a, NdotV * NdotV));
#endif
// The result is not normalized as we fetch in a cubemap

// To simulate the streching of highlight at grazing angle for IBL we shrink the roughness
// which allow to fake an anisotropic specular lobe.
// Ref: http://www.frostbite.com/2015/08/stochastic-screen-space-reflections/ - slide 84
real AnisotropicStrechAtGrazingAngle(real roughness, real perceptualRoughness, real NdotV)
real AnisotropicStrechAtGrazingAngle(real perceptualRoughness, real NdotV)
return roughness * lerp(saturate(NdotV * 2.0), 1.0, perceptualRoughness);
real p = perceptualRoughness;
return p * lerp(saturate(NdotV * 2.0) * p, p, p);
}
// ----------------------------------------------------------------------------

3
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl


// This is a ad-hoc tweak to better match reference of anisotropic GGX.
// TODO: We need a better hack.
preLightData.iblPerceptualRoughness *= saturate(1.2 - abs(bsdfData.anisotropy));
float iblRoughness = PerceptualRoughnessToRoughness(preLightData.iblPerceptualRoughness);
preLightData.iblR = GetSpecularDominantDir(N, iblR, iblRoughness, NdotV);
preLightData.iblR = GetSpecularDominantDir(N, iblR, preLightData.iblPerceptualRoughness, NdotV);
#ifdef LIT_USE_GGX_ENERGY_COMPENSATION
// Ref: Practical multiple scattering compensation for microfacet models.

正在加载...
取消
保存