Skip to content
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 @@ -60,6 +60,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Moved AMD FidelityFX shaders to core
- Improved sampling of overlapping point/area lights in path-traced volumetric scattering (case 1358777).
- Path-traced volumetric scattering now takes fog color into account, adding scattered contribution on top of the non-scattered result (cases 1346105, 1358783).
- Fixed minor readability issues in the ray tracing code.

## [12.0.0] - 2021-01-11

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/NormalBuffer.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RayTracingCommon.hlsl"

#define RAY_BINNING_TILE_SIZE 16
#define BINNING_TILE_SIZE 16
Expand All @@ -30,7 +32,7 @@ void RAY_BINNING(uint2 groupThreadId : SV_GroupThreadID, uint3 dispatchThreadId
uint2 currentCoord = groupId * RAY_BINNING_TILE_SIZE + groupThreadId.xy;

#if HALF_RESOLUTION
currentCoord *= 2;
currentCoord = ComputeSourceCoordinates(currentCoord, _RaytracingFrameIndex);
#endif

// Initialize the invalid counter to 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingLightLoop.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Common/AtmosphericScatteringRayTracing.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RayTracingFallbackHierarchy.cs.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RayTracingCommon.hlsl"

#define RAYTRACING_DEFERRED_TILE_SIZE 8

Expand All @@ -48,7 +49,7 @@ void RAYTRACING_DEFERRED(uint3 dispatchThreadId : SV_DispatchThreadID, uint2 gro
uint2 currentCoord = groupId * RAYTRACING_DEFERRED_TILE_SIZE + groupThreadId;

#ifdef HALF_RESOLUTION
currentCoord *=2;
currentCoord = ComputeSourceCoordinates(currentCoord, _RaytracingFrameIndex);
#endif

// Initialize the output buffer
Expand All @@ -71,7 +72,7 @@ void RAYTRACING_DEFERRED(uint3 dispatchThreadId : SV_DispatchThreadID, uint2 gro

float3 finalColor = 0.0f;
// if the distance is exactly zero, this means we are facing an environement ray that we need to evaluate
if (rayDistance == 0.0f)
if (RayTracingGBufferIsSky(rayDistance))
{
// Weight value used to do the blending
float weight = 0.0;
Expand All @@ -96,7 +97,7 @@ void RAYTRACING_DEFERRED(uint3 dispatchThreadId : SV_DispatchThreadID, uint2 gro
finalColor = HsvToRgb(finalColor);
}
}
else if (rayDistance < 0.0f)
else if (RayTracingGBufferIsUnlit(rayDistance))
{
finalColor = LOAD_TEXTURE2D_X(_GBufferTexture3, currentCoord).rgb;

Expand All @@ -119,7 +120,7 @@ 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 (rayDistance <= 0.0f)
if (!RayTracingGBufferIsLit(rayDistance))
{
_RaytracingLitBufferRW[COORD_TEXTURE2D_X(currentCoord)] = float4(finalColor * (_RaytracingPreExposition ? 1.0 : GetInverseCurrentExposureMultiplier()), 0.0);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ uint _RayBinTileViewOffset;
[shader("miss")]
void MissShaderGBuffer(inout RayIntersectionGBuffer rayIntersection : SV_RayPayload)
{
rayIntersection.t = 0;
rayIntersection.t = RAY_TRACING_DISTANCE_FLAG_SKY;
}

struct PixelCoordinates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,23 @@ uint2 ComputeSourceCoordinates(uint2 halfResCoord, int frameIndex)
{
return halfResCoord * 2;
}

// These need to be negative for RayDistanceIndicatesHitSkyOrUnlit
#define RAY_TRACING_DISTANCE_FLAG_UNLIT -1.0
#define RAY_TRACING_DISTANCE_FLAG_SKY 0.0

bool RayTracingGBufferIsUnlit(float rayDistance)
{
return rayDistance < 0.0;
}

bool RayTracingGBufferIsSky(float rayDistance)
{
return rayDistance == RAY_TRACING_DISTANCE_FLAG_SKY;
}

bool RayTracingGBufferIsLit(float rayDistance)
{
return rayDistance > 0.0;
}
#endif // RAY_TRACING_COMMON_HLSL
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void ClosestHitGBuffer(inout RayIntersectionGBuffer rayIntersectionGbuffer : SV_

// Then export it to the gbuffer
EncodeIntoStandardGBuffer(standardLitData, rayIntersectionGbuffer.gbuffer0, rayIntersectionGbuffer.gbuffer1, rayIntersectionGbuffer.gbuffer2, rayIntersectionGbuffer.gbuffer3);
rayIntersectionGbuffer.t = standardLitData.isUnlit != 0 ? -1 : RayTCurrent();
rayIntersectionGbuffer.t = standardLitData.isUnlit != 0 ? RAY_TRACING_DISTANCE_FLAG_UNLIT : RayTCurrent();
}

// Generic function that handles the reflection code
Expand Down