Commit Graph

144 Commits

Author SHA1 Message Date
daniel wright
56d35020a1 Lumen Reflections now sample SceneColor on hit (both SWRT and HWRT), to cover over the regions where Screen Traces gave up where they went behind an object. Improves reflection quality under foreground objects. r.Lumen.Reflections.SampleSceneColorAtHit
Cost is .03ms on 2080TI at 1080p
Fixed Lumen Reflection Screen Traces outputting too far of a distance when fading out at the edges of the screen
Added r.AOGlobalDistanceFieldForceUpdateOnce to allow working around Mesh SDF streaming latency

[CL 23147835 by daniel wright in ue5-main branch]
2022-11-15 19:40:26 -05:00
tiago costa
7e6e489420 Track PrimitiveModifiedBounds using FBox instead of FRenderBounds to avoid precision issues in LWC.
#preflight 636e67ea0c74adb48b567ed7

[CL 23097929 by tiago costa in ue5-main branch]
2022-11-11 10:24:43 -05:00
tiago costa
32c2e06e05 Use GetSize() instead of 2 * GetExtent() in GlobalDistanceField.cpp
#preflight skip

[CL 23091092 by tiago costa in ue5-main branch]
2022-11-10 20:00:19 -05:00
tiago costa
7b4f3d2b77 Clean up Global SDF update frequency logic
#rb daniel.wright, krzysztof.narkowicz
#preflight 636acf35ed07daaa9a2e1c64

[CL 23041041 by tiago costa in ue5-main branch]
2022-11-08 17:07:28 -05:00
tiago costa
884f3d3c8a Don't bind view uniform buffer to Global SDF update shaders
#rb none
#preflight 63610b91731604696a0975fc

[CL 22880212 by tiago costa in ue5-main branch]
2022-11-01 08:21:14 -04:00
krzysztof narkowicz
297e617fbf Automatically enable GPU shader print when toggling Global SDF and Lumen debugging CVars using it.
[CL 22792913 by krzysztof narkowicz in ue5-main branch]
2022-10-26 17:29:04 -04:00
henrik karlsson
b5b86c796c This change is a strategical submit for a coming change that removes lots of includes in headers that are included by many files. This change contains adding of includes in files that previously got those includes transitively from other inclkudes
#preflight 6355d4940313c24974b2107b
#rb none

[CL 22783162 by henrik karlsson in ue5-main branch]
2022-10-26 12:57:32 -04:00
jian ru
bb6c24d7af Fix RHI validation errors on global distance field resources
[FYI] krzysztof.narkowicz, daniel.wright

[CL 22725378 by jian ru in ue5-main branch]
2022-10-24 09:38:52 -04:00
krzysztof narkowicz
3c426fbff0 Global Distance Field - fixed missing updates to Global SDF when there are more than one SceneRender() calls per frame by removing UpdateTrackingBounds optimization:
* We update primitives once per scene inside a SceneRender()
* GlobalSDF is cached per view
* GlobalSDF update is based on whether current primitive is in UpdateTrackingBounds, where UpdateTrackingBounds are built from current views
* If render gets called with a non main view (like a cubemap capture) then scene primitive will be updated, but GlobalSDF for the main view won't

[FYI] Tiago.Costa

[CL 22710474 by krzysztof narkowicz in ue5-main branch]
2022-10-22 07:12:02 -04:00
jeremy moore
dedd787dcf #jira UE-167486
Only build shaders that use ShaderPrint if ShaderPrint is supported.
#preflight 634ee698e746026e48eb17e1

[CL 22628292 by jeremy moore in ue5-main branch]
2022-10-19 12:33:12 -04:00
eric mcdaniel
40de6a4957 Register GlobalDistanceField.PageObjectGridBuffer buffer for use on async compute pipe as well as graphics pipe to resolve ensure when utilized by async Lumen passes
Resolves the following ensure:
Resource GlobalDistanceField.PageObjectGridBuffer is in external access mode and is valid for access on the following pipelines: Graphics, but is being used on the AsyncCompute pipe in pass Scene.DiffuseIndirectAndAO.LumenScreenProbeGather.UpdateRadianceCaches.TraceFromProbes Res=16x16.

#rb Jian.Ru
#preflight 634dffb1d737d61a2f2c6c8e

[CL 22601928 by eric mcdaniel in ue5-main branch]
2022-10-18 11:59:25 -04:00
krzysztof narkowicz
a32a091bf1 Lumen - Bumped global SDF resolution from 224 to 252.
* Memory usage didn't change as Global SDF occupancy was lowered to 0.3. This can be now lowered thanks for previous changes to smaller pages and Landscape page fix.
* Performance is almost the same (<0.05ms change on console)

