Skip to content

Changed the clamping approach for RTR and RTGI (in both perf and quality) to improve visual quality. #3020

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
Jan 12, 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ -57,6 +57,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Decreased the minimal Fog Distance value in the Density Volume to 0.05.
- Changed the convergence time of ssgi to 16 frames and the preset value
- Improved robustness of volumetric sampling in path tracing (case 1295187).
- Changed the clamping approach for RTR and RTGI (in both perf and quality) to improve visual quality.

## [10.3.0] - 2020-12-01

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ DeferredLightingRTParameters PrepareIndirectDiffuseDeferredLightingRTParameters(
deferredParameters.raytracingCB._RaytracingIntensityClamp = settings.clampValue;
deferredParameters.raytracingCB._RaytracingPreExposition = 1;
deferredParameters.raytracingCB._RaytracingIncludeSky = 1;
deferredParameters.raytracingCB._RaytracingPreExposition = 1;
deferredParameters.raytracingCB._RaytracingRayMaxLength = settings.rayLength;
deferredParameters.raytracingCB._RayTracingDiffuseLightingOnly = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,14 @@ void RAYTRACING_DEFERRED(uint3 dispatchThreadId : SV_DispatchThreadID, uint2 gro
// If the distance is negative, this means it is a sky pixel or an unlit material
if (LOAD_TEXTURE2D_X(_RaytracingDistanceBuffer, currentCoord).x < 0.0)
{
float3 newSampleColor = clamp(LOAD_TEXTURE2D_X(_GBufferTexture3, currentCoord).rgb * GetCurrentExposureMultiplier(), 0.0, _RaytracingIntensityClamp)
* (_RaytracingPreExposition ? 1.0 : GetInverseCurrentExposureMultiplier() );
_RaytracingLitBufferRW[COORD_TEXTURE2D_X(currentCoord)] = float4(newSampleColor, 0.0);
// Convert to HSV space
float3 finalColor = RgbToHsv(LOAD_TEXTURE2D_X(_GBufferTexture3, currentCoord).rgb * GetCurrentExposureMultiplier());

// Expose and clamp the final color
finalColor.z = clamp(finalColor.z, 0.0, _RaytracingIntensityClamp);

// Convert back to HSV space
_RaytracingLitBufferRW[COORD_TEXTURE2D_X(currentCoord)] = float4(HsvToRgb(finalColor) * (_RaytracingPreExposition ? 1.0 : GetInverseCurrentExposureMultiplier()), 0.0);
return;
}

Expand Down Expand Up @@ -106,8 +111,23 @@ void RAYTRACING_DEFERRED(uint3 dispatchThreadId : SV_DispatchThreadID, uint2 gro
float3 finalColor = (diffuseLighting + specularLighting);
// Apply fog attenuation
ApplyFogAttenuation(sourcePosInput.positionWS, rayDirection, rayDistance, finalColor, true);
// Expose, clamp and inverse exposure
finalColor = clamp(finalColor * GetCurrentExposureMultiplier(), 0.0, _RaytracingIntensityClamp) * (_RaytracingPreExposition ? 1.0 : GetInverseCurrentExposureMultiplier());

// Expose, clamp and inverse exposure. Though depending on the signal nature we go for different clamping strategies
if (_RaytracingPreExposition)
{
// Convert to HSV space
finalColor = RgbToHsv(finalColor * GetCurrentExposureMultiplier());

// Expose and clamp the final color
finalColor.z = clamp(finalColor.z, 0.0, _RaytracingIntensityClamp);

// Convert back to HSV space
finalColor = HsvToRgb(finalColor);
}
else
{
finalColor = clamp(finalColor * GetCurrentExposureMultiplier(), 0.0, _RaytracingIntensityClamp) * GetInverseCurrentExposureMultiplier();
}
_RaytracingLitBufferRW[COORD_TEXTURE2D_X(currentCoord)] = float4(finalColor, 1.0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,14 @@ void RayGenIntegration()
// Normalize the value
finalColor *= 1.0f / _RaytracingNumSamples;

// Convert to HSV space
finalColor = RgbToHsv(finalColor * GetCurrentExposureMultiplier());

// Expose and clamp the final color
finalColor = clamp(finalColor * GetCurrentExposureMultiplier(), 0.0, _RaytracingIntensityClamp);
finalColor.z = clamp(finalColor.z, 0.0, _RaytracingIntensityClamp);

// Convert back to HSV space
finalColor = HsvToRgb(finalColor) * GetInverseCurrentExposureMultiplier();
// We store the sampled color and the weight that shall be used for it (1.0f)
_IndirectDiffuseTextureRW[COORD_TEXTURE2D_X(currentCoord)] = float4(finalColor, 1.0f);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,32 @@ void RayGenIntegration()
// Evaluate the ray intersection
TraceRay(_RaytracingAccelerationStructure, RAY_FLAG_CULL_BACK_FACING_TRIANGLES, RAYTRACINGRENDERERFLAG_REFLECTION, 0, 1, 0, rayDescriptor, rayIntersection);

// The clamping process is different for the sky and rest
float3 sampleColor = 0.0;
if (rayIntersection.t == _RaytracingRayMaxLength)
{
// Convert to HSV space
sampleColor = RgbToHsv(rayIntersection.color * GetCurrentExposureMultiplier());

// Expose and clamp the final color
sampleColor.z = clamp(sampleColor.z, 0.0, _RaytracingIntensityClamp);

// Convert back to HSV space
sampleColor = HsvToRgb(sampleColor) * GetInverseCurrentExposureMultiplier();
}
else
{
// Expose and clamp the final color
sampleColor = clamp(rayIntersection.color * GetCurrentExposureMultiplier(), 0.0, _RaytracingIntensityClamp) * GetInverseCurrentExposureMultiplier();
}

// Contribute to the pixel
finalColor += rayIntersection.color;
finalColor += sampleColor;
}

// Normalize the value
finalColor *= 1.0 / realSampleCount;

// Expose and clamp the final color
finalColor = clamp(finalColor * GetCurrentExposureMultiplier(), 0.0, _RaytracingIntensityClamp) * GetInverseCurrentExposureMultiplier();

// We also need to compute the fade factor for this sample
float weightValue = _RaytracingReflectionSmoothnessFadeStart == _RaytracingReflectionMinSmoothness ? 1.0 : saturate((perceptualSmoothness - _RaytracingReflectionMinSmoothness) / (_RaytracingReflectionSmoothnessFadeStart -_RaytracingReflectionMinSmoothness));

Expand Down Expand Up @@ -252,8 +268,24 @@ void RayGenIntegrationTransparent()
// Evaluate the ray intersection
TraceRay(_RaytracingAccelerationStructure, RAY_FLAG_CULL_BACK_FACING_TRIANGLES, RAYTRACINGRENDERERFLAG_REFLECTION, 0, 1, 0, rayDescriptor, rayIntersection);

// Expose and clamp the final color
float3 finalColor = clamp(rayIntersection.color * GetCurrentExposureMultiplier(), 0.0, _RaytracingIntensityClamp) * GetInverseCurrentExposureMultiplier();
// The clamping process is different for the sky and rest
float3 finalColor = 0.0;
if (rayIntersection.t == _RaytracingRayMaxLength)
{
// Convert to HSV space
finalColor = RgbToHsv(rayIntersection.color * GetCurrentExposureMultiplier());

// Expose and clamp the final color
finalColor.z = clamp(finalColor.z, 0.0, _RaytracingIntensityClamp);

// Convert back to HSV space
finalColor = HsvToRgb(finalColor) * GetInverseCurrentExposureMultiplier();
}
else
{
// Expose and clamp the final color
finalColor = clamp(rayIntersection.color * GetCurrentExposureMultiplier(), 0.0, _RaytracingIntensityClamp) * GetInverseCurrentExposureMultiplier();
}

// We store the sampled color and the weight that shall be used for it (1.0)
_SsrLightingTextureRW[COORD_TEXTURE2D_X(currentCoord)] = float4(finalColor, 1.0);
Expand Down