Commit Graph

29 Commits

Author SHA1 Message Date
tiago costa
66a1ac1125 Updated MeshUtilities::GenerateStratifiedUniformHemisphereSamples to use concentric disk sampling.
- The number of samples returned is the square number closer to the requested number.
- Updated code paths using the function to request a number of samples close to what they previously got.

#rb Krzysztof.Narkowicz
#preflight 628de9e7f622d972b5732cbb

#ROBOMERGE-AUTHOR: tiago.costa
#ROBOMERGE-SOURCE: CL 20361675 via CL 20361695 via CL 20361702
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v948-20297126)

[CL 20362041 by tiago costa in ue5-main branch]
2022-05-25 06:17:20 -04:00
krzysztof narkowicz
2c93837775 Lumen - disable mesh cards generation when max num cards in static mesh properties is set to 0
#ROBOMERGE-AUTHOR: krzysztof.narkowicz
#ROBOMERGE-SOURCE: CL 20082848 via CL 20083225 via CL 20083623
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v943-19904690)

[CL 20106592 by krzysztof narkowicz in ue5-main branch]
2022-05-09 14:00:17 -04:00
krzysztof narkowicz
67827c332c Lumen - fixed surface coverage on sparse trees
* Mostly two sided meshes are assumed to be foliage and forced to be repsented as a cube projection
* Lowered card min density treshold for cube projections

[FYI] Daniel.Wright

#ROBOMERGE-AUTHOR: krzysztof.narkowicz
#ROBOMERGE-SOURCE: CL 19424752 via CL 19424760
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v930-19419903)

[CL 19425489 by krzysztof narkowicz in ue5-main branch]
2022-03-17 15:54:43 -04:00
krzysztof narkowicz
31a4f9aecb Lumen - surface cache generation improvements
* Added r.MeshCardRepresentation.Debug for surface cache debugging. It skips DDC reads and writes, allows to regenerate per static mesh on demand and appends extra debug visualization data to every generated mapping
* Surfels are now weighted by opacity - ratio of rays which hit in a given cell, and by visibility - how many rays can hit a given Surfel from outside the mesh. This helps to select most important surfaces to cover when hitting limits
* Removed distance constraint. It�s no longer needed when card discontinuities are already handled inside the surface cache sampling code. This allows to generate larger and more optimal cards
* Limit max number of surfels to prevent generation time from exploding, as dense two sided meshes like large trees can generate many more surfels than simple walls

[FYI] Daniel.Wright

#ROBOMERGE-AUTHOR: krzysztof.narkowicz
#ROBOMERGE-SOURCE: CL 19304117 via CL 19304128
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v926-19321884)

[CL 19346860 by krzysztof narkowicz in ue5-main branch]
2022-03-10 20:49:33 -05:00
daniel wright
0daeb7fe49 Fixed MeshCards not getting generated when a mesh has DistanceFieldResolutionScale = 0, breaking CitySample HLOD1
Instead of clearing RadiosityAtlas and skipping Radiosity when switching Lumen to SWRT, voxelize the direct lighting that's been calculated so far and keep the existing Radiosity atlas
#preflight 621f057e257fd6e099457e56
#jira UE-144367
#rb Krzysztof.Narkowicz
#lockdown Juan.Canada

#ROBOMERGE-AUTHOR: daniel.wright
#ROBOMERGE-SOURCE: CL 19219209 in //UE5/Release-5.0/... via CL 19219356
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v921-19075845)

[CL 19227351 by daniel wright in ue5-main branch]
2022-03-02 15:19:12 -05:00
krzysztof narkowicz
f38e756567 Lumen - generate surface cache on small elements and decrease min card world space size. No noticeable performance issues in CitySample or Reverb.
#jira none
#lockdown Juan.Canada
#rb Daniel.Wright
#preflight 62194603783beeaf8a0fc2fa

#ROBOMERGE-AUTHOR: krzysztof.narkowicz
#ROBOMERGE-SOURCE: CL 19157447 in //UE5/Release-5.0/... via CL 19159834
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v921-19075845)

[CL 19161485 by krzysztof narkowicz in ue5-main branch]
2022-02-25 19:47:27 -05:00
charles bloom
38b1d2e51f Mark up more ParallelFor scopes for Insights
#rb none
#preflight 6216cd82647bb7debf703367