[CL 22390125 by krzysztof narkowicz in ue5-main branch]
2022-10-06 20:57:24 -04:00
krzysztof narkowicz
43bc1719fb Global Distance Field - fixed debug stats for r.AOGlobalDistanceFieldCacheMostlyStaticSeparately=0
[CL 22203093 by krzysztof narkowicz in ue5-main branch]
2022-09-27 06:59:17 -04:00
krzysztof narkowicz
f3bf236d1e Global Distance Field - fixed heightfield page allocation reducing number of required pages by 5%. Also added debug code for counting filled pages (pages having values outside of 0 or 1, which need to be allocated and filled).
[FYI] Tiago.Costa

[CL 22191882 by krzysztof narkowicz in ue5-main branch]
2022-09-26 15:22:52 -04:00
krzysztof narkowicz
256efd9533 Global Distance Field - fixed "Unable to bind a shader parameter type Texture3D<uint> with a SHADER_PARAMETER_RDG_TEXTURE_UAV" cook warning.
[CL 22173109 by krzysztof narkowicz in ue5-main branch]
2022-09-24 13:27:37 -04:00
krzysztof narkowicz
d1ca6d0cdc Lumen - optimized global distance field tracing by skipping coverage data sampling if it�s not required. Coverage data is used only for foliage partial transparency, but we were sampling it everywhere adding overhead to every trace even when there was no foliage around.
During page composite pass, pages containing coverage values below 1 are marked using a single bit inside PageTable. This bit is then checked during the tracing pass to decide whether we should load a sparse coverage page or not.

Previously we were marking empty areas as coverage 0, but it had some side effects and isn�t compatible with this marking scheme. Now all empty space is marked as coverage=1 and mobility cache composition was accordingly modified.

Performance wins on FortGPUTestBed, all tracing passes, current gen console, 1080p
Epic - 0.17ms
High - 0.1ms

Unfortunately this doesn�t fully remove coverage overhead in levels without foliage. Overhead after this optimization:
Epic - 0.1ms
High - 0.06ms

[CL 22165335 by krzysztof narkowicz in ue5-main branch]
2022-09-23 20:45:46 -04:00
krzysztof narkowicz
9a0e9d220f Lumen - don't allocate and update GlobalDistanceField.PageObjectGridBuffer, when Lumen is disabled.
#jira UE-164911
[FYI] Nuno.Leiria

[CL 22163723 by krzysztof narkowicz in ue5-main branch]
2022-09-23 20:04:50 -04:00
zach bethel
f69b6fbc27 Fixed validation errors due to async compute distance field targets.
#jira UE-163453
#preflight 631faf4be07c4dc0b134f5e6

[CL 21985233 by zach bethel in ue5-main branch]
2022-09-13 12:31:35 -04:00
krzysztof narkowicz
7a5bf8c610 Lumen Software Ray Tracing - replaced voxel lighting volume with an object grid, which allows to sample surface cache directly instead of a low resolution and leaky resampled voxel representation.
* Higher resolution reflections
* No leaking from voxel resampling
* Better emissive representation as previously voxel lighting could miss those
* Allows to resolve hits below voxel interpolation footprint, which previously had to be black in order to prevent from sampling the surface from which current ray originated and causing multibounce to explode.

Distance field object grid is now a part of the global distance field update. Which allows to reuse the page table, update, separate mobility caches and make sure that global distance field matches hit lighting (previous Voxel Lighting was updated in a different place and didn�t always match). Object grid is half resolution and stores up to 4 closest objects to the cell center. All objects are sorted by distance. On every global distance field, the appropriate cell is loaded. Objects are processed in order (sorted by distance to cell center) and their surface cache is applied to hit points until a valid coverage is found.

Smaller changes:
* Removed LumenVoxelLighting
* Prefixed Global Distance Field resources with �GlobalDistanceField.�
* Distance field object buffers are now properly tracked by RDG
* Distance field will bind empty buffers if there are no distance field objects
* Moved global distance field object composite shaders to GlobalDistanceFieldCompositeObjects.usf in order to speed up shader compilation
* Removed mesh SDF change tracking through AddModifiedBoundsForLumen
* Remove more unused parts of Distance Scene
* Fixed ComputeSurfaceCacheSample sampling outside of valid bilinear region

Memory:
Memory increased from 72mb to 112mb. Could be optimized in future by moving object cull grid to separate page table to leverage extra sparseness, or by simply reducing max number of element per grid cell to 3, thus bringing memory overhead to 82mb.

Performance:
Console, FortGPUTestBed, 1080p
Lumen High: 3.4ms -> 3.4ms
Lumen Epic: 7.9ms -> 8.1ms

