38 Commits

Author SHA1 Message Date
tiago costa
1aa5e205b9 Replaced double precision members of FDistanceFieldVolumeData and FSparseDistanceFieldMip with single precision floats.
#rb Krzysztof.Narkowicz

[CL 29863953 by tiago costa in ue5-main branch]
2023-11-21 09:53:46 -05:00
sebastien hillaire
773b3c6731 Lumen - add capture of translucent meshes into lumen scene and card.
If hit lighting and refraction is not enabled, translucent meshes will be skipped, and translucent cards part of composed meshes won't be won't be dispatched.
#rb Krzysztof.Narkowicz

[CL 29507890 by sebastien hillaire in ue5-main branch]
2023-11-06 20:10:34 -05:00
tiago costa
abca6b5a6c Resubmit CL26160360, 26146080, 26137852, 26126752
Only leaving CL 26157603 reverted since accessing GenerateSource in FDistanceFieldVolumeData::CacheDerivedData is not safe due to async mesh compilation.

#prelight 64948190a26e02126bc0a64f
#rb Krzysztof.Narkowicz

[CL 26206875 by tiago costa in ue5-main branch]
2023-06-23 04:28:57 -04:00
bob tellez
4c7e2e1b32 [Backout] - CL26160360, 26157603, 26146080, 26137852, 26126752
[FYI] tiago.costa
Original CL Desc
-----------------------------------------------------------------
Use FSignedDistanceFieldBuildSectionData when generating distance fields for Nanite meshes.

Context:
- Nanite meshes distance fields are generated using the original mesh data instead of the coarse representation generated by Nanite, however that code path was not checking section data such as blend mode, two sided, etc.

Fix:
- Modified FStaticMeshBuilder::BuildMeshVertexPositions(...) to also output a FStaticMeshSectionArray.
- Updated MeshRepresentation::SetupEmbreeScene(...) to check section flags when using SourceMeshData.IsValid() code path.

#prelight
#rb Krzysztof.Narkowicz

[CL 26174853 by bob tellez in ue5-main branch]
2023-06-22 00:25:01 -04:00
tiago costa
a6c0a01df7 Fix incorrect Distance Field / Card Representation when multiple mesh sections with different settings point to the same material slot
- Different mesh sections can point to the same material slot which was a problem since bAffectDistanceFieldLighting flag can be set per section but we were using an array with an entry per material slot instead of per section.
- To address this now we build array of FSignedDistanceFieldBuildSectionData (one entry per section) so section don't override each other.

#prelight 64921d9ab76bf403cda2f33f
#rb daniel.wright

[CL 26137888 by tiago costa in ue5-main branch]
2023-06-20 18:44:39 -04:00
kevin ortegren
f9272bdeba Embree device/scene is used even after they fail init. Fix crash by early out. (This matches the behavior of GenerateCardRepresentationData).
Failed Embree init will leave FDistanceFieldVolumeData::IsValid() returning false.

#rb tiago.costa, mihnea.balta
#rnx
#preflight 63ff868dae54ee4ce945432b

[CL 24471347 by kevin ortegren in ue5-main branch]
2023-03-01 16:53:19 -05:00
UnrealBot
73409369c0 Branch snapshot for CL 21319338
[CL 21319338 in ue5-main branch]
2022-08-10 16:03:37 +00:00
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
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
charles bloom
67ef10a399 mark up most of the ParallelFors used in cook with named scopes for Insights
#rb arne.schober
#preflight none

[CL 18966875 by charles bloom in ue5-main branch]
2022-02-11 19:32:06 -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
krzysztof narkowicz
eed0fc3bed 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
#ROBOMERGE-BOT: (v836-16769935)

[CL 16916104 by krzysztof narkowicz in ue5-main branch]
2021-07-21 17:57:42 -04:00
Ben Ingram
b569c9be59 Fix usage of embree with LWC for mesh distance fields and cards
#jira UE-117476
#rb Krzysztof.Narkowicz

[CL 16624221 by Ben Ingram in ue5-main branch]
2021-06-10 11:46:03 -04:00
Martin Ridgers
040fedf56e Removed external linkage from ComputerLinearVoxelIndex() in two separate modules to prevent monolithic link errors.
#rb trivial
#rnx

[CL 15887029 by Martin Ridgers in ue5-main branch]
2021-04-01 04:59:16 -04:00
daniel wright
b339145bac Fixed Distance Field Streaming on cooked windows
Tested TopazEntry PIE and cooked win64

#ROBOMERGE-SOURCE: CL 15865752 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v786-15839533)

[CL 15865757 by daniel wright in ue5-main branch]
2021-03-30 14:38:12 -04:00
daniel wright
4cb3062eb8 Changed lack of Embree to be a warning, not error log, to not fail DDC build commandlet
#ROBOMERGE-SOURCE: CL 15828365 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v785-15821902)

[CL 15834014 by daniel wright in ue5-main branch]
2021-03-25 18:24:34 -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
danny couture
d5ba6e94d9 Remove BackgroundPriority to let the ParallelFor auto select the best priority depending on which thread is launching the paralllelfor
i.e. This allows latency sensitive texture compression parallelfor from the gamethread to benefit from all the foreground threads and complete faster

#rb Arne.Schober

[CL 15387719 by danny couture in ue5-main branch]
2021-02-11 11:01:47 -04:00
Arne Schober
5fdfd0099d U5 - Move FMeshDistanceFieldAsyncTask in parallelFor
[CL 15373180 by Arne Schober in ue5-main branch]
2021-02-09 20:52:00 -04:00
Arne Schober
f6e1fb0d86 U5 - have MeshDistanceFields BusyWait and not take down all Task Workers.
[CL 15288899 by Arne Schober in ue5-main branch]
2021-02-02 21:18:43 -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
Daniel Wright
e5b3986253 Mesh Distance Field supports Two Sided materials properly, when assigned to the asset
[CL 14945194 by Daniel Wright in ue5-main branch]
2020-12-17 00:02:25 -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
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