Commit Graph

147 Commits

Author SHA1 Message Date
chris kulla
162107cb91 GPULM: Fix ray tracing payload type runtime error
GPULM flagged some errors at runtime due to a mismatch in payload type with respect to the default hit shader. The path tracing default hit shader should be used instead of the raytracing one.

Refactor functions that find default shaders to be independent of the DeferredRenderer and of the View object (since only a ShaderMap is needed)

Make the binding to the miss shader for GPULM explicit since this should also match the right payload type (and we want to eventually deprecate implicit miss shader bindings)

#jira UE-169205
#rb Yujiang.Wang
#preflight 636a872edc30a4ce96a6fce8

[CL 23031241 by chris kulla in ue5-main branch]
2022-11-08 12:22:31 -05:00
chris kulla
60ddb1867f Hide unused payload structs from shaders which did not declare them
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]
2022-10-28 23:28:11 -04:00
chris kulla
5da8820c19 Redesign the raytracing payload type tagging to use a function instead of a hardcoded field
This allows the raytracing payload type to vary according to shader permutation parameters which is more flexible and simplifies the code for complex cases like Lumen or deferred reflections

#rb Yuriy.ODonnell
#jira none
#preflight 635a8ba96a2a692f5d720eb3

[CL 22809506 by chris kulla in ue5-main branch]
2022-10-27 10:21:14 -04:00
Charles deRousiers
48b3286bc0 Add IES atlas texture manager.
This persistent atlas hold IES texture in a unique texture array which is used by all systems (raster/RT/PT/Lumen), and unify IES profile rendering.

#rb chris.kulla, sebastien.hillaire, krzysztof.narkowicz
#jira UE-167618
#preflight 6356fd907261e565c436a0fb

[CL 22806455 by Charles deRousiers in ue5-main branch]
2022-10-27 04:36:31 -04:00
chris kulla
b00b7d70d0 Organize Ray Tracing shaders by their payload
Every shader now has the ability to declare which payload it uses. HitGroup, Miss and Callable shaders may only specify a single type, whereas Raygen shaders may provide more than one.

The global raytracing shader libraries have been categorized according to their payload type, which helps facilitate the creation of minimal ray-tracing pipelines.

Avoid adding callable shaders to the RTPSO if they are not being used.

All RHI shader compilers and shader loaders that support ray tracing have been modified to track an extra uint representing the payload type flagged in the source (at time of compilation).

Add the RayTracingPayloadType to the shadermap DDC key so that we can properly detect when a shader's payload type is invalidated. This is required because we serialize the payload type into the shaders from the C++ side.

#rb Yuriy.ODonnell
#jira none
#preflight 635715cae6096564af4dd28e

[CL 22742893 by chris kulla in ue5-main branch]
2022-10-24 20:11:02 -04:00
tiantian xie
0a5d859dad Rendering Engine change to support the following two kind of path tracing denoiser plugins at the same time:
1. Spatial denoising only plugin.
  2. Spatial and temporal denoising plugin.

When the user enables both plugins:
  1. The spatial denoising only plugin + builtin temporal denoiser can be selected as (default):

        `r.PathTracing.SpatialDenoiser.Type 0`
  2. The spatial and temporal denoser plugin can be selected as:

        `r.PathTracing.SpatialDenoiser.Type 1`

Note:
  * There is a modification in FRDGBuilder::IsTransient() to make TexCreate_Shared  return false to make it committed resource. Otherwise, the interop will fail when trying to get the device E_Invalidarg (0x80070057).

#jira UE-158838
#preflight 633f20f72a0a2c1ead3a6184
#rb Juan.Canada, Chris.Kulla
#ushell-cherrypick of 21960393 by Tiantian.Xie

[CL 22405452 by tiantian xie in ue5-main branch]
2022-10-07 14:17:00 -04:00
christopher waters
3a23407075 Work around O0 crash in DXC when compiling FPathTracingRG
#jira UE-165154
#preflight 633c4e53a46afe1978926cc4
#rb arciel.rekman, chris.kulla
#lockdown mihnea.balta

[CL 22336282 by christopher waters in ue5-main branch]
2022-10-04 15:16:42 -04:00
jason hoerner
0b1ec407d6 MGPU: Support for specifying GPU mask for RDG textures, to facilitate a hack fix for GPU Lightmass MGPU transition validation assert.
The assert is due to an architectural bug in RDG where resource transitions for a given resource occur at an arbitrary time in the graph execution, due to batching.  The GPU mask can vary, based on which Pass is executing when a transition for a given resource occurs.  This leads to the internal state used for validation being inconsistent on one of the GPUs.  The hack fix is to make it so the offending resource (PathTracer.LightGrid) only exists on one GPU.  This works because the inconsistent transition state happens on a GPU that the resource isn't actually used on, so removing it from that GPU prevents the assert.  The RDG transition bug doesn't come up often, because most graphs run all-GPU work first (GPU scene update), then run to termination on a single mask, but GPU Lightmass switches back and forth.

