Skip to content

Commit

Permalink
[HDRP][Path Tracing] Camera ray misses now return a null value with M…
Browse files Browse the repository at this point in the history
…inimum Depth > 1 (#6067)

* Minor change when setting min depth > 1: camera misses are now black.

* Updated changelog.
  • Loading branch information
eturquin committed Oct 20, 2021
1 parent fd35b0f commit 2a77472
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
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 @@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Use RayTracingAccelerationStructure.CullInstances to filter Renderers and populate the acceleration structure with ray tracing instances for improved CPU performance on the main thread.
- Changed the max distance for Light Anchors to avoid unstability with high values (case 1362802).
- PrepareLightsForGPU CPU Light loop performance improvement (40% to 70% faster), utilizing burst and optimized. Utilizing better sorting, distributing work in jobs and improving cache access of light data.
- In path tracing, camera ray misses now return a null value with Minimum Depth > 1.

## [13.1.0] - 2021-09-24

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,22 @@ RW_TEXTURE2D_X(float4, _FrameTexture);
[shader("miss")]
void MissCamera(inout PathIntersection pathIntersection : SV_RayPayload)
{
// In indirect-only mode, it makes more sense to return a null value
if (_RaytracingMinRecursion > 1)
{
pathIntersection.value = 0.0;
pathIntersection.alpha = 0.0;
return;
}

bool skyEnabled = _EnvLightSkyEnabled && _RaytracingCameraSkyEnabled;
float4 missColor = skyEnabled ? _SkyCameraTexture[COORD_TEXTURE2D_X(pathIntersection.pixelCoord)] : _RaytracingCameraClearColor;
pathIntersection.value = missColor.xyz * GetInverseCurrentExposureMultiplier();
pathIntersection.alpha = missColor.w;
pathIntersection.value = missColor.rgb * GetInverseCurrentExposureMultiplier();
pathIntersection.alpha = missColor.a;

ApplyFogAttenuation(WorldRayOrigin(), WorldRayDirection(), pathIntersection.value, pathIntersection.alpha);

if (_EnableVolumetricFog && _RaytracingMinRecursion <= 1)
if (_EnableVolumetricFog)
{
float3 lightPosition, envValue = pathIntersection.value;

Expand Down Expand Up @@ -85,7 +93,7 @@ void MissMaterial(inout PathIntersection pathIntersection : SV_RayPayload)
return;
}

pathIntersection.value = _EnvLightSkyEnabled ? SampleSkyTexture(WorldRayDirection(), 0.0, 0).xyz : 0.0;
pathIntersection.value = _EnvLightSkyEnabled ? SampleSkyTexture(WorldRayDirection(), 0.0, 0).rgb : 0.0;
ApplyFogAttenuation(WorldRayOrigin(), WorldRayDirection(), pathIntersection.value);
}

Expand Down

0 comments on commit 2a77472

Please sign in to comment.