Commit Graph

114 Commits

Author SHA1 Message Date
tiago costa
d9c4dec954 Fix distance field shadows when LWC is enabled.
- Incorrect reinterpret cast to float.

#rb daniel.wright
#preflight 61269445eef7f30001b92ddb

#ROBOMERGE-SOURCE: CL 17309679 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v861-17282326)

[CL 17309687 by tiago costa in ue5-release-engine-test branch]
2021-08-25 17:05:27 -04:00
tiago costa
31d59cd946 Fix stat name for PrepareDistanceFieldScene
#rb daniel.wright
#pf 610c535b26ea630001a87682

#ROBOMERGE-SOURCE: CL 17080985 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v853-17066230)

[CL 17080996 by tiago costa in ue5-release-engine-test branch]
2021-08-06 05:57:19 -04:00
tiago costa
3831a71619 Updated CapsuleShadowing to RDG.
- Resource states/transitions handled by RDG
- Shader bindings using SHADER_PARAMETER_STRUCT.
Converted data and intermediate buffers to StructuredBuffers.
Removed a lot of unecessary structs from DistanceFiedLightingShared.h

#rb krzysztof.narkowicz
#preflight 61004413ab06550001afad83

#ROBOMERGE-SOURCE: CL 16971682 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v838-16927207)

[CL 16971689 by tiago costa in ue5-release-engine-test branch]
2021-07-27 15:02:57 -04:00
zach bethel
a44fbef833 Incremental fix-up to add names to RDG passes and use the correct RHI command list.
#rb christopher.waters

#ROBOMERGE-SOURCE: CL 16923748 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v836-16769935)

[CL 16923764 by zach bethel in ue5-release-engine-test branch]
2021-07-22 11:00:18 -04:00
krzysztof narkowicz
2a8132abb9 DF PrimitiveModifiedBounds memory and performance optimizations. This helps a lot in large scenes which place lots of objects onto this list:
*Don't track modified bounds if they are outside of the interest range of Global Distance Field or Lumen
*Change FBox to FRenderBounds (4 bytes less per box)
*Try to keep PrimitiveModifiedBounds memory allocation based on the last frame's usage

#rb Daniel.Wright

#ROBOMERGE-SOURCE: CL 16697019 via CL 16697029
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v835-16672529)

[CL 16697032 by krzysztof narkowicz in ue5-release-engine-test branch]
2021-06-16 17:48:21 -04:00
graham wihlidal
f602dcf242 Big cleanup/refactor of InstanceData* (renamed to InstanceSceneData* to match many other places already calling it that, and to disambiguate upcoming changes that add another instance data buffer to GPU Scene for arbitrary data payloads). This change also removes the virtuals on FPrimitiveSceneProxy for the instance list along with lots of copy paste code for all the derived types, and instead makes it a built-in feature of the base proxy (since nearly everything supports GPU Scene instancing now).
#rb ola.olsson
[FYI] brian.karis
#preflight 60c4d5c586ce760001377f2a

#ROBOMERGE-OWNER: graham.wihlidal
#ROBOMERGE-AUTHOR: graham.wihlidal
#ROBOMERGE-SOURCE: CL 16660135 via CL 16660883
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v834-16658389)

[CL 16660909 by graham wihlidal in ue5-release-engine-test branch]
2021-06-14 13:43:26 -04:00
tiago costa
3dc755958e Updated most of distance field ambient occlusion codepath to use RDG.
- Resource state transitions handled by RDG.
- FDistanceFieldObjectBufferResource replaced by FDistanceFieldCulledObjectBufferParameters to use RDG.
- FTileIntersectionResources replaced by FTileIntersectionParameters to use RDG.
- FAOScreenGridResources replaced by FAOScreenGridParameters to use RDG.
- Don't store DFAO resources in View.State.
- Split FDeferredShadingSceneRenderer::RenderDistanceFieldAOScreenGrid() into multiple passes.
- Split BuildTileObjectLists() into multiple passes.

#rb daniel.wright

#ROBOMERGE-SOURCE: CL 16660080 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v834-16658389)

[CL 16660083 by tiago costa in ue5-release-engine-test branch]
2021-06-14 12:46:26 -04:00
graham wihlidal
c3bda99324 Fix LWC issues with FRenderTransform
#fyi rune.stubbe, zak.middleton

[CL 16561641 by graham wihlidal in ue5-main branch]
2021-06-04 15:39:10 -04:00
graham wihlidal
c850a02c69 Implemented a new WIP type called FRenderTransform that (for now) represents instance transforms as a float 4x3 matrix - in the future we expect a much tighter per-instance encoding (for example: 12bytes for position, 4bytes for rotation, 6bytes for scale), so this type can be optimized in that direction. Other than saving hundreds of MB in *heavy* instance scenes, faster updates/uploads, etc.. this type could be used to represent a transform that stays 32bit w/ a rebase offset. Passing around ambiguous FVector and FMatrix data is bound to get us into trouble, whereas a concrete type we can reason about for transforms in render-only code makes a good deal of sense.
This change is another basis for more instance data and GPUScene improvements coming down the pipe.