[CL 19105606 by charles bloom in ue5-main branch]
2022-02-23 19:25:03 -05:00
fred kimberley
7fbfaf57c8 Require explicit constructors/casts when converting between FVector, FVector3d, and FVector3f.
#jira UE-122078
#rb Andrew.Davidson, Colin.McGinley
#preflight standard build

#ROBOMERGE-AUTHOR: fred.kimberley
#ROBOMERGE-SOURCE: CL 18817999 in //UE5/Release-5.0/... via CL 18818012 via CL 18822871
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v910-18824042)

[CL 18824721 by fred kimberley in ue5-main branch]
2022-02-02 07:59:31 -05:00
andrew davidson
f089ae83f4 FMatrix explicit cast fixes
#preflight 61f277cbaf74b68515c0bd64

#ROBOMERGE-AUTHOR: andrew.davidson
#ROBOMERGE-SOURCE: CL 18751911 in //UE5/Release-5.0/... via CL 18751924 via CL 18752067
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v903-18687472)

[CL 18752076 by andrew davidson in ue5-main branch]
2022-01-27 06:25:37 -05:00
UnrealBot
c47e81b2cb Branch snapshot for CL 18531810
[CL 18531810 in ue5-main branch]
2022-01-06 16:44:09 +00:00
UnrealBot
2987349d36 Branch snapshot for CL 18514113
[CL 18514113 in ue5-main branch]
2022-01-05 20:41:17 +00:00
krzysztof narkowicz
bbc28ea8b9 Lumen surface cache generation changes in order to fix surface coverage issues
* First mesh is voxelized by tracing rays in every voxel
* Then voxel faces are clustered in parallel to build continuos cards. Clustering follows voxel distance, card ratio, density and other metrics
* Finally a specificied number of cards is selected per mesh (user parameter). This allows to tradeoff between coverage and runtime overhead

Other:
* Added surface cache coverage view mode for debugging coverage issues - r.Lumen.Visualize.Mode 6
* Fixed r.LumenScene.SurfaceCache.CardMinResolution to be able to go below 2

#preflight 61d478acdb0309127dfaf8ec
#rb Daniel.Wright

#ROBOMERGE-AUTHOR: krzysztof.narkowicz
#ROBOMERGE-SOURCE: CL 18519098 in //UE5/Release-5.0/... via CL 18519102
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v899-18417669)

[CL 18519115 by krzysztof narkowicz in ue5-release-engine-test branch]
2022-01-05 10:30:05 -05:00
Marc Audy
0c3be2b6ad Merge Release-Engine-Staging to Test @ CL# 18240298
[CL 18241953 by Marc Audy in ue5-release-engine-test branch]
2021-11-18 14:37:34 -05:00
krzysztof narkowicz
f0221b15cb Fixed crash (check firing) in Lumen when importing certain meshes. Check was firigin because of LWC automatic FVector type promotion to double, which caused a mismatch between float and double calculations.
#ROBOMERGE-AUTHOR: krzysztof.narkowicz
#ROBOMERGE-SOURCE: CL 17871833 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v883-17842818)
#ROBOMERGE[STARSHIP]: UE5-Release-Engine-Staging Release-5.0

[CL 17871864 by krzysztof narkowicz in ue5-release-engine-test branch]
2021-10-20 08:48:24 -04:00
krzysztof narkowicz
368847f1fb Lumen - fixed a bug, where incorrect card direction could be serialized causing an assert to fire at rumtime
#ROBOMERGE-SOURCE: CL 16900162 via CL 16917756
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v836-16769935)

[CL 16917910 by krzysztof narkowicz in ue5-release-engine-test branch]
2021-07-21 19:12:47 -04:00
krzysztof narkowicz
b2397588bc New Lumen surface cache card generation:
* Generate surfels directly from the triangles instead of relying on ray tracing, to fix coverage issues on some meshes
* Surfels which are inside meshes (surrounded by back faces) or are too close to geometry are discarded
* New surfel clustering algorithm, which inserts one seed after another and tries to iteratively grow clusters in order to find the best set of seeds. Final step is to reset all clusters and grow all simultaneously from previously selected seeds.
* Cluster growing is based on normal, distance and surfel visibility (don�t cluster surfels near geometry first, as it can cause algorithm to be stuck in a local minimum)
* Runtime sampling has strict culling based on the angle and card AABB. Additionally, the tri-planar blending zone was tightened. This improves performance. 0.62-0.5 ms.
* Added various visualizations and CVars for card generation debugging
* Fixed card visibility bug, where card could influence outside of it�s range due to negative shadow map visibility

