You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
This is meant to help avoid inconsistencies between GetRayTracingPayloadType() and the shader code. As an example of the usage, convert RayTracingDebug related shaders to only enable the payload conditionally. Fix the current incorrect mixing of payload uses in the same shader by introducing a permutation for the material version of the debug shader vs. the one that uses the debug payload (this was previously a runtime shader parameter only which implied two different payloads could theoretically be compiled into one RTPSO). Also conditionaly enable some of the simpler payload types like the niagara and decal ones that are only used in a few places. Other payloads will be handled in future refactors. Split RayTracingDebug.usf into smaller files that only have one raytracing entry in them to reduce the amount of counditional logic needed around payloads. #rb Yuriy.ODonnell #jira none #preflight 635c49e9ae6840072d4df82f [CL 22849513 by chris kulla in ue5-main branch]
62 lines
2.2 KiB
Plaintext
62 lines
2.2 KiB
Plaintext
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "../Common.ush"
|
|
#include "RayTracingDebugUtils.ush"
|
|
|
|
#include "/Engine/Shared/RayTracingDebugTypes.h"
|
|
|
|
uint OpaqueOnly;
|
|
|
|
RaytracingAccelerationStructure TLAS;
|
|
|
|
StructuredBuffer<FRayTracingInstanceDebugData> InstancesDebugData;
|
|
StructuredBuffer<FRayTracingPickingFeedback> PickingBuffer;
|
|
|
|
RWStructuredBuffer<FRayTracingPickingFeedback> PickingOutput;
|
|
StructuredBuffer<FRayTracingInstanceDescriptor> InstanceBuffer;
|
|
|
|
RAY_TRACING_ENTRY_RAYGEN(RayTracingDebugPickingRGS)
|
|
{
|
|
const uint2 PixelPos = (float2(View.CursorPosition) * View.ViewResolutionFraction);
|
|
float2 RenderTargetUV = (float2(PixelPos) + .5f) * View.BufferSizeAndInvSize.zw;
|
|
|
|
FRayDesc Ray = CreatePrimaryRay(RenderTargetUV);
|
|
|
|
const uint InstanceInclusionMask = (OpaqueOnly ? RAY_TRACING_MASK_OPAQUE : RAY_TRACING_MASK_ALL);
|
|
|
|
FRayTracingDebugPayload Payload = (FRayTracingDebugPayload)0;
|
|
Payload.SetMiss();
|
|
|
|
TraceRay(
|
|
TLAS,
|
|
RAY_FLAG_CULL_BACK_FACING_TRIANGLES /*RayFlags*/,
|
|
InstanceInclusionMask,
|
|
0 /*RayContributionToHitGroupIndex*/,
|
|
RAY_TRACING_NUM_SHADER_SLOTS /*MultiplierForGeometryContributionToShaderIndex*/,
|
|
0 /*MissShaderIndex*/,
|
|
Ray.GetNativeDesc(),
|
|
Payload);
|
|
|
|
FRayTracingPickingFeedback PickingFeedback = (FRayTracingPickingFeedback)0xFFFFFFFFu;
|
|
|
|
if (Payload.IsHit())
|
|
{
|
|
FRayTracingInstanceDebugData InstanceDebugData = InstancesDebugData[Payload.GeometryInstanceIndex];
|
|
FRayTracingInstanceDescriptor InstanceDescriptor = InstanceBuffer[Payload.InstanceIndex];
|
|
|
|
PickingFeedback.GeometryAddress = InstanceDebugData.GeometryAddress;
|
|
|
|
PickingFeedback.InstanceIndex = Payload.InstanceIndex;
|
|
PickingFeedback.GeometryInstanceIndex = Payload.GeometryInstanceIndex;
|
|
PickingFeedback.TriangleIndex = Payload.TriangleIndex;
|
|
PickingFeedback.GeometryIndex = Payload.GeometryIndex;
|
|
|
|
PickingFeedback.InstanceId = GetRayTracingInstanceDescriptorInstanceId(InstanceDescriptor);
|
|
PickingFeedback.Flags = GetRayTracingInstanceDescriptorFlags(InstanceDescriptor);
|
|
PickingFeedback.Mask = GetRayTracingInstanceDescriptorMask(InstanceDescriptor);
|
|
PickingFeedback.InstanceContributionToHitGroupIndex = GetRayTracingInstanceDescriptorInstanceContributionToHitGroupIndex(InstanceDescriptor);
|
|
}
|
|
|
|
PickingOutput[0] = PickingFeedback;
|
|
}
|