Commit Graph

20 Commits

Author SHA1 Message Date
andrew lauritzen
54ae421ce0 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
#ROBOMERGE-BOT: (v835-16672529)

[CL 16675244 by andrew lauritzen in ue5-main branch]
2021-06-15 12:46:58 -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
andrew lauritzen
377205cc04 Minor precision improvement to clipmap math far away from the origin.
Remove some of the logical asserts as they can trip due to precision in these cases, but it is not a catestrophic error, and the checks were mostly useful when developing the initial logic.

#jira UE-97981

#ROBOMERGE-SOURCE: CL 14271083 in //UE5/Release-5.0-M2/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-M2 -> Main) (v724-14254601)

[CL 14271277 by andrew lauritzen in ue5-main branch]
2020-09-08 13:37:21 -04:00
andrew lauritzen
5014926a72 Shadow projection shader refactoring.
Sampling a virtual shadow map (directional clipmap or spot light) can now be more easily done by:
- Include FVirtualShadowMapProjectionParameters in shader parameter struct
- Call FVirtualShadowMapArray::SetShaderDefines in ModifyCompilationEnvironment
- Set shader parameters via FVirtualShadowMapArray::SetProjectionParameters
- Calling SampleVirtualShadowMapDepth in the shader

#review ola.olsson

[CL 14201665 by andrew lauritzen in ue5-main branch]
2020-08-27 14:20:18 -04:00
Ola Olsson
f044aa8b42 Implemented invalidation of Virtual Shadow Maps for all GPU-Scene updates (Add/Remove/Movement)
- Added LastUpdateSceneFrameNumber to Instance data
- Added GetGPUSceneFrameNumber() to access View.FrameNumber or GPU-Scene specific GPUSceneFrameNumber
- Moved GPUScene class to GPUScene.h
- Moved logic to add/remove instance data to GPU scene to class memebers.
- Added functions in FVirtualShadowMapArrayCacheManagerto invalidate footprints of removed or moved instances before GPU scene update.
- Render to virtual shadow map now invalidates as dynamic the footprint of any cluster that had LastUpdateSceneFrameNumber == GetGPUSceneFrameNumber()

#rb rune.stubbe,andrew.lauritzen
#fyi zach.bethel

[CL 14179043 by Ola Olsson in ue5-main branch]
2020-08-25 10:06:54 -04:00
andrew lauritzen
f56c73960d Various nanite and virtual shadow refactoring:
- Remove virtual shadow cascades path and enable clipmaps instead
- Restore full resolution dense shadow maps even when virtual shadow maps are enabled. Combine dense and virtual shadow maps in the screen space shadow mask during projection.
- Remove "copy to fallback" path for virtual shadows; to be replaced by a separate explicit fallback map or similar. This will break Reverb indirect occlusion with Nanite geometry when virtual shadow maps are on for now. For functional testing, disabling virtual shadow maps will still work.
- Fix a bug with point light shadow projection matrices
- Change VirtualShadowMapId's to "int" since we set them to INDEX_NONE (-1) in a bunch of places

[CL 14156014 by andrew lauritzen in ue5-main branch]
2020-08-20 14:06:29 -04:00
Ola Olsson
90810d2428 Refactored ShadowProjectionData to not have any view dependence
- simple matter of moving out view.PreTranslation handling

#rb andrew.lauritzen

[CL 14145303 by Ola Olsson in ue5-main branch]
2020-08-19 12:54:43 -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