Commit Graph

31 Commits

Author SHA1 Message Date
jason hoerner
0267d53323 DisplayCluster: Virtual Shadow Map cache can optionally be allocated per view, and enabled that feature for Virtual Production. Significant performance win by avoiding constant cache thrashing when rendering multiple families. Frame time goes from ~45 ms to ~26 ms for Valley test scene (Node 2), GPU bound in both cases. Separate cache per view isn't implemented for split screen views (single view family with multiple views), but Virtual Production doesn't use that, and support for that could be added in the future.
#jira UE-142732
#rb andrew.lauritzen ola.olsson
#preflight 628d06a45c3ef99a7b2fffa3

[CL 20351116 by jason hoerner in ue5-main branch]
2022-05-24 13:17:13 -04:00
andrew lauritzen
c79193c915 Many LWC fixes for virtual shadow maaps:
- Shadow PreViewTranslation and ClipmapOrigin become full LWC tile/offset values on the GPU
- In most cases, the camera's and shadow's PreViewTranslations can be subtracted on the GPU to produce a regular-range value to transform from PrimaryView.TranslatedWorld to ShadowView.TranslatedWorld
- Miner cleanup and improvements to SMRT trace loop
- Remove special case for ortho matrices disabling PreViewTranslation in FViewMatrices
- Remove broken static function local and associated cvar r.PreViewTranslation

#preflight 6205dd571404d0fef964d721
#jira UE-139824
#rb graham.wihlidal
#lockdown juan.canada

#ROBOMERGE-AUTHOR: andrew.lauritzen
#ROBOMERGE-SOURCE: CL 18956693 in //UE5/Release-5.0/... via CL 18956877 via CL 18957087
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)

[CL 18958948 by andrew lauritzen in ue5-main branch]
2022-02-11 14:57:27 -05:00
ola olsson
1e2e7de5aa Fix missing VSM invalidations (where the primitive transform is not updated, but e.g., a skinned mesh is animating)
- Add bHasDeformableMesh to FPrimitiSceneProxy to declare if the meshes are deformed, e.g., skeletal mesh, to be able to catch this case.
- also fix incorrect tracking of revealed primitives (causes invalidation errors with missing shadows when meshes are culled on the CPU).
- Add cvar switch to turn off the new behavior (for emergency use) r.Shadow.Virtual.Cache.DeformableMeshesInvalidate (defaults to 1)

#jira UE-133211
#rb andrew.lauritzen
#preflight 620389584c05b86e6d60185a
#lockdown juan.canada

#ROBOMERGE-AUTHOR: ola.olsson
#ROBOMERGE-SOURCE: CL 18915487 in //UE5/Release-5.0/... via CL 18920329 via CL 18922688
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v916-18915374)

[CL 18923422 by ola olsson in ue5-main branch]
2022-02-09 15:11:16 -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
3542cab338 FMatrix explicit cast fixes - Renderer
#rb ben.ingram, zak.middleton
#preflight 61f285e71e5d78c38307cda4

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

[CL 18752338 by andrew davidson in ue5-main branch]
2022-01-27 07:20:20 -05:00
ola olsson
95f303b0cd Fix bug in new rendered primitive tracking for VSM (incorrectly used upper boundfor non-persistent primitive IDs).
#rb rune.stubbe
#preflight 61e7fb10614a721b0c3db801

#ROBOMERGE-AUTHOR: ola.olsson
#ROBOMERGE-SOURCE: CL 18656867 in //UE5/Release-5.0/... via CL 18656871 via CL 18656875
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v900-18638592)

[CL 18656880 by ola olsson in ue5-main branch]
2022-01-19 07:04:51 -05:00
andrew lauritzen
82ac76bfc6 Temporary work-around for assert firing on some machines
#rb none
[FYI] ola.olsson
#preflight none

#ROBOMERGE-AUTHOR: andrew.lauritzen
#ROBOMERGE-SOURCE: CL 18649481 in //UE5/Release-5.0/... via CL 18649858 via CL 18650107
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v900-18638592)

[CL 18650352 by andrew lauritzen in ue5-main branch]
2022-01-18 17:56:40 -05:00
ola olsson
5d9aa916c8 Add tracking of culled prims for cached VSM, to correctly and efficiently invalidate primitives that move (even if they are culled)
- Disable view-dependent CPU culling of primitives for local-light VSMs (to fix incorrect caching).
- Track per-light cache data for clipmaps to enable storing bit flags for rendered primitives.
- Make invalidations skip primitives that were never rendered into a clipmap, and mark invalidated primitives as not rendered.

#rb andrew.lauritzen
#preflight 61e6c37b3778a195deabfb8a

#ROBOMERGE-AUTHOR: ola.olsson
#ROBOMERGE-SOURCE: CL 18639158 in //UE5/Release-5.0/... via CL 18639165 via CL 18639180
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v899-18417669)

