Files
UnrealEngineUWP/Engine/Shaders/Private/PathTracing/PathTracingDefaultHitShader.usf
chris kulla 4591aab281 Path Tracing: Refactor path tracing code to minimize material/blend type related special cases in the integrator
Revisit payload encoding to handle blend mode logic entirely in the shader. This removes the need for a blendmode field and simplifies the logic in the raygen shader, reducing the amount of switch statements. We also gain back 3 extra bits that can be spent on output flags.

Refactor how random walk selection is performed to avoid shadingmodel specific code in the integrator. Also refactor the code to allow transparency to be combined with SSS.

Unify the handling of SingleLayerWater and solid glass since they were mostly sharing the same code. Both cases now use the DEFAULT_LIT shading model. This required extending the logic for camera medium tracking a bit. It now always runs (with a cvar to turn it off for debugging) instead of being tied to View.IsUnderwater() which could only work for water geometry. This makes it possible to achieve the under-water effect with regular refractive materials as well.

#rb Aleksander.Netzel
#jira none
#preflight 63efbaa090198dffbafaaf38

[CL 24286321 by chris kulla in ue5-main branch]
2023-02-17 13:15:33 -05:00

53 lines
1.5 KiB
Plaintext

#include "/Engine/Private/Common.ush"
#include "/Engine/Private/RayTracing/RayTracingCommon.ush"
#include "/Engine/Private/PathTracing/PathTracingCommon.ush"
RAY_TRACING_ENTRY_CLOSEST_HIT(PathTracingDefaultOpaqueCHS,
FPackedPathTracingPayload, PackedPayload,
FRayTracingIntersectionAttributes, Attributes)
{
if (PackedPayload.IsVisibilityRay())
{
// mark shadow fully opaque
PackedPayload.SetRayThroughput(0.0);
}
else
{
// mark hit as solid black
FPathTracingPayload Payload = (FPathTracingPayload)0;
Payload.ShadingModelID = SHADINGMODELID_UNLIT;
Payload.BSDFOpacity = 1.0;
PackedPayload = PackPathTracingPayload(Payload);
}
PackedPayload.HitT = RayTCurrent();
}
RAY_TRACING_ENTRY_CLOSEST_HIT(PathTracingDefaultHiddenCHS,
FPackedPathTracingPayload, PackedPayload,
FRayTracingIntersectionAttributes, Attributes)
{
// This is not reachable in theory since AHS calls IgnoreHit(), but could be if the mesh gets flagged with ForceOpaque (or the ray ignores AHS)
if (PackedPayload.IsVisibilityRay())
{
// don't change the throughput (object should be invisible)
}
else
{
// mark hit as fully transparent
FPathTracingPayload Payload = (FPathTracingPayload)0;
Payload.ShadingModelID = SHADINGMODELID_UNLIT;
Payload.TransparencyColor = 1.0;
PackedPayload = PackPathTracingPayload(Payload);
}
PackedPayload.HitT = RayTCurrent();
}
RAY_TRACING_ENTRY_ANY_HIT(PathTracingDefaultHiddenAHS,
FPackedPathTracingPayload, PackedPayload,
FRayTracingIntersectionAttributes, Attributes)
{
IgnoreHit();
}