The longer term plan (for 5.2) is to scope ALL resources so they only exist on the GPUs they are needed on, then make it so transitions ignore the active GPU mask, and instead apply transitions for all GPUs where a given resource is present.  So there will never be a mismatch in transition state across GPUs.  Scoping resources to specific GPUs saves GPU memory and the CPU performance cost of maintaining the resources, so it would be worth doing on its own.  And it provides other advantages in terms of improved validation and potential automation of cross GPU transfers through RDG.  But this was too big a refactor to do for 5.1, especially with Parallel Rendering work in flight, so I went with the hack fix to avoid the crash.

#jira UE-157789
#rb zach.bethel mihnea.balta
#rnx
#preflight 6339cb1df76de2d4d531462b

[CL 22307467 by jason hoerner in ue5-main branch]
2022-10-03 12:51:51 -04:00
aleksander netzel
28183cf9d4 Handle underwater in path tracing:
* For single layer water absorbtion/scattering parameters are only known at the surface
* Add a pass to initialize extinction coefficient by shooting an up-ray from camera to hit the water surface.
* Evaluate material and pass extinction coefficient in a buffer for initializing path state's extinction coefficient.

#rb chris.kulla, yuriy.odonnell
#preflight 631f11295b06877acb808871

[CL 21964062 by aleksander netzel in ue5-main branch]
2022-09-12 09:03:35 -04:00
chris kulla
20b72a912e Fix path tracer materials with AlphaHoldout blending mode
The logic for ShouldCompilePermutation did not exactly match the logic used at runtime, which could lead to the incorrect material being used.

#jira UE-150850
#rb Jason.Nadro
#preflight 631bd95e967ffc68fb38ff44

[CL 21933517 by chris kulla in ue5-main branch]
2022-09-09 20:41:47 -04:00
tiago costa
5d63c9fad9 Added option to apply inverse exposure to local lights
- This should only be used for gameplay lights.
- Current implementation adjusts light intensity on CPU using exposure data readback from GPU.

#preflight 631b4884d31788ea3a993a2f
#rb Krzysztof.Narkowicz

[CL 21929836 by tiago costa in ue5-main branch]
2022-09-09 18:16:47 -04:00
bryan sefcik
07894f4a07 Removed redundant private include paths from build.cs files.
Fixed include paths to be relative to the private or public folders.
Hid or removed includes that reached into other private module folders.
Updated PublicInclude paths when necessary.

#jira
#preflight 631a717cec45fbf3d74d4ba7

[CL 21916033 by bryan sefcik in ue5-main branch]
2022-09-09 00:53:22 -04:00
jason hoerner
3870a93d7d MGPU: Remove "r.AllowMultiGPUInEditor" CVar. This CVar is redundant, because the command line -MaxGPUCount setting is required anyway to enable MGPU.
#jira UE-162959
#rb mihnea.balta
#preflight 631a0679967ffc68fbdbfb31

[CL 21894828 by jason hoerner in ue5-main branch]
2022-09-08 11:35:07 -04:00
jason hoerner
0a02dddc41 Path Tracer MGPU: Perf and synchronization improvements.
* Added "TransferResourceSignal" API to allow signaling that the destination GPU of a cross GPU transfer is done using a given resource, and it's safe for a source GPU to start copying to it.  Wanted to get this API level change into 5.1, as it could be used for various MGPU bugs and features going forward.
* Used new API in Path Tracer to fix potential bugs caused by cross GPU copy overlapping with rendering to the destination resource.
* Do multiple passes per frame based on the number of GPUs active, to reduce amortized overhead for cross GPU copies and other frame related work, and avoid situations where performance doesn't increase when rendering is CPU bound.  In a purely CPU bound case, performance doubles, while in a GPU bound case, performance increases by 6%.

#jira none
#rnx
#rb chris.kulla jason.nadro mihnea.balta
#preflight 6310ecaae74078cfcdbfba37