[CL 18639190 by ola olsson in ue5-main branch]
2022-01-18 08:51:35 -05:00
andrew lauritzen
9e7886cc82 Add epsilon to fix some flickering lit pixels in shadowed regions due to numeric precision in the SMRT sample comparison.
Add a cvar for the clipmap level depth scale, primarily for debug purposes.

#rb ola.olsson
[FYI] daniel.wright
#preflight 61d646acdb0309127d0ed214

#ROBOMERGE-AUTHOR: andrew.lauritzen
#ROBOMERGE-SOURCE: CL 18533629 in //UE5/Release-5.0/... via CL 18534025
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v899-18417669)

[CL 18534205 by andrew lauritzen in ue5-release-engine-test branch]
2022-01-06 14:20:46 -05:00
andrew lauritzen
eccc470d1c Initial VSM scalability settings
Expand Z range of clipmap levels to fix some rare artifacts related to SMRT walking off the Z range with certain settings.

#rb ola.olsson
#preflight 61aea891fc6bcc8e1975cdff

#ROBOMERGE-AUTHOR: andrew.lauritzen
#ROBOMERGE-SOURCE: CL 18400198 in //UE5/Release-5.0/... via CL 18400211
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v896-18170469)

[CL 18400217 by andrew lauritzen in ue5-release-engine-test branch]
2021-12-07 16:24:58 -05:00
andrew lauritzen
ead3650569 Virtual shadow maps: early out on pixels backfacing the light in both projection and page allocation
Page allocation part is a fairly minor benefit in most scenes but can occasionally make a big difference.
Projection early-out is a pretty uniform benefit all the time, especially with SMRT.

#preflight 612d1b836a14cc000118f03a
#rb ola.olsson

#ROBOMERGE-SOURCE: CL 17388425 via CL 17389280
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v865-17346139)

[CL 17389330 by andrew lauritzen in ue5-release-engine-test branch]
2021-09-01 13:13:01 -04:00
andrew lauritzen
35f696abf5 Use conservative CPU cull volume for VSM clipmaps to avoid missing non-nanite geometry in cached pages.
Better labeling for some GPU profiling regions.
Fix to frustum vertex buffer usage flag.

#rb ola.olsson

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

[CL 16675251 by andrew lauritzen in ue5-release-engine-test branch]
2021-06-15 12:47:24 -04:00
andrew lauritzen
c373a4445f Fix depth range precision and offset/clamping issues with VSM cached pages
- Instead, create a reference depth range with a guard band that we reuse frame to frame until we get too close to the edge, at which point we invalidate that clipmap level's cached pages (if any)
- Does not significantly affect invalidations, even when moving quickly near surfaces, since those cases would already get invalidated when those pixels moved to a different clipmap level
- Sets up for not re-copying cached VSM pages every frame

#rb ola.olsson
[FYI] brian.karis

#ROBOMERGE-SOURCE: CL 16492432 in //UE5/Private-Frosty/...
#ROBOMERGE-BOT: STARSHIP (Private-Frosty -> Main) (v823-16466674)

[CL 16492445 by andrew lauritzen in ue5-main branch]
2021-05-27 17:36:27 -04:00
andrew lauritzen
d32436ea2c Lower default clipmap range to avoid potential precision issues with non-Nanite instance culling.
Should only really affect planet-scale atmospheric sky rendering with shadows onto cloud type cases, which is not the default config.

#rb graham.wihlidal, ola.olsson
#lockdown nick.whiting

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

[CL 16060017 by andrew lauritzen in ue5-main branch]
2021-04-20 08:44:23 -04:00
andrew lauritzen
181bc2e497 Reenable VSM HZB to help with some of the Nanite buffer overrun cases
Add virtual clipmap levels near the camera to cover extreme close-ups
Add Nanite view compation debug output
Make VSM resolution lod bias consistent for directional and local lights
Remove some unnecessary code from ProjectionCommon.ush which gets included in material shaders

#jira UETOP-1088
#rb graham.wihlidal, ola.olsson
[FYI] brian.karis
#lockdown graham.wihlidal

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

[CL 15994621 by andrew lauritzen in ue5-main branch]
2021-04-13 16:54:28 -04:00
andrew lauritzen
9b0a6fab9d Remove complete shadow maps and replace with direct VSM sampling
- Move VSM parameters into a single uniform buffer; required for base pass rendering.
  - SRVs are initialized to dummy data until they are computed during the frame and subsequently updated before any VSM sampling.
  - Make names and usage more consistent with other UB bindings in mesh passes
- Direct injection of VSM into translucent volume and fog
- Support VSM sampling in forward lighting shaders
  - Enabled and bound currently for translucent forward and single pass water meshes
- Support VSM sampling in sky atmosphere and cloud rendering
  - NOTE: Sky atmosphere LUT pass currently executes before BasePass and ShadowDepths so it will not sample proper data and throw a warning. Moving passes around to address this will come in a future commit.

#rb Brian.Karis, Ola.Olsson, Sebastien.Hillaire, Zachary.Bethel

#ROBOMERGE-OWNER: andrew.lauritzen
#ROBOMERGE-AUTHOR: andrew.lauritzen
#ROBOMERGE-SOURCE: CL 15649858 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v779-15635321)
#ROBOMERGE-CONFLICT from-shelf

[CL 15650486 by andrew lauritzen in ue5-main branch]
2021-03-08 23:14:54 -04:00
andrew lauritzen
ceabdff2a2 - Add support to mark coarse pages in mips/clipmap levels
- Fix optimal plane bias with clipmap LOD fallback
- Clean up and optimize some of the clipmap level offset math
- Rename some fields to make the resuse between clipmaps/mips clear

#rb brian.karis, ola.olsson

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

[CL 15466676 by andrew lauritzen in ue5-main branch]
2021-02-18 21:09:05 -04:00
graham wihlidal
200151a3bc Renamed r.Shadow.v.* cvars to r.Shadow.Virtual.* to be more obvious, and also renamed VSM.* resource prefixes to Shadow.Virtual.*
#rb brian.karis
[FYI] ola.olsson, andrew.lauritzen

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

[CL 15454805 by graham wihlidal in ue5-main branch]
2021-02-18 13:44:36 -04:00
andrew lauritzen
c9627e03e2 Rearrage clipmaps so that their snapping aligns more across levels
- Levels are now strictly pow2 sizes and snap to half their size (instead of internal page boundaries).
- Propogate mips propgates along clipmap levels instead of mips for directional lights
- Provide a O(1) lookup for clipmaps as well that will fall back to coarser data. Do not use it by default for current opaque shading where we know by construction where the mapped pages are.
Still some minor cleanup and optimization possible to come in a future commit.

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

[CL 15399908 by andrew lauritzen in ue5-main branch]
2021-02-12 19:00:35 -04:00
Ola Olsson
981111f9c9 Implement multi-view support for VSM clipmaps (i.e., split screen and stereo)
#rb andrew.lauritzen

[CL 15283162 by Ola Olsson in ue5-main branch]
2021-02-02 15:25:19 -04:00
andrew lauritzen
eb93f3b0c8 Grab bag of virtual shadow fixes:
- Fix SMRT with non-nanite geometry (wasn't sampling the second map)
- Fix toggling distance field shadow cascade on when VSMs are enabled (trying to create a distance field complete shadow map)
  - This is a bit of a questionable case, but at least does not crash now
- Remove dependence of clipmap max distance on shadow cascade distance and replace with a cvar
  - Will likely want to do something similar for far culling distance for non-nanite stuff, but TBD
  - May eventually want a parameter back on the light, but for now just having a cvar set high is good as there is little overhead with Nanite meshes
- Add some debug output for SMRT spot lights

#jira UERNDR-682
#rb brian.karis
#fyi ola.olsson

[CL 15215315 by andrew lauritzen in ue5-main branch]
2021-01-27 01:49:27 -04:00
Ola Olsson
876ee313e1 Non-Nanite directional light VSM Prototype (disabled, depends on instance culling)
- All non-nanite VSM code is wrapped in ENABLE_NON_NANITE_VSM define (on by default if GPUCULL_TODO is on)
- Added FProjectedShadowInfo with setup to gather primitives for clipmap VSM
- Added RenderVirtualShadowMapsHw to FVirtualShadowMapArray to draw into the VSM
- Shadow depth Vertex shader contains logic to route the instances to pages and uses clip distance to clip to page boundary
- Added culling shaders to replicate instances for each overlapped page

#rb rune.stubbe
#fyi graham.wihlidal,brian.karis,andrew.lauritzen

[CL 15144144 by Ola Olsson in ue5-main branch]
2021-01-20 08:46:15 -04:00
andrew lauritzen
ea36c322ad Scale clipmap resolution by main view resolution.
#rb ola.olsson

[CL 14987547 by andrew lauritzen in ue5-main branch]
2021-01-04 20:05:41 -04:00
andrew lauritzen
fb0b1d790b Initial shadow map ray tracing support for directional lights
- Disabled by defaul to start. Enable with r.Shadow.v.SMRT.RayCountDirectional 1
- Denoiser will now use temporal reprojection when SMRT is enabled (disable with r.Shadow.v.Denoiser.Temporal 0)
- Variety of fixes and refactors to existing VSM and projection code
- Still a few edge cases that will be improved in future around screen space trace and similar, but working fairly robustly for reasonable light source size settings

#rb ola.olsson
#fyi brian.karis

[CL 14942586 by andrew lauritzen in ue5-main branch]
2020-12-16 17:57:13 -04:00
andrew lauritzen
b23585628f Adjust some VSM clipmap settings to avoid running out of pages
- Don't bias the "first" clipmap level based on the resolution bias so that the effective "max" resolution at the near clipmap remains the same. There's no right/wrong on this one but this way is likely more intuitive.

#rb none
#fyi ola.olsson

[CL 14602087 by andrew lauritzen in ue5-main branch]
2020-10-28 15:00:35 -04:00