Commit Graph

118 Commits

Author SHA1 Message Date
zach bethel
16dcf5b313 Refactored Lumen and Distance Field buffers to RDG.
- Replaced FRW{Structured, ByteAddress}Buffer with TRefCountPtr<FRDGPooledBuffer>
 - Replaced ResizeResourceIfNeeded with Resize{Structured, ByteAddress}BufferIfNeeded.
 - Replaced FScatterUploadBuffer with FRDGScatterUploadBuffer.
 - Removed awkward copy of page table buffers now that scatters are on the RDG timeline.
 - Reduced number of uniform buffers created by consolidating within FLumenSceneFrameTemporaries.
 - Fixed up const-correctness of FLumenSceneFrameTemporaries to sanity check that resources were not being mutated later in the frame.
 - Reduced explicit view creations somewhat.
 - Distance fields needs an FDistanceFieldSceneFrameTemporaries to cache RDG resources, but I held off on this due to the number of files it would touch.

#rb krzyzstof.narkowicz, daniel.wright

#ROBOMERGE-AUTHOR: zach.bethel
#ROBOMERGE-SOURCE: CL 19921040 via CL 19922067 via CL 19922607
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v943-19904690)

[CL 19925590 by zach bethel in ue5-main branch]
2022-04-26 14:37:07 -04:00
zach bethel
10131e1285 Refactored RDG in preparation for UnifiedBuffer conversions.
- Refactord 'Finalized Access' feature into a more flexible 'External' vs. 'Internal' access mode per resource toggle.
      - Resources can transition between modes multiple times within the graph.
      - Supports async compute pipeline.
      - Supports queueing of requests to avoid back-to-back helper passes.
      - This feature is needed to support conversion of GPU scene buffers.

 - Deprecated the ReadOnly and ForceTracking resource flags and added a 'SkipTracking' flag instead.
      - Previous semantics were confusing and error prone.
      - New model requires a manual flag to tell RDG never to transition a resource.
      - This flag is used for read-only dummy resources as an optimization.

 - Renamed some of the auxiliary 'FinalizedResource' utilities since the name no longer matches the semantics.

#preflight 6266cc6d0634d0904ce4ba46

[CL 19904734 by zach bethel in ue5-main branch]
2022-04-25 13:00:12 -04:00
tiago costa
d3e0196bd2 Fix error compiling shaders sampling distance fields when using non-default Distance Field Offset Data Structure
- Shaders sampling mesh distance fields must define OFFSET_DATA_STRUCT according to r.DFShadowOffsetDataStructure.
- Also renamed cvar r.DFShadowOffsetDataStructure to r.DistanceFields.OffsetDataStructure since it applies to all techniques sampling mesh distance fields.

#preflight 626661771a71643e8b8b07df
#rb Krzysztof.Narkowicz
#jira none