[FYI] Daniel.Wright, Patrick.Kelly

#ROBOMERGE-SOURCE: CL 16897632 via CL 16916104
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v836-16769935)

[CL 16916378 by krzysztof narkowicz in ue5-release-engine-test branch]
2021-07-21 18:05:08 -04:00
daniel wright
64d93669a5 Fixed crash cooking when project does not have r.GenerateMeshDistanceFields enabled
#ROBOMERGE-SOURCE: CL 15788010 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v783-15756269)

[CL 15790801 by daniel wright in ue5-main branch]
2021-03-23 22:43:50 -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
66f0ccca88 ParallelFor over orientations when building mesh card representation.
#rb Krzysztof.Narkowicz

[CL 15737373 by Yuriy ODonnell in ue5-main branch]
2021-03-18 09:38:36 -04:00
krzysztof narkowicz
e9ca31e797 LumenScene refactor
* Moved LumenScene functionality into new LumenScene.cpp file
* Moved all Lumen data into FLumenPrimitive. FPrimitiveSceneInfo now contains just a LumenPrimitiveIndex
* Mesh cards are spawned only near the camera on demand. This saves ~200-300mb of GPU memory on big city levels, and also skips some GPU and CPU costs
* Fixed card merging (previously it was reusing MeshCards which could result in missing cards)

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

[CL 15494982 by krzysztof narkowicz in ue5-main branch]
2021-02-22 18:04:23 -04:00
krzysztof narkowicz
8e87b8ba2b Lumen - tighten surface cache projections to save a bit of atlas space and remove empty borders causing incorrect radiosity upsampling
[FYI] Patrick.Kelly

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

[CL 15392790 by krzysztof narkowicz in ue5-main branch]
2021-02-11 17:59:41 -04:00
Krzysztof Narkowicz
bef7aa2a1e Fixed Lumen card representation for thin planes, where decals were too thin to be picked up for projection
#fyi Daniel.Wright

[CL 15169798 by Krzysztof Narkowicz in ue5-main branch]
2021-01-23 01:26:01 -04:00
Krzysztof Narkowicz
6c573a2474 Lumen surface cache now supports internal surfaces
* r.LumenScene.MeshCardsMaxLOD controls representation quality. With 0 being a box projection
* New card placement to focus on important parts of a mesh (skip non visible parts)
* Replaced CubeMapTrees with MeshCards. Instead of a big volume texture lookup there are now 6 lists of decals (one per axis)
* Merged distance field and mesh card Embree setup code into a set of common functions
* Removed hardcoded limits of 6 cards per mesh

#fyi Daniel.Wright, Patrick.Kelly, Yuriy.ODonnell

[CL 15144947 by Krzysztof Narkowicz in ue5-main branch]
2021-01-20 11:34:55 -04:00
Krzysztof Narkowicz
2921126a39 SDF and card rep generation now check for degenerate triangles before adding them to the Embree scene
#rb Daniel.Wright

[CL 14579820 by Krzysztof Narkowicz in ue5-main branch]
2020-10-26 15:07:53 -04:00
Krzysztof Narkowicz
3da3a205fb Added FMeshBuilder::BuildMeshVertexPositions. It replaces FMeshBuilder::BuildMesh(bool bBuildOnlyPosition = true) and does the minimal work which is required to extract vertex positions from a mesh descriptor.
This is later used to build static mesh derived data in cases where Nanite coarse mesh representation replaces original static mesh data and we can't depend on it. In extreme cases it lowers main thread derived data build time from ~7.5s to ~0.1s.

#rb Richard.TalbotWatkin

[CL 14578414 by Krzysztof Narkowicz in ue5-main branch]
2020-10-26 13:09:34 -04:00