浏览代码

Updated empirical mip remaping for refraction and planar reflection

/main
Frédéric Vauchelles 7 年前
当前提交
a852e040
共有 2 个文件被更改,包括 3 次插入7 次删除
  1. 5
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/ImageBasedLighting.hlsl
  2. 5
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl

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


return PerceptualRoughnessToMipmapLevel(perceptualRoughness, UNITY_SPECCUBE_LOD_STEPS);
}
real PerceptualRoughnessToMipmapLevelFromGaussianConvolution(real perceptualRoughness, uint mipMapCount)
{
return sqrt(perceptualRoughness) * mipMapCount;
}
// The *accurate* version of the non-linear remapping. It works by
// approximating the cone of the specular lobe, and then computing the MIP map level
// which (approximately) covers the footprint of the lobe with a single texel.

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


preLightData.transparentTransmittance = exp(-bsdfData.absorptionCoefficient * refraction.dist);
// Empirical remap to try to match a bit the refraction probe blurring for the fallback
// Use IblPerceptualRoughness so we can handle approx of clear coat.
preLightData.transparentSSMipLevel = PerceptualRoughnessToMipmapLevelFromGaussianConvolution(preLightData.iblPerceptualRoughness, uint(_ColorPyramidScale.z));
preLightData.transparentSSMipLevel = pow(preLightData.iblPerceptualRoughness, 1.3) * uint(max(_ColorPyramidScale.z - 1, 0));
#endif
return preLightData;

// Specific case for Texture2Ds, their convolution is a gaussian one and not a GGX one.
// So we use another roughness mip mapping.
if (IsEnvIndexTexture2D(lightData.envIndex))
iblMipLevel = PerceptualRoughnessToMipmapLevelFromGaussianConvolution(preLightData.iblPerceptualRoughness, uint(_ColorPyramidScale.z));
// Empirical remapping
iblMipLevel = pow(preLightData.iblPerceptualRoughness, 0.8) * uint(max(_ColorPyramidScale.z - 1, 0));
float4 preLD = SampleEnv(lightLoopContext, lightData.envIndex, R, iblMipLevel);
weight *= preLD.a; // Used by planar reflection to discard pixel

正在加载...
取消
保存