浏览代码

HDRenderPipeline: Minor improvement + code cleanup

- update the roughness remapping of refraction to better match
reflection probe
/Yibing-Project-2
Sebastien Lagarde 7 年前
当前提交
2448888d
共有 3 个文件被更改,包括 12 次插入5 次删除
  1. 2
      ScriptableRenderPipeline/Core/ShaderLibrary/CommonLighting.hlsl
  2. 7
      ScriptableRenderPipeline/Core/ShaderLibrary/VolumeRendering.hlsl
  3. 8
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl

2
ScriptableRenderPipeline/Core/ShaderLibrary/CommonLighting.hlsl


}
// ior is a value between 1.0 and 2.5
float ConvertIORToFresnel0(float ior)
float IORToFresnel0(float ior)
{
return Sqr((ior - 1.0) / (ior + 1.0));
}

7
ScriptableRenderPipeline/Core/ShaderLibrary/VolumeRendering.hlsl


HenyeyGreensteinPhasePartVarying(asymmetry, LdotD);
}
// Absorption coefficient from Disney: http://blog.selfshadow.com/publications/s2015-shading-course/burley/s2015_pbs_disney_bsdf_notes.pdf
float TransmittanceColorAtDistanceToAbsorption(float3 transmittanceColor, float atDistance)
{
return -log(transmittanceColor + 0.00001) / max(atDistance, 0.000001);
}
#endif // UNITY_VOLUME_RENDERING_INCLUDED

8
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl


bsdfData.ior = ior;
// IOR define the fresnel0 value, so update it also for consistency (and even if not physical we still need to take into account any metal mask)
bsdfData.fresnel0 = lerp(ConvertIORToFresnel0(ior).xxx, baseColor, metallic);
bsdfData.fresnel0 = lerp(IORToFresnel0(ior).xxx, baseColor, metallic);
// Absorption coefficient from Disney: http://blog.selfshadow.com/publications/s2015-shading-course/burley/s2015_pbs_disney_bsdf_notes.pdf
bsdfData.absorptionCoefficient = -log(transmittanceColor + 0.00001) / max(atDistance, 0.000001);
bsdfData.absorptionCoefficient = TransmittanceColorAtDistanceToAbsorption (transmittanceColor, atDistance);
bsdfData.transmittanceMask = transmittanceMask;
bsdfData.thickness = max(thickness, 0.0001);
}

preLightData.transmissionRefractV = refraction.rayWS;
preLightData.transmissionPositionWS = refraction.positionWS;
preLightData.transmissionTransmittance = exp(-bsdfData.absorptionCoefficient * refraction.distance);
preLightData.transmissionSSMipLevel = PerceptualRoughnessToMipmapLevel(bsdfData.perceptualRoughness, uint(_GaussianPyramidColorMipSize.z));
// Empirical remap to try to match a bit the refractio probe blurring for the fallback
preLightData.transmissionSSMipLevel = sqrt(bsdfData.perceptualRoughness) * uint(_GaussianPyramidColorMipSize.z);
#else
preLightData.transmissionRefractV = -V;
preLightData.transmissionPositionWS = posInput.positionWS;

正在加载...
取消
保存