[CL 21759166 by jason hoerner in ue5-main branch]
2022-09-02 10:36:32 -04:00
jason hoerner
2dcf98af12 Path Tracing: fix for profiling with multiple GPUs.
Scoped the root timing block of the scene renderer to all GPUs when the path tracer is active, so child profiling blocks on any GPU can show up (the GPU profiler discards timing intervals where any event in the hierarchy isn't active on a given GPU).  Also subdivided the path tracer into more timing blocks, to solve the same issue within the path tracer, and allow multi-GPU work, cross GPU copy, and single-GPU post processing to be differentiated.

#jira NONE
#rnx
#rb chris.kulla
#preflight 630a75c8f92416fb9238cec0

[CL 21685581 by jason hoerner in ue5-main branch]
2022-08-29 15:15:51 -04:00
Guillaume Abadie
dea57d98b9 Adds DOF squeeze factor support to path tracer.
#rb chris.kulla
#jira none
#preflight 63039d0433729407e891731b

[CL 21485998 by Guillaume Abadie in ue5-main branch]
2022-08-22 12:55:03 -04:00
christopher waters
e9a48d6897 Removing more uses of GMaxRHIFeatureLevel.
Focus started on GenerateMips and AddClearUAVPass.

#jira none
#rb mihnea.balta
#preflight 62fe768d200ff87e07c5e1ad

[CL 21448320 by christopher waters in ue5-main branch]
2022-08-18 15:29:29 -04:00
chris kulla
1665081912 Fix function name clash in unity build
#jira UE-158690
#rb trivial
#preflight 62c5befa097ca6afc4f1b1d6

[CL 20968822 by chris kulla in ue5-main branch]
2022-07-06 13:02:49 -04:00
chris kulla
ce3055b11c Path Tracer: Default light functions to be greyscale like the deferred renderer, with a cvar to toggle colored light functions if needed.
#rb trivial
#jira UE-107027
#preflight 62c5b7232a05d4f55b096669

[CL 20968744 by chris kulla in ue5-main branch]
2022-07-06 12:52:23 -04:00
chris kulla
46c135a57f Path Tracer: Light function material support
#jira UE-107027
#rb Yuriy.ODonnell

Extend the recently added raytraced light function support to the path tracer. Unlike in Ray Tracing which must retain visual compatibility with the deferred renderer, the path tracing implementation supports colored light functions.

Also guard the logic for miss shaders in DeferredRendering to avoid issues on platforms that support ray tracing but not ray tracing shaders yet (Vulkan).
#preflight 62c500bb2a05d4f55be9ff6b

[CL 20957938 by chris kulla in ue5-main branch]
2022-07-05 23:42:37 -04:00
tiago costa
4d36069905 Improved ray tracing decals checks.
- Ray tracing decal grid is only created (CreateRayTracingDecalData(...)) if ShouldPrepareRayTracingDecals().
- ShouldPrepareRayTracingDecals() checks whether runtime supports the feature, there's decals in the scene, and any technique actually uses decals (currently only PathTracing).
- Added bHasRayTracingDecals to FViewInfo since RayTracingDecalUniformBuffer always has a valid uniform buffer (but might not contain any decals).
    - Techniques check bHasRayTracingDecals decide whether to use permutations that use decals.

#rb chris.kulla
#preflight 62b5f3527c36e1309759a17e

[CL 20813032 by tiago costa in ue5-main branch]
2022-06-24 14:01:41 -04:00
chris kulla
eefd5a5b99 Path Tracer: enable progress display by default and reduce the default SPP to 2048
#preflight 62b1e90c8e03312ad86cc2be

[CL 20759133 by chris kulla in ue5-main branch]
2022-06-21 12:05:30 -04:00
Tiantian Xie
58704dbb7a Fix path tracing denoiser for interactive rendering.
#jira none
#rb Chris.Kulla
#preflight 62abba335c69124c409a1517

[CL 20697441 by Tiantian Xie in ue5-main branch]
2022-06-16 19:23:05 -04:00
Tiantian Xie
7a07d9353e Add experimental temporal denoising for offline path tracing that is spatially denoised. It gives a final touch to mitigate the temporal instability while preserving fine details.
Basic algorithm:

Estimate the pixel correspondences (motion vectors) to the previous frame where their local patches match the best using non-local means. Then history is combined with the current frame with a temporal low pass filter (exponential moving average & temporal bilaterial filtering). To better control the parameters, we use perception error DeltaE2000. Pixel difference larger than 10 dE is rejected for detail preserving.

How to enable:

Add `r.PathTracing.TemporalDenoiser 1` in MRQ console variables when path tracing denoising is enabled in postprocess volume.


#jira UE-136319
#rb chris.kulla
#preflight 62aa28dca40a4dc3a0412e2f

[CL 20675469 by Tiantian Xie in ue5-main branch]
2022-06-15 15:25:49 -04:00
tiago costa
fc62d1fc0e 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]
2022-05-26 05:59:55 -04:00