浏览代码

Computes part of the BRDF normalization out of the light loop.

/lw-shader-optimization
Felipe Lira 7 年前
当前提交
1bbfe054
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 4
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Lighting.hlsl

4
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Lighting.hlsl


half roughness;
half roughness2;
half grazingTerm;
half normalizationTerm; // stores (roughness + 0.5) * 4.0 BRDF term. roughness + 0.5 comes from an approximation of V * F.
};
half ReflectivitySpecular(half3 specular)

outBRDFData.perceptualRoughness = PerceptualSmoothnessToPerceptualRoughness(smoothness);
outBRDFData.roughness = PerceptualRoughnessToRoughness(outBRDFData.perceptualRoughness);
outBRDFData.roughness2 = outBRDFData.roughness * outBRDFData.roughness;
outBRDFData.normalizationTerm = (outBRDFData.roughness + 0.5h) * 4.0h;
#ifdef _ALPHAPREMULTIPLY_ON
outBRDFData.diffuse *= alpha;

half d = NoH * NoH * (brdfData.roughness2 - 1.h) + 1.00001h;
half LoH2 = LoH * LoH;
half specularTerm = brdfData.roughness2 / ((d * d) * max(0.1h, LoH2) * (brdfData.roughness + 0.5h) * 4);
half specularTerm = brdfData.roughness2 / ((d * d) * max(0.1h, LoH2) * brdfData.normalizationTerm);
// on mobiles (where half actually means something) denominator have risk of overflow
// clamp below was added specifically to "fix" that, but dx compiler (we convert bytecode to metal/gles)

正在加载...
取消
保存