Commit Graph

27 Commits

Author SHA1 Message Date
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
ben ingram
02a8483152 Fix usage of embree with LWC for mesh distance fields and cards
#jira UE-117476
#rb Krzysztof.Narkowicz

#ROBOMERGE-SOURCE: CL 16624221 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v831-16623017)

[CL 16624232 by ben ingram in ue5-release-engine-test branch]
2021-06-10 11:46:40 -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
Krzysztof Narkowicz
6a3e844487 Mesh distance field generation fixes:
* Fixed section filtering bug causing to generate SDF from random triangles when a single section was filtered out
* Removed plane hack, which was squashing some meshes and causing generation rays to randomly return backface / frontface hits

Tested in FortGPUTestBed and Fornite, but didn't notice any issues introduced by plane hack removal. If something breaks, then anyway we should fix it in the tracing code by improving non uniform SDF scale support there.

#rb Daniel.Wright

[CL 14571736 by Krzysztof Narkowicz in ue5-main branch]
2020-10-25 23:29:54 -04:00
danny couture
6e8494009d DistanceField and MeshCards async queues are now reusing existing threadpool instead of spawning their own
DistanceField and MeshCards are not limited anymore to a single thread and can scale to the number of physical cores available
DistanceField and MeshCards are now both limiting their tick time length to avoid huge game-thread stalls when lots of assets are being built
Fix potential race-condition in DistanceFieldAsyncQueue found while fixing MeshCardAsyncQueue

#rb Alexis.Matte

[CL 14420000 by danny couture in ue5-main branch]
2020-10-05 08:22:37 -04:00
Krzysztof Narkowicz
5581ebef92 Generate mesh distance fields and Lumen card representation for Nanite meshes directly from the source mesh data. Nanite replaces static mesh data with a coarse mesh representation, which sometimes has holes in it or is not accurate enough. Building from the source data works around that issue and gets up the highest possible SDF/card quality. Unfortunately it also regresses static mesh import times by ~3-5% until we don't get async static mesh builds.
Mesh build numbers for Nanite meshes:
1701216 tris:
Static mesh build: 11.2s
Static mesh build for the SDF async task (added in this CL): 2.3s
Async SDF build: 0.7s
Async card rep build: 0.15s

5524435 tris:
Static mesh build: 36.4s
Static mesh build for the SDF async task: 6.2s
Async SDF build: 1.2s
Async card rep build: 0.5s

1146238 tris
Static mesh build: 10.5s
Static mesh build for the SDF async task: 1.5s
Async SDF build: 0.6s
Async card rep build: 0.1s

#rb Daniel.Wright

[CL 14372405 by Krzysztof Narkowicz in ue5-main branch]
2020-09-22 23:04:05 -04:00
Michal Valient
95d19f95b1 [REVERB] Merging //UE4/Private-Reverb-Development@13832732
#rb graham.wihlidal, rune.stubbe, brian.karis, andrew.lauritzen, jeff.farris

[CL 13834854 by Michal Valient in ue5-main branch]
2020-07-06 18:58:26 -04:00
Josh Adams
aa9705149b Copying Private-LoadTimes-4.24 stream to Main. Biggest changes are in Materials/Shader memory freezing.
#rb none

[CL 11282608 by Josh Adams in Main branch]
2020-02-06 13:13:41 -05:00
ryan durand
471d972e62 Updating copyright for Engine Developer.
#rnx
#rb none


#ROBOMERGE-SOURCE: CL 10869240 via CL 10869516 via CL 10869902
#ROBOMERGE-BOT: (v613-10869866)

[CL 10870584 by ryan durand in Main branch]
2019-12-26 15:32:37 -05:00
mickael gilabert
745e065507 Added mesh distance field downsampling capability during serialization time (compressed and not compressed)
Added DownSampleMeshDistanceFieldDivider target platform variable

#rb daniel.wright
#rnx


#ROBOMERGE-SOURCE: CL 6442105 via CL 6444722

