Skip to content

Fixed Nans happening due to volumetric clouds when the pixel color is perfectly black (case 1379185). #6311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed exception on DLSS when motion vectors are disabled (case # 1377986).
- Fixed decal performances when they use different material and the same draw order.
- Fixed alpha channel display in color picker in Local Volumetric Fog component (the alpha is not used for the fog) (case 1381267).
- Fixed Nans happening due to volumetric clouds when the pixel color is perfectly black (case 1379185).

### Changed
- Optimizations for the physically based depth of field.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,17 @@ void FillCloudUpscaleNeighborhoodData(int2 groupThreadId, int subRegionIdx, out
float EvaluateFinalTransmittance(float3 color, float transmittance)
{
// Due to the high intensity of the sun, we often need apply the transmittance in a tonemapped space
float3 resultColor = color / (1.0 + color) * transmittance;
resultColor = resultColor / (1.0 - resultColor);
return _ImprovedTransmittanceBlend ? Luminance(resultColor / color) : transmittance;
// As we only produce one transmittance, we evaluate the approximation on the luminance of the color
float luminance = Luminance(color);

// Apply the tone mapping and then the transmittance
float resultLuminance = luminance / (1.0 + luminance) * transmittance;

// reverse the tone mapping
resultLuminance = resultLuminance / (1.0 - resultLuminance);

// This approach only makes sense if the color is not black
return (luminance > 0.0 && _ImprovedTransmittanceBlend == 1) ? resultLuminance / luminance : transmittance;
}
#endif // REAL_TIME_VOLUMETRIC_CLOUDS

Expand Down