[CL 19900311 by tiago costa in ue5-main branch]
2022-04-25 07:32:32 -04:00
krzysztof narkowicz
367923aa7b GlobalDistanceField - optimizations and refactors
* Decreased Global Distance Field border from full voxel to half voxel and decreased page size from 16 to 8. This removes ~30% of pages, saving memory and improving update speed
* Half texel border requires to compute gradients using 8 page table fetches, but it didn�t influence Lumen tracing performance on console
* Smaller pages put some pressure on culling and other passes. Culling grid was switch from per page to per 4x4x4 pages. Overall full GDF update speed in FortGPUTestBed decreased from 5.89ms to 4.57ms
* Switched page table format to UInt32 in order to support larger Global Distance Field resolutions
* Moved all GlobalDistanceField shaders into /DistanceField/* folder, in future we should move other distance field shaders there
* Moved GlobalDistanceField page stats from r.Lumen.Visualize.Stats in Lumen code to r.GlobalDistanceField.Debug in GlobalDistanceField code
* Fixed Lumen normal visualization when only Global Distance Field tracing is enabled

#preflight 62630427006fa20b683b405a
[FYI] Tiago.Costa, Daniel.Wright

#ROBOMERGE-AUTHOR: krzysztof.narkowicz
#ROBOMERGE-SOURCE: CL 19873116 via CL 19873429 via CL 19874251
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v940-19807014)

[CL 19878047 by krzysztof narkowicz in ue5-main branch]
2022-04-22 19:55:41 -04:00
douglasjose
a76d51fe56 PR #9092 - fix spelling of "continuous" in the Blueprint node "AI > Tasks > Move To Location or Actor" (and elsewhere). Thank you for the submission, douglasjose!
https://github.com/EpicGames/UnrealEngine/pull/9092


#jira UE-149320
#preflight 625da0d0b21bb49791c4a531
#rb lauren.barnes
#fyi martin.sevigny

[CL 19790872 by douglasjose in ue5-main branch]
2022-04-18 14:30:53 -04:00
zach bethel
a00b40ad3b Deprecated GetRenderTargetItem() from IPooledRenderTarget.
#preflight 624ddb30090236773a1a83e0
#rb luke.thatcher

#ROBOMERGE-AUTHOR: zach.bethel
#ROBOMERGE-SOURCE: CL 19655641 via CL 19655653 via CL 19655661
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v938-19570697)

[CL 19657582 by zach bethel in ue5-main branch]
2022-04-06 18:24:24 -04:00
andrew davidson
692c7957c1 Require explicit constructors/casts when converting between FVector, FVector3d, and FVector3f.
Runtime files
#jira UE-122078
#rb Andrew.Davidson, Colin.McGinley
#preflight standard build

#ushell-cherrypick of 18817999 by Fred.Kimberley
#preflight 62441346f73c316f68db20c0

#ROBOMERGE-OWNER: andrew.davidson
#ROBOMERGE-AUTHOR: andrew.davidson
#ROBOMERGE-SOURCE: CL 19554852 via CL 19555052 via CL 19555055
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v937-19513599)

[CL 19561417 by andrew davidson in ue5-main branch]
2022-03-30 14:37:45 -04:00
andrew davidson
a29e2bc827 #ue5 - LWC: FVector4f <-> FVector4d conversion is now explicit.
FLinearColor has also been modified to make any double->float conversions explicit. Previously all 3D TVector versions were allowed to be implicit and thus could convert TVector<double> => FLinearColor => TVector4<float>.

Fixed up all engine and game casts. Added "//LWC_TODO: precision loss" around any explicit casts that previously were silently explicit and we may need to revisit for precision loss analysis.

#jira UE-122085
#rb Ben.Ingram, Andrew.Davidson
#preflight 61f24af473238441cb7bb0f1

#ushell-cherrypick of 18751249 by Zak.Middleton

#ROBOMERGE-OWNER: andrew.davidson
#ROBOMERGE-AUTHOR: andrew.davidson
#ROBOMERGE-SOURCE: CL 19478113 via CL 19493187 via CL 19493195
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v936-19480137)

[CL 19494217 by andrew davidson in ue5-main branch]
2022-03-24 09:07:58 -04:00
daniel wright
abe8a7e6c3 Global Distance Field:
* Creates a half res Coverage atlas when Lumen is active, which tracks whether the region in space is occupied by two sided materials (foliage), which then get a smaller surface expand to reduce over-occlusion
* r.LumenScene.GlobalSDF.FullyCoveredExpandSurfaceScale, r.LumenScene.GlobalSDF.UncoveredExpandSurfaceScale
* A larger MinStepSize is used in two sided regions to accelerate tracing: r.LumenScene.GlobalSDF.UncoveredMinStepScale

Radiance Cache:
* Fixed allocator overflow corrupting the cache
* Probes placed for foliage trace at the lowest resolution

Screen Probe Gather:
* Two Sided Foliage shading interpolates from Screen Probes a second time using the backfacing normal

Radiosity:
 * Ray directions are generated off of CardCoord instead of AtlasCoord, fixing a source of non-determinism

3.66ms   DiffuseIndirectAndAO -> 3.73ms in a scene with no foliage
4.71ms   DiffuseIndirectAndAO -> 6.05ms in a scene with heavy foliage, because fixing over-occlusion makes traces cost more

#preflight 621d89e5814dfc80784f1028
#jira UE-141204
#rb Krzysztof.Narkowicz
#lockdown Juan.Canada

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

[CL 19214930 by daniel wright in ue5-main branch]
2022-03-01 21:07:45 -05:00
krzysztof narkowicz
7ebc0a227a Lumen fixes
Workaround for DX11 AMD driver bug breaking world space radiance cache updates
Simple repro:
* Run default plane level on a AMD GPU with -dx11
* r.Lumen.RadianceCache.ForceFullUpdate 1
* r.Lumen.RadianceCache.Visualize 1
* Notice that some probes are black

Workaround for AMD driver bug breaking global SDF
* Enable Lumen or use r.AOGlobalDFResolution 224
* ShowFlag.VisualizeGlobalDistanceField 1
* Open default level with a plane, move plane away from the 1st clipmap, move it up and down, notice artifacts below it

Workaround for a bug in FMath::Clamp<int32>(int32, uint32, uint32) causing it to work as if it would be FMath::Clamp<uint32> and to overflow Lumen Scene atlas.

#lockdown Juan.Canada
#rb Danie.Wright
#preflight 6215174f840463c99a663425
#jira UE-143183

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

[CL 19136652 by krzysztof narkowicz in ue5-main branch]
2022-02-24 20:40:01 -05:00
tiago costa
78e7d11184 Fix incorrect heightfield data in Global Distance Field
Context:
- When texture is compiling, renderer uses a default texture instead.
- Compiling state is not reflected in bHasStreamingUpdatePending
- Distance to heightfield calculation involves a projection onto the heightfield normal which is incorrect when using default texture, resulting in distance to be 0 everywhere inside the heightfield xy bounds.

Change:
- check if HeightmapTexture->IsCompiling() in FLandscapeComponentSceneProxy::HeightfieldHasPendingStreaming().
- Only add primitive heightfield to UpdateRegionHeightfield if texture is not streaming or compiling.

#jira UE-142890
#preflight 620e18833609e193715f7e95
#rb Krzysztof.Narkowicz
#lockdown juan.canada

#ROBOMERGE-AUTHOR: tiago.costa
#ROBOMERGE-SOURCE: CL 19068236 in //UE5/Release-5.0/... via CL 19087982
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v921-19075845)

[CL 19130422 by tiago costa in ue5-main branch]
2022-02-24 18:42:28 -05:00
tiantian xie
496ffefe05 Enable the voxelization from height field to global distance field for metal SM5.
#jira 140266
#preflight 620d0ac955014c2b1efcf8b9

#ROBOMERGE-AUTHOR: tiantian.xie
#ROBOMERGE-SOURCE: CL 19060691 in //UE5/Release-5.0/... via CL 19078538
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v921-19075845)

[CL 19121565 by tiantian xie in ue5-main branch]
2022-02-24 14:39:30 -05:00
krzysztof narkowicz
03c883e176 Fixed Lumen crash on PS5 startup caused by unclamped ResBiasXY trying to allocate a weird number of SurfaceCache pages for an extremely long card
Misc:
* Renamed r.Lumen.DiffuseIndirect.MaxMeshSDFTraceDistance to r.Lumen.TraceMeshSDFs.TraceDistance as it controls also reflection traces
* Fixed Lumen global tracing mode with Landscape, which would only trace heightfields without any mesh SDFs and global SDF
* Disabled render target flag on GlobalSDF volume based on the recommendation from GCN guide: "For 3D images sampled from all directions (SDF tracing) Make sure to not flag for render target usage (forces possibly slower THIN tiling mode)" https://gpuopen.com/wp-content/uploads/2017/03/GDC2017-Advanced-Shader-Programming-On-GCN.pdf

#rb Daniel.Wright
#jira UE-142797
#preflight 620c2102565043444cac6101
#lockdown michal.valient

#ROBOMERGE-AUTHOR: krzysztof.narkowicz
#ROBOMERGE-SOURCE: CL 19010341 in //UE5/Release-5.0/... via CL 19010465 via CL 19010515
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)

[CL 19010521 by krzysztof narkowicz in ue5-main branch]
2022-02-15 23:38:23 -05:00
tiago costa
5997fc203f Fix assert in GlobalDistanceField.cpp when View.ViewState == nullptr.
#rb none
#jira none
#preflight 620a708e583261b0a658e2f8

[CL 18979433 by tiago costa in ue5-main branch]
2022-02-14 10:16:26 -05:00
krzysztof narkowicz
349d652b0a GlobalDistanceField - fixed holes between clipmap levels due to bilinear filtering pulling texels across clipmaps in GlobalDistanceFieldMipTexture
Also:
* Added r.LumenScene.UpdateViewOrigin to stop updating Lumen VoxelLighting and Global Distance Field origin for debugging
* Fixed r.AOUpdateGlobalDistanceField

#jira none
#rb Tiago.Costa
#preflight 62043f02a65a8a28462f5361

#ROBOMERGE-AUTHOR: krzysztof.narkowicz
#ROBOMERGE-SOURCE: CL 18935058 in //UE5/Release-5.0/... via CL 18935132 via CL 18935213
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)

[CL 18935221 by krzysztof narkowicz in ue5-main branch]
2022-02-10 09:28:01 -05:00
tiago costa
feb44a501a Fix issues r.AOGlobalDistanceFieldCacheMostlyStaticSeparately is disabled.
- Don't allocate PageTableCombinedTexture and use PageTableLayerTextures[GDF_Full] instead.
- Accumulate all primitive modifications info GDF_Full cache when not caching mostly static objects separately.

#preflight 6202c158bf28c072cbf38641
#rb krzysztof.narkowicz

[CL 18910647 by tiago costa in ue5-main branch]
2022-02-08 16:53:35 -05:00
tiago costa
5a4fbaec6c Fix result of last global distance field propagation step not being used.
#rb krzysztof.narkowicz
#preflight none

[CL 18910622 by tiago costa in ue5-main branch]
2022-02-08 16:52:30 -05:00
tiago costa
52b54ca696 Remove unused data from HeightfieldDescriptions buffer.
Remove unused param from ComposeHeightfieldsIntoPagesCS.
Added const keyword to GetHeightfieldRepresentation(...)
Remove TexCreate_RenderTargetable flag from VisualizeDistanceField texture since it is only used as UAV.

#fyi daniel.wright
#preflight 6202bbbd121599bf437e90a7

[CL 18906762 by tiago costa in ue5-main branch]
2022-02-08 14:04:52 -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
tiago costa
820c3df810 Fix GlobalDistanceField corruption when scene only contains heightfields.
Issue:
- Can't rely on FComposeHeightfieldsIntoPagesCS to initialize pages in its current form
- Multiple heightfield components can write to the same pages.
- FComposeHeightfieldsIntoPagesCS only runs on pages that overlap with heightfield components.

Fix:
- Run FComposeObjectsIntoPagesCS even when scene doesn't contain any mesh SDFs.
- It will initialize all pages that require it.
- Added FProcessDistanceFields permutation to skip iterating through mesh SDF lists when scene doesn't contain any.

#preflight 61f98390c54b18c42dd9b30a
#rb krzysztof.narkowicz

#ushell-cherrypick of 18812568 by tiago.costa

[CL 18823420 by tiago costa in ue5-main branch]
2022-02-02 05:42:31 -05:00
zach bethel
9996233f7a Removed unused legacy MSAA multi-texture support from IPooledRenderTarget.
- Deprecated legacy members from FPooledRenderTargetDesc.
 - Deprecated ETextureRenderTarget and removed from RDG.
 - TargetableTexture always equals ShaderResourceTexture.
 - Simplified render target pool FindFreeElement.
 - Create pooled buffers and textures with a known state.

#rb graham.wihlidal
#preflight 61f8488568795b2f45852274

#ROBOMERGE-AUTHOR: zach.bethel
#ROBOMERGE-SOURCE: CL 18796880 in //UE5/Release-5.0/... via CL 18797840 via CL 18799070
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v908-18788545)

[CL 18799188 by zach bethel in ue5-main branch]
2022-01-31 17:22:31 -05:00
tiago costa
3e6539db68 Fix GlobalDistanceField not getting correctly updated when scene only contains heightfields.
- Multiple branches that only checked for mesh SDFs needed to be updated.
- New permutation of AllocatePagesCS to skip mesh SDFs when none are in the scene.
- New permutations of ComposeHeightfieldsIntoPagesCS to support composing with None/Previous/Parent.
    - Previous - compose with mesh SDF pages.
    - Parent - compose with mostly static pages.
- Improvements to distance field visualization mode conditions.

#rb Krzysztof.Narkowicz, Patrick.Kelly
#preflight 61f7af8fe55232619f74490f

#ROBOMERGE-AUTHOR: tiago.costa
#ROBOMERGE-SOURCE: CL 18787631 in //UE5/Release-5.0/... via CL 18787637 via CL 18787659
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v903-18687472)

[CL 18787662 by tiago costa in ue5-main branch]
2022-01-31 04:59:02 -05:00
zak middleton
36c99f6887 #ue5 - LWC: FVector4f <-> FVector4d conversion is now explicit.
FLinearColor has also been modified to make any double->float conversions explicit. Previously all 3D TVector versions were allowed to be implicit and thus could convert TVector<double> => FLinearColor => TVector4<float>.

Fixed up all engine and game casts. Added "//LWC_TODO: precision loss" around any explicit casts that previously were silently explicit and we may need to revisit for precision loss analysis.

#jira UE-122085
#rb Ben.Ingram, Andrew.Davidson
#preflight 61f24af473238441cb7bb0f1

#ROBOMERGE-AUTHOR: zak.middleton
#ROBOMERGE-SOURCE: CL 18751249 in //UE5/Release-5.0/... via CL 18751253 via CL 18751319
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v903-18687472)

[CL 18751326 by zak middleton in ue5-main branch]
2022-01-27 03:30:41 -05:00
krzysztof narkowicz
83a5c30226 New Lumen user settings
Project
 * Ray Lighting Mode - project wide control for ray lighting quality

Post Process Volume
 * Lumen Scene Lighting Quality - drives Radiosity gather quality
 * Lumen Scene Detail - drives Lumen culling aggressiveness
 * Lumen Scene View Distance - controls the distance from the camera that Lumen Scene will be maintained
 * Lumen Scene Lighting Update Speed - drives Radiosity gather convergence speed
 * Final Gather Lighting Update Speed - drives Final Gather temporal accumulation strength
 * Max Trace Distance - the distance that Lumen features will trace through the scene
 * Ray Lighting Mode - local control for ray lighting quality

Primitive Component
 * Emissive Light Source - provides a hint to Lumen that the mesh has an important lighting contribution and should not be culled

Replaced r.Lumen.MaxTraceDistance with r.Lumen.MaxTraceDistanceScale
Increased MAX_GLOBAL_DF_CLIPMAPS to 6

#rb Krzysztof.Narkowicz
#preflight 61ef58b8ca3de856bce72093

#ROBOMERGE-OWNER: krzysztof.narkowicz
#ROBOMERGE-AUTHOR: daniel.wright
#ROBOMERGE-SOURCE: CL 18743987 in //UE5/Release-5.0/... via CL 18744701 via CL 18745671
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v903-18687472)

[CL 18745941 by krzysztof narkowicz in ue5-main branch]
2022-01-26 17:07:27 -05:00
richard wallis
9b72565453 Use UInt Dummy for GlobalDistanceFieldPageTableTexture to fix shader validation errors on macOS.
#jira none
[REVIEW] [at]will.damon
#preflight 61e17e71023139f0c926a14c

#ROBOMERGE-AUTHOR: richard.wallis
#ROBOMERGE-SOURCE: CL 18734474 in //UE5/Release-5.0/... via CL 18734479 via CL 18734534
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v903-18687472)

[CL 18734545 by richard wallis in ue5-main branch]
2022-01-26 08:27:36 -05:00