You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Initial support for deferred decals in path tracer.
- Decals materials are evaluated using callable shaders in PathTracingKernel. - Decals are culled using a 2D grid similar to the existing light grid. - In order to correctly handle decal blending order, decals are sorted using the same logic as the rasterizer on CPU. The compute shader that builds the decal grid maintains the correct order. - Decal materials are wrapped in FRayTracingDecalMaterialShader. The instance parameters of each decal are bound using uniform buffers. #preflight 628f3fed2f2409bc1e7a6414 #rb Yuriy.ODonnell, chris.kulla, Jeremy.Moore [CL 20377336 by tiago costa in ue5-main branch]
This commit is contained in:
@@ -1,38 +1,39 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
/*================================================================================================
|
||||
RayTracingDefinitions.h: used in ray tracing shaders and C++ code to define common constants
|
||||
!!! Changing this file requires recompilation of the engine !!!
|
||||
=================================================================================================*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// Change this to force recompilation of all ray tracing shaders (use https://www.random.org/cgi-bin/randbyte?nbytes=4&format=h)
|
||||
// This avoids changing the global ShaderVersion.ush and forcing recompilation of all shaders in the engine (only RT shaders will be affected)
|
||||
#define RAY_TRACING_SHADER_VERSION 0x41d29fc9
|
||||
|
||||
#define RAY_TRACING_REGISTER_SPACE_LOCAL 0 // default register space for hit group (closest hit, any hit, intersection) shader resources
|
||||
#define RAY_TRACING_REGISTER_SPACE_GLOBAL 1 // register space for ray generation and miss shaders
|
||||
#define RAY_TRACING_REGISTER_SPACE_SYSTEM 2 // register space for "system" parameters (index buffer, vertex buffer, fetch parameters)
|
||||
|
||||
#define RAY_TRACING_MASK_OPAQUE 0x01 // Opaque and alpha tested meshes and particles (e.g. used by reflection, shadow, AO and GI tracing passes)
|
||||
#define RAY_TRACING_MASK_TRANSLUCENT 0x02 // Opaque and alpha tested meshes and particles (e.g. used by translucency tracing pass)
|
||||
#define RAY_TRACING_MASK_THIN_SHADOW 0x04 // Whether the thin geometry (e.g. hair) is visible for shadow rays
|
||||
#define RAY_TRACING_MASK_SHADOW 0x08 // Whether the geometry is visible for shadow rays
|
||||
#define RAY_TRACING_MASK_SCENE_CAPTURE 0x10 // Whether the geometry is visible when rendering scene capture views
|
||||
#define RAY_TRACING_MASK_FAR_FIELD 0x20
|
||||
#define RAY_TRACING_MASK_ALL 0xFF
|
||||
|
||||
#define RAY_TRACING_SHADER_SLOT_MATERIAL 0
|
||||
#define RAY_TRACING_SHADER_SLOT_SHADOW 1
|
||||
#define RAY_TRACING_NUM_SHADER_SLOTS 2
|
||||
|
||||
#define RAY_TRACING_MISS_SHADER_SLOT_DEFAULT 0 // Main miss shader that simply sets HitT to a "miss" value (see FMinimalPayload::SetMiss())
|
||||
#define RAY_TRACING_MISS_SHADER_SLOT_LIGHTING 1 // Miss shader that may be used to evaluate light source radiance in ray traced reflections and translucency
|
||||
#define RAY_TRACING_NUM_MISS_SHADER_SLOTS 2
|
||||
|
||||
#define RAY_TRACING_LIGHT_COUNT_MAXIMUM 256
|
||||
|
||||
#define RAY_TRACING_MAX_ALLOWED_RECURSION_DEPTH 1 // Only allow ray tracing from RayGen shader
|
||||
#define RAY_TRACING_MAX_ALLOWED_ATTRIBUTE_SIZE 8 // Sizeof 2 floats (barycentrics)
|
||||
#define RAY_TRACING_MAX_ALLOWED_PAYLOAD_SIZE 64 // Our maximum allowed payload size (sizeof FPackedMaterialClosestHitPayload)
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
/*================================================================================================
|
||||
RayTracingDefinitions.h: used in ray tracing shaders and C++ code to define common constants
|
||||
!!! Changing this file requires recompilation of the engine !!!
|
||||
=================================================================================================*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// Change this to force recompilation of all ray tracing shaders (use https://www.random.org/cgi-bin/randbyte?nbytes=4&format=h)
|
||||
// This avoids changing the global ShaderVersion.ush and forcing recompilation of all shaders in the engine (only RT shaders will be affected)
|
||||
#define RAY_TRACING_SHADER_VERSION 0x41d29fc9
|
||||
|
||||
#define RAY_TRACING_REGISTER_SPACE_LOCAL 0 // default register space for hit group (closest hit, any hit, intersection) shader resources
|
||||
#define RAY_TRACING_REGISTER_SPACE_GLOBAL 1 // register space for ray generation and miss shaders
|
||||
#define RAY_TRACING_REGISTER_SPACE_SYSTEM 2 // register space for "system" parameters (index buffer, vertex buffer, fetch parameters)
|
||||
|
||||
#define RAY_TRACING_MASK_OPAQUE 0x01 // Opaque and alpha tested meshes and particles (e.g. used by reflection, shadow, AO and GI tracing passes)
|
||||
#define RAY_TRACING_MASK_TRANSLUCENT 0x02 // Opaque and alpha tested meshes and particles (e.g. used by translucency tracing pass)
|
||||
#define RAY_TRACING_MASK_THIN_SHADOW 0x04 // Whether the thin geometry (e.g. hair) is visible for shadow rays
|
||||
#define RAY_TRACING_MASK_SHADOW 0x08 // Whether the geometry is visible for shadow rays
|
||||
#define RAY_TRACING_MASK_SCENE_CAPTURE 0x10 // Whether the geometry is visible when rendering scene capture views
|
||||
#define RAY_TRACING_MASK_FAR_FIELD 0x20
|
||||
#define RAY_TRACING_MASK_ALL 0xFF
|
||||
|
||||
#define RAY_TRACING_SHADER_SLOT_MATERIAL 0
|
||||
#define RAY_TRACING_SHADER_SLOT_SHADOW 1
|
||||
#define RAY_TRACING_NUM_SHADER_SLOTS 2
|
||||
|
||||
#define RAY_TRACING_MISS_SHADER_SLOT_DEFAULT 0 // Main miss shader that simply sets HitT to a "miss" value (see FMinimalPayload::SetMiss())
|
||||
#define RAY_TRACING_MISS_SHADER_SLOT_LIGHTING 1 // Miss shader that may be used to evaluate light source radiance in ray traced reflections and translucency
|
||||
#define RAY_TRACING_NUM_MISS_SHADER_SLOTS 2
|
||||
|
||||
#define RAY_TRACING_LIGHT_COUNT_MAXIMUM 256
|
||||
#define RAY_TRACING_DECAL_COUNT_MAXIMUM 256
|
||||
|
||||
#define RAY_TRACING_MAX_ALLOWED_RECURSION_DEPTH 1 // Only allow ray tracing from RayGen shader
|
||||
#define RAY_TRACING_MAX_ALLOWED_ATTRIBUTE_SIZE 8 // Sizeof 2 floats (barycentrics)
|
||||
#define RAY_TRACING_MAX_ALLOWED_PAYLOAD_SIZE 64 // Our maximum allowed payload size (sizeof FPackedMaterialClosestHitPayload)
|
||||
|
||||
@@ -1,93 +1,113 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
/*================================================================================================
|
||||
RayTracingTypes.h: used in ray tracing shaders and C++ code to define common types
|
||||
!!! Changing this file requires recompilation of the engine !!!
|
||||
=================================================================================================*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
// C++ representation of a light for the path tracer
|
||||
// #dxr_todo: Unify this with FRTLightingData ?
|
||||
struct FPathTracingLight {
|
||||
// FVector3f RelativeWorldPosition;
|
||||
// FVector3f TilePosition;
|
||||
FVector3f TranslatedWorldPosition;
|
||||
FVector3f Normal;
|
||||
FVector3f dPdu;
|
||||
FVector3f dPdv;
|
||||
FVector3f Color;
|
||||
FVector2f Dimensions; // Radius,Length or RectWidth,RectHeight or Sin(Angle/2),0 depending on light type
|
||||
FVector2f Shaping; // Barndoor controls for RectLights, Cone angles for spots lights
|
||||
float Attenuation;
|
||||
float FalloffExponent; // for non-inverse square decay lights only
|
||||
float VolumetricScatteringIntensity; // scale for volume contributions
|
||||
int32 IESTextureSlice;
|
||||
uint32 Flags; // see defines PATHTRACER_FLAG_*
|
||||
FVector3f TranslatedBoundMin;
|
||||
FVector3f TranslatedBoundMax;
|
||||
uint32 RectLightAtlasUVScale; // Rect. light atlas UV transformation, encoded as f16x2
|
||||
uint32 RectLightAtlasUVOffset; // Rect. light atlas UV transformation, encoded as f16x2
|
||||
// keep structure aligned
|
||||
};
|
||||
|
||||
static_assert(sizeof(FPathTracingLight) == 128, "Path tracing light structure should be aligned to 128 bytes for optimal access on the GPU");
|
||||
|
||||
struct FPathTracingPackedPathState {
|
||||
uint32 PixelIndex;
|
||||
uint32 RandSeqSampleIndex;
|
||||
uint32 RandSeqSampleSeed;
|
||||
FVector3f Radiance;
|
||||
float BackgroundVisibility;
|
||||
uint16 Albedo[3];
|
||||
uint16 Normal[3];
|
||||
FVector3f RayOrigin;
|
||||
FVector3f RayDirection;
|
||||
FVector3f PathThroughput;
|
||||
uint16 PathRoughness;
|
||||
uint16 SigmaT[3];
|
||||
};
|
||||
|
||||
static_assert(sizeof(FPathTracingPackedPathState) == 84, "Packed Path State size should be minimized");
|
||||
|
||||
#else
|
||||
|
||||
// HLSL side of the structs above
|
||||
|
||||
struct FPathTracingLight {
|
||||
// float3 RelativeWorldPosition;
|
||||
// float3 TilePosition;
|
||||
float3 TranslatedWorldPosition;
|
||||
float3 Normal;
|
||||
float3 dPdu;
|
||||
float3 dPdv;
|
||||
float3 Color;
|
||||
float2 Dimensions;
|
||||
float2 Shaping;
|
||||
float Attenuation;
|
||||
float FalloffExponent;
|
||||
float VolumetricScatteringIntensity; // scale for volume contributions
|
||||
int IESTextureSlice;
|
||||
uint Flags;
|
||||
float3 TranslatedBoundMin;
|
||||
float3 TranslatedBoundMax;
|
||||
uint RectLightAtlasUVScale;
|
||||
uint RectLightAtlasUVOffset;
|
||||
};
|
||||
|
||||
struct FPathTracingPackedPathState {
|
||||
uint PixelIndex;
|
||||
uint RandSeqSampleIndex;
|
||||
uint RandSeqSampleSeed;
|
||||
float3 Radiance;
|
||||
float BackgroundVisibility;
|
||||
uint3 PackedAlbedoNormal;
|
||||
float3 RayOrigin;
|
||||
float3 RayDirection;
|
||||
float3 PathThroughput;
|
||||
uint2 PackedRoughnessSigma;
|
||||
};
|
||||
|
||||
#endif
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
/*================================================================================================
|
||||
RayTracingTypes.h: used in ray tracing shaders and C++ code to define common types
|
||||
!!! Changing this file requires recompilation of the engine !!!
|
||||
=================================================================================================*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
// C++ representation of a light for the path tracer
|
||||
// #dxr_todo: Unify this with FRTLightingData ?
|
||||
struct FPathTracingLight {
|
||||
// FVector3f RelativeWorldPosition;
|
||||
// FVector3f TilePosition;
|
||||
FVector3f TranslatedWorldPosition;
|
||||
FVector3f Normal;
|
||||
FVector3f dPdu;
|
||||
FVector3f dPdv;
|
||||
FVector3f Color;
|
||||
FVector2f Dimensions; // Radius,Length or RectWidth,RectHeight or Sin(Angle/2),0 depending on light type
|
||||
FVector2f Shaping; // Barndoor controls for RectLights, Cone angles for spots lights
|
||||
float Attenuation;
|
||||
float FalloffExponent; // for non-inverse square decay lights only
|
||||
float VolumetricScatteringIntensity; // scale for volume contributions
|
||||
int32 IESTextureSlice;
|
||||
uint32 Flags; // see defines PATHTRACER_FLAG_*
|
||||
FVector3f TranslatedBoundMin;
|
||||
FVector3f TranslatedBoundMax;
|
||||
uint32 RectLightAtlasUVScale; // Rect. light atlas UV transformation, encoded as f16x2
|
||||
uint32 RectLightAtlasUVOffset; // Rect. light atlas UV transformation, encoded as f16x2
|
||||
// keep structure aligned
|
||||
};
|
||||
|
||||
static_assert(sizeof(FPathTracingLight) == 128, "Path tracing light structure should be aligned to 128 bytes for optimal access on the GPU");
|
||||
|
||||
struct FPathTracingPackedPathState {
|
||||
uint32 PixelIndex;
|
||||
uint32 RandSeqSampleIndex;
|
||||
uint32 RandSeqSampleSeed;
|
||||
FVector3f Radiance;
|
||||
float BackgroundVisibility;
|
||||
uint16 Albedo[3];
|
||||
uint16 Normal[3];
|
||||
FVector3f RayOrigin;
|
||||
FVector3f RayDirection;
|
||||
FVector3f PathThroughput;
|
||||
uint16 PathRoughness;
|
||||
uint16 SigmaT[3];
|
||||
};
|
||||
|
||||
static_assert(sizeof(FPathTracingPackedPathState) == 84, "Packed Path State size should be minimized");
|
||||
|
||||
// C++ representation of a decal for ray tracing
|
||||
struct FRayTracingDecal
|
||||
{
|
||||
FVector3f TranslatedBoundMin;
|
||||
uint32 Pad0;
|
||||
FVector3f TranslatedBoundMax;
|
||||
uint32 CallableSlotIndex;
|
||||
// keep structure aligned
|
||||
};
|
||||
|
||||
static_assert(sizeof(FRayTracingDecal) == 32, "Ray tracing decal structure should be aligned to 32 bytes for optimal access on the GPU");
|
||||
|
||||
#else
|
||||
|
||||
// HLSL side of the structs above
|
||||
|
||||
struct FPathTracingLight {
|
||||
// float3 RelativeWorldPosition;
|
||||
// float3 TilePosition;
|
||||
float3 TranslatedWorldPosition;
|
||||
float3 Normal;
|
||||
float3 dPdu;
|
||||
float3 dPdv;
|
||||
float3 Color;
|
||||
float2 Dimensions;
|
||||
float2 Shaping;
|
||||
float Attenuation;
|
||||
float FalloffExponent;
|
||||
float VolumetricScatteringIntensity; // scale for volume contributions
|
||||
int IESTextureSlice;
|
||||
uint Flags;
|
||||
float3 TranslatedBoundMin;
|
||||
float3 TranslatedBoundMax;
|
||||
uint RectLightAtlasUVScale;
|
||||
uint RectLightAtlasUVOffset;
|
||||
};
|
||||
|
||||
struct FPathTracingPackedPathState {
|
||||
uint PixelIndex;
|
||||
uint RandSeqSampleIndex;
|
||||
uint RandSeqSampleSeed;
|
||||
float3 Radiance;
|
||||
float BackgroundVisibility;
|
||||
uint3 PackedAlbedoNormal;
|
||||
float3 RayOrigin;
|
||||
float3 RayDirection;
|
||||
float3 PathThroughput;
|
||||
uint2 PackedRoughnessSigma;
|
||||
};
|
||||
|
||||
struct FRayTracingDecal
|
||||
{
|
||||
float3 TranslatedBoundMin;
|
||||
uint Pad0;
|
||||
float3 TranslatedBoundMax;
|
||||
uint CallableSlotIndex;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user