[FYI] Daniel.Wright, Tiago.Costa

[CL 21825874 by krzysztof narkowicz in ue5-main branch]
2022-09-06 14:53:33 -04:00
tiago costa
e51555d838 Update Global SDF in translated world space.
- Clipmap center is used as origin of translated world space during update.
- Modified HeightfieldDescriptions to store LWC matrices.

#rb Krzysztof.Narkowicz
#preflight 63068184c744dac9673b04ba

[CL 21551226 by tiago costa in ue5-main branch]
2022-08-24 16:30:25 -04:00
tiago costa
7ae20fa7c1 Use DistanceFieldSampler in the shaders used to update global SDF.
- Remove depedency on ViewUniformBuffer.
- Changed DistanceFieldSampler to use wrap addressing so that it matches the global sampler addressing mode.

#rb aleksander.netzel
#preflight 63063a1ac744dac967282411

[CL 21541307 by tiago costa in ue5-main branch]
2022-08-24 11:17:02 -04:00
daniel wright
9292fcb068 Distance field stochastic semi-transparency for foliage
* Global SDF tracing uses a per-step noise comparison to implement semi-transparency (r.LumenScene.GlobalSDF.DitheredTransparencyStepThreshold), with a high min step size to regain performance
 * Fixed Global SDF Coverage getting stomped when Movable objects were nearby, which was lowering its effective resolution.  Empty space is now marked as not covered, which requires MinStepSizes to be kept smaller than or equal to ONE_SIDED_BAND_SIZE.
 * Mesh SDF tracing now expands based on coverage and implements its own semi-transparency (r.Lumen.DiffuseIndirect.MeshSDF.DitheredTransparencyStepThreshold)
 * Only Screen Probe and Radiance Cache traces enable dithered transparency to combat foliage over-occlusion.  Visualize matches reflection behavior by default, so it has to have TraceInput.bDitheredTransparency = true to visualize what diffuse rays see.

#ROBOMERGE-AUTHOR: daniel.wright
#ROBOMERGE-SOURCE: CL 21019034 via CL 21019035 via CL 21019036
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v972-20964824)

[CL 21023956 by daniel wright in ue5-main branch]
2022-07-09 14:06:37 -04:00
jason hoerner
1f73247f9d MGPU: Fix for global distance field data not being initialized when swapping GPUs. Force full update of global distance field data if the GPU index changes. If AFR is enabled, force global distance fields to be updated across all GPUs, to avoid thrashing due to the GPU index changing every frame.
#jira UE-145093
#rnx
#rb jason.nadro
#preflight 62bc9eb9b64c84b3ba7a9d2f

[CL 20881535 by jason hoerner in ue5-main branch]
2022-06-29 16:12:02 -04:00
tiago costa
836a0e9d2e Fix incorrect assert when r.AOGlobalDistanceFieldStaggeredUpdates is disabled.
#preflight skip
#rb none

[CL 20880623 by tiago costa in ue5-main branch]
2022-06-29 15:29:18 -04:00
jason hoerner
d15b1426d0 Scene Capture Cube: fix for severe artifacts in volumetric cloud rendering, and possibly other artifacts. The artifacts are caused by the temporal volumetric cloud effect not having a separate history per cube map face.
* Each cube map face gets its own FSceneViewState.  The downside is that it potentially could add a lot of extra memory.  So some memory optimizations were made to compensate.
* Global distance field data is shared for all cube map faces.  This data is only dependent on the view origin, which is invariant for the cube map faces.  A mechanism was added to allow cross view state data sharing for shared origin views.  This saves 8.5 MB, and improves perf.
* Disabled distance field lighting temporal AO for cube map capture.  The AO history texture in the view state is dependent on the Scene texture extents, which is typically the front buffer size, which then gets multiplied by 6.  For a 1080p front buffer, this is 24 MB, while for a 4K front buffer, this is 96 MB, regardless of the resolution of the cube map capture itself.  A 256x256 cube map capture, including all the auxiliary state, is otherwise only around 9 MB, so this is an order of magnitude increase.  A comment in the function "DistanceFieldAOUseHistory" has more details on how this could be fixed, by using the view rect rather than Scene texture extents for the history texture -- for the 256x256 case, it would reduce the incremental memory cost to 768K.

With the memory savings from disabling distance field lighting temporal AO, this change is more or less memory neutral if the Scene texture extent (front buffer) is 1080p.  A net increase of 590K.  With a higher resolution front buffer, it's a subsantial memory win.

#jira UE-151717
#rnx
#rb tiago.costa daniel.wright
#preflight 629f6a27233ae0a8f8f99932

[CL 20614815 by jason hoerner in ue5-main branch]
2022-06-11 19:06:03 -04:00