#rb jason.nadro, krzysztof.narkowicz, zach.bethel, zak.middleton, rune.stubbe, ben.woodhouse
[FYI] brian.karis, ola.olsson
#preflight 60b9608d0249c300016598de


#ROBOMERGE-OWNER: graham.wihlidal
#ROBOMERGE-AUTHOR: graham.wihlidal
#ROBOMERGE-SOURCE: CL 16555619
#ROBOMERGE-BOT: (v828-16531559)
#ROBOMERGE-CONFLICT from-shelf

[CL 16555914 by graham wihlidal in ue5-main branch]
2021-06-03 21:10:11 -04:00
daniel wright
8add01e6dd Fixed crash with Lumen Direct Lighting when FDeferredShadingSceneRenderer::ShouldPrepareDistanceFieldScene() returns false, as is the case on Intel.
#jira UE-116102
#rb krzysztof.narkowicz, michal.valient
[FYI] nick.whiting

#ROBOMERGE-SOURCE: CL 16390780 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v804-16311228)

[CL 16390826 by daniel wright in ue5-main branch]
2021-05-19 15:28:52 -04:00
Krzysztof Narkowicz
7cf4c5f5b8 Refactored Lumen Surface Cache lookup. DF and HWRT surface cache lookups are now unified into a single array, which translates SceneInstanceIndex into a LumenMeshCardsIndex. Later it could become a part of GPUScene if needed.
#fyi Patrick.Kelly, Daniel.Wright

[CL 16306367 by Krzysztof Narkowicz in ue5-main branch]
2021-05-12 17:17:39 -04:00
Daniel Wright
36c0a63336 Screen Probe HW tracing uses hit velocity to determine if trace hit something moving
Screen Probe Mesh SDF tracing uses hit velocity to determine if trace hit something moving
Added r.DistanceFields.SurfaceBiasExpand

[CL 16294546 by Daniel Wright in ue5-main branch]
2021-05-11 23:28:28 -04:00
zach bethel
d4527175e2 Avoid copying scene primitive bounds array.
#fyi krzysztof.narkowicz

[CL 16194110 by zach bethel in ue5-main branch]
2021-05-04 11:15:16 -04:00
danny couture
397ce1723b Optimize RemovePrimiveSceneInfos by fixing linear search
- 4.7s to 6.2 ms  when loading AncientGame world

#jira UETOP-1548
#rb Daniel.Wright
#lockdown Simon.Tourangeau
#preflight 608974862377910001f3a41f

#ROBOMERGE-SOURCE: CL 16146081 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v789-15992632)

[CL 16146096 by danny couture in ue5-main branch]
2021-04-28 13:29:11 -04:00
Daniel Wright
81bb26af50 Added DistanceFields LLM stat
#lockdown michal.valient
#jira UE-113295
#rb graham.wihlidal

#ROBOMERGE-OWNER: Daniel.Wright
#ROBOMERGE-AUTHOR: daniel.wright
#ROBOMERGE-SOURCE: CL 15986180 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v787-15839533)
#ROBOMERGE-CONFLICT from-shelf

[CL 15991397 by Daniel Wright in ue5-main branch]
2021-04-13 12:53:51 -04:00
Daniel Wright
697b5b9cf6 Sparse, narrow band, streamed Mesh Signed Distance Fields
* SDFs are now generated, allocated from the atlas and uploaded in 8^3 bricks (7^3 unique data, half voxel padding).
 * Tracing must load the brick index from the indirection table, and only bricks near the surface are stored
 * 3 mips are now generated, with the lowest resolution always loaded and the other 2 streamed
 * SDFs are now G8 narrow band.  Lower resolution mips must be traversed when querying distance to nearest surface far away from the surface
 * The Distance Field Brick Atlas is now stored for each FScene and dynamically resized based on needs with a GPU memcopy
 * Brick atlas uses a 1d pooled allocator which has no fragmentation and greatly reduces packing waste over the 3d allocator
 * Added new indirection for Distance Field Asset data, so that only a single entry needs to be updated when a mip is streamed in or out in scenes with millions of instances
 * Compute shaders operating on distance field instances generate streaming requests, which are async read back to CPU, turned into IO requests, which are polled and when complete uploaded to atlases
 * Any mesh instance inside the Global SDF extent (200m) requests mip1, and at 50m requests mip2
 * Now using a batched compute scatter to upload to the distance field atlas instead of RHIUpdateTexture3d, to bypass alignment restrictions and per-upload overhead
 * Distance Field streaming uses an async task to move Memcpy and IO request overhead off of the Rendering Thread
 * Distance Field Visualization now computes a normal from the SDF gradient and does simple lighting to better visualize the scene representation
 * Increased r.DistanceFields.MaxPerMeshResolution from 128 to 512, to better represent large objects
 * Mesh SDF generation now uses an Embree point query to calculate closest unsigned distance, and then a much smaller set of rays to count backfaces for negative region determination, for a 11x speedup
 * Upgraded mesh utilities to Embree 3.12.2 to get point queries
 * Fixed wrong transform used for SDF normals in Lumen, causing non-uniformly scaled meshes to have incorrect Surface Cache interpolation
 * Fixed Static Mesh materials not getting PostLoaded before SDF build, causing their blend modes to be wrong for the build, which corrupts the DDC.  Also included those blend modes in the DDC key.

