diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricClouds/VolumetricCloudsUtilities.hlsl b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricClouds/VolumetricCloudsUtilities.hlsl index b5520a75063..38fbf6a1b9d 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricClouds/VolumetricCloudsUtilities.hlsl +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricClouds/VolumetricCloudsUtilities.hlsl @@ -819,8 +819,12 @@ float EvaluateFinalTransmittance(float3 color, float transmittance) // reverse the tone mapping resultLuminance = resultLuminance / (1.0 - resultLuminance); + // By softening the transmittance attenuation curve for pixels adjacent to cloud boundaries when the luminance is super high, + // We can prevent sun flicker and improve perceptual blending. (https://www.desmos.com/calculator/vmly6erwdo) + float finalTransmittance = max(resultLuminance / luminance, pow(transmittance, 6)); + // This approach only makes sense if the color is not black - return luminance > 0.0 ? lerp(transmittance, resultLuminance / luminance, _ImprovedTransmittanceBlend) : transmittance; + return luminance > 0.0 ? lerp(transmittance, finalTransmittance, _ImprovedTransmittanceBlend) : transmittance; } #endif // VOLUMETRIC_CLOUD_UTILITIES_H