[CL 6444741 by mickael gilabert in Main branch]
2019-05-14 09:50:20 -04:00
Robert Manuszewski
2752c82adc Merging //UE4/Dev-Main @ 4664414 to Dev-Core (//UE4/Dev-Core)
#rb none

[CL 4675693 by Robert Manuszewski in Dev-Core branch]
2019-01-02 00:55:51 -05:00
Josh Adams
4f63a76b48 - Changed compression methods to be an FName instead of hardcoded enum
- Added support for compression plugins
- Removed the Custom compression concept, now using plugins properly
- Modified UnrealPak to use FNames, and allow for multiple compression methods (fallbacks on error or unavailability, etc)
- Added project settings for compression method selection for UnrealPak, and additional settings to be passed to UnrealPak (for instance, to control compression size/speed, etc)
- Deprecated a bunch of old function calls
- Improved pak file "old format" reading ability
- Brought over some changes from Fortnite for pak file encryption and memory savings
- Implemented a parallel compression pull request (#4129) to speed up pak file compression
#jira UE-51294
#rb ben.marsh

[CL 4480944 by Josh Adams in Dev-Core branch]
2018-10-17 14:18:10 -04:00
Ben Marsh
13d012685f Merging copyright update from 4.19 branch.
#rb none
#rnx
#jira

[CL 3818977 by Ben Marsh in Staging-4.19 branch]
2018-01-02 15:30:26 -05:00
Marcus Wassmer
60ef532ed8 Copying //UE4/Dev-Rendering to //UE4/Dev-Main (Source: //UE4/Dev-Rendering @ 3694557)
#lockdown Nick.Penwarden
#rb none

============================
  MAJOR FEATURES & CHANGES
============================

Change 3495522 by Rolando.Caloca

	DR - Enable gpu skinning on Vulkan

Change 3681208 by Jian.Ru

	Force bCastShadowAsMasked to false for opaque materials;
	Disable UI check box of bCastShadowAsMasked when blend mode is opaque or modulated

Change 3682631 by Rolando.Caloca

	DR - Copy 3682626
	Fix recompute tangents not being applied to different sections

Change 3684812 by Arne.Schober

	DR - Fix a crash and a Masterfile issue

Change 3684833 by Marcus.Wassmer

	Fix more non-unity issues

Change 3685236 by Arne.Schober

	DR - Fix some issues with Particles e.g stride was meant to be set to repeat and also subUV needs to be taken care of

Change 3685247 by Arne.Schober

	DR - accidentally removed bracket

Change 3686764 by Daniel.Wright

	In uncooked Feature Level ES2, fixed reflection capture data getting tossed in PostLoad when it is needed for encoding in OnRegister.

Change 3686775 by Marcus.Wassmer

	Fix bad merge

Change 3687022 by Marcus.Wassmer

	Fix Win32 compiles

Change 3687355 by Rolando.Caloca

	DR - Copy 3687334
	Fix for odd Vulkan crash

Change 3687537 by Arne.Schober

	DR - Making StaticArray faster as PSO descriptor uses them intensively (5ms in one infiltrator scene on PS4)
	Rewrote integer sequence to use fewer template instantiations for faster compile times and larger sequence support.

Change 3687546 by Arne.Schober

	DR - Remove unnecessary virtuals and recounts

Change 3688128 by Rolando.Caloca

	DR - Fix Linux compile error, rename Elements macro to GetNumArrayElements

Change 3688140 by Rolando.Caloca

	DR - Linux warning fix

Change 3688190 by Mark.Satterthwaite

	Use the correct #define for determining whether we are compiling for Metal in general, rather that only doing so for Metal + Mobile rendering. Should fix the skin-cache rendering.

	#jira UE-50912

Change 3688689 by Chris.Bunner

	Static analysis fixes.

Change 3688948 by Chris.Bunner

	More static analysis fixes.

Change 3689116 by Arne.Schober

	DR - [UE-51015] - moving alignment specifier

Change 3690645 by Marcus.Wassmer

	Restore per-element align for TStaticArray

Change 3690801 by Jian.Ru

	Marcus's fix FStaticMeshVertexFactories::ReleaseResources
	#jira UE-51093

Change 3690809 by Rolando.Caloca

	DR - Copy 3690806
	Fix Anisotropic not working on Vulkan

Change 3690874 by Benn.Gallagher

	Fix for index buffer overflow and clothing upgrade warnings.

	#jira UE-51026

Change 3691221 by Jian.Ru

	Fix log spam when -d3ddebug
	#jira UE-50977

Change 3691291 by Marcus.Wassmer

	Move global dynamic buffer commits to before GPU FX rendering.
	Fixes d3derror in ES2 preview.  The more subtle issue I believe is that the d3d11statecache is leaving streams bound for too long, but that requires more investigation

	#jira UE-51058

Change 3691361 by Rolando.Caloca

	DR - Fix resources not getting destroyed at RHI destruction time

	#jira UE-51057

Change 3691607 by Arne.Schober

	DR - interface change requested by Steve

Change 3691662 by Marcus.Wassmer

	Fix one bit of d3dwarning.  Need a 16 byte minimum to make 0 stride vbuffer happy for colors.

Change 3692268 by Rolando.Caloca

	DR - vk - Keep a reference to a buffer to avoid deletion - Fixes crash in Paragon

Change 3692403 by Jian.Ru

	Marcus's fix on automation test failure

Change 3692443 by Jian.Ru

	Back out changelist 3692403

Change 3692455 by Marcus.Wassmer

	Fix automation failure in tile rendering.
	Can't setdata for vertexfactories on the gamethread

Change 3692566 by Marcus.Wassmer

	Fix clang compiles

Change 3692664 by Chris.Bunner

	Updated default editor skeletal mesh.

Change 3692675 by Marcus.Wassmer

	Make the behavior of FCanvasTileRendererItem::FRenderData actually match the comment.
	Fixes automation crash.

Change 3692692 by Jian.Ru

	Fix a bug where only the first slice of 3d textures are cleared on XboxOne; Fix a rendering artifact when r.TranslucentLightingVolume is 0
	#jira UE-50636

Change 3693043 by Arne.Schober

	DR - [UE-51173]- Fixing Instanced Rendering Vertexbuffer SRV Resources not getting initzialized and re-set onto the vertexfactory after the Buffer has been updated

Change 3693284 by Marcus.Wassmer

	Duplicate 3682248.
	Fix for debug canvas draw randomly corrupting memory

Change 3693360 by Rolando.Caloca

	DR - Fix material events not showing up in RenderDoc

Change 3693549 by Marcus.Wassmer

	Fix incorrect flag check

Change 3693575 by Arne.Schober

	DR - null size check on StaticMeshVertexData

Change 3693677 by Marcus.Wassmer

	Make double plus sure the copy is a valid size

Change 3694155 by Marcus.Wassmer

	Generate correct strides for vertexfactories depending on whether color will be overridden or not by the component.  Fixes WEX and probably other similar bugs.
	ALSO fix horrible longstanding bug in OpenGL VertexDeclaration cache.  Strides not part of the operator== of the key so collisions/map walks would sometimes return the wrong decl with the wrong set of streamstrides.
	D3D has the same problem, causing spurious D3D warnings but I haven't fixed it yet.

Change 3694156 by Marcus.Wassmer

	This doesn't really matter because the decl is created dynamically but the stream elements might as well be right if we're gonna have them

Change 3694470 by Benn.Gallagher

	Fixed crash fixing up clothing sections index buffers in specific Unreal Tournament asset with modified oversized index buffer.

	#jira UE-51207

Change 3694557 by Chris.Bunner

	Static analysis and potential memory leak fix.

	Change 3684284 by Arne.Schober

	Manual Vfetch for StaticMeshes
	Skelmeshes also use the new Layout
	Skelmeshes use DDC

	Copying //UE4/Dev-Rendering-PSO to Dev-Rendering (//UE4/Dev-Rendering)

Change 3689555 by Arne.Schober

	DR - Fix performance regession cause by not sharing VertexFactory ptr in the static drawlist

[CL 3694667 by Marcus Wassmer in Main branch]
2017-10-13 11:32:28 -04:00