Original costs on 1080 GTX (full updates on everything and no screen traces)
10.60ms   UpdateGlobalDistanceField
3.62ms   LumenReflectiveTest.DirectionalLight_1 Shadowmap 1
1.73ms   VoxelizeCards Clipmaps=[0,1,2,3]
0.38ms   TraceCards 1 dispatch 1 groups
0.51ms   TraceCards 1 dispatch 1 groups

Sparse SDF costs
12.06ms   UpdateGlobalDistanceField
4.35ms   LumenReflectiveTest.DirectionalLight_1 Shadowmap 1
2.30ms   VoxelizeCards Clipmaps=[0,1,2,3]
0.69ms   TraceCards 1 dispatch 1 groups
0.77ms   TraceCards 1 dispatch 1 groups

Tested: TopazEntry PC, Reverb PC and PS5, EngineTests, QAGame, Rift, Frosty P_Construct_WP, FortGPUTestbed

#rb Krzysztof.Narkowicz

#ROBOMERGE-OWNER: Daniel.Wright
#ROBOMERGE-AUTHOR: daniel.wright
#ROBOMERGE-SOURCE: CL 15784493 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v783-15756269)
#ROBOMERGE-CONFLICT from-shelf

[CL 15790658 by Daniel Wright in ue5-main branch]
2021-03-23 22:40:05 -04:00
Yuriy ODonnell
da38c78f19 Added TRACE_CPUPROFILER_EVENT_SCOPE-s in various parts of rendering code that can take non-trivial time.
#preflight 60578088c118270001c6367f

[CL 15756286 by Yuriy ODonnell in ue5-main branch]
2021-03-21 13:53:35 -04:00
Florin Pascu
77051879b6 DistanceField Shadow Mobile(disabled by default for the moment)
#rb Dmitriy.Dyomin,Zach.Bethel, Jack.Porter
#jira UE-103864

[CL 15471024 by Florin Pascu in ue5-main branch]
2021-02-19 07:49:57 -04:00
krzysztof narkowicz
50bb5b5be7 Fixed Lumen crash when trying to render lights into Lumen's surface cache without any mesh SDF in the scene. Also added DistanceField::SetupObjectBufferParameters for setting up mesh SDF parameters with a fallback to dummy buffers.
[FYI] Daniel.Wright

#ROBOMERGE-SOURCE: CL 15395707 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v771-15082668)

[CL 15395709 by krzysztof narkowicz in ue5-main branch]
2021-02-11 22:43:59 -04:00
krzysztof narkowicz
c3673e67a7 Fixed Lumen voxel lighting cache bug when distance field indices are swapped during primitive removal
[FYI] Daniel.Wright

#ROBOMERGE-SOURCE: CL 15353139 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v771-15082668)

[CL 15360267 by krzysztof narkowicz in ue5-main branch]
2021-02-08 17:03:39 -04:00
Krzysztof Narkowicz
bae97b8f2d Lumen - clamp mesh SDF traces to mesh SDF bounding box so traces for large meshes don't return a hit point outside of this bounding box
[CL 14654683 by Krzysztof Narkowicz in ue5-main branch]
2020-11-04 13:57:55 -04:00
Krzysztof Narkowicz
37ebc32b2a Mesh distance fields - remove unused and duplicated matrices from the DF GPU scene
[CL 14643078 by Krzysztof Narkowicz in ue5-main branch]
2020-11-03 12:35:40 -04:00
Krzysztof Narkowicz
c61e716d8e Mesh distance fields - refactored LoadGlobalObject* functions into LoadDFObjectData.
#rb none

[CL 14636549 by Krzysztof Narkowicz in ue5-main branch]
2020-11-02 17:20:22 -04:00
Krzysztof Narkowicz
453577c165 Improved mesh distance field distance to surface computation when using non uniform scale. It now computes a perfect distance to the object's bounding box. This is also now a common function used for the global SDF compose and for mesh SDF culling (previous mesh SDF culling function was buggy and was failing for non uniform scaled and rotated objects).
#fyi Daniel.Wright, Patrick.Kelly

[CL 14629023 by Krzysztof Narkowicz in ue5-main branch]
2020-11-02 12:27:17 -04:00
Krzysztof Narkowicz
14d02c6809 MeshSDF - implemented a tight bounding box with one voxel margin for bilinear gradient reconstruction. This allowed the MESH_SDF_APPROX_MARGIN hack to be removed and secured all gradient reconstruction operations from reading outside of valid bounds. Also saved ~50% of SDF atlas space, and speed up some mesh SDF operations:
UpdateGlobalDistanceField: ~7% faster
TraceMeshSDFs: ~5% faster

#rb Daniel.Wright, Patrick.Kelly

[CL 14618591 by Krzysztof Narkowicz in ue5-main branch]
2020-10-29 23:43:01 -04:00