Commit Graph

29 Commits

Author SHA1 Message Date
Brian Karis
c69a8a42cc One pass VSM projection, culled by the light grid.
Major SMRT optimization. Adaptive 7 rays per light with rough penumbra detection. Quality appears to surpass 1rpp with denoising.

#rb andrew.lauritzen

[CL 15190972 by Brian Karis in ue5-main branch]
2021-01-25 18:20:37 -04:00
andrew lauritzen
d45623ceed - Add pass to propogated mapped page information down the page table to enable O(1) lookups of any mapped page at the leaves
- Move some functions in PageManagement.usf to avoid confusing global resource scopes

#rb brian.karis
#fyi ola.olsson

[CL 15169596 by andrew lauritzen in ue5-main branch]
2021-01-22 23:23:16 -04:00
Ola Olsson
75247deb28 Hook up render state recreate to VSM Cvar (r.Shadow.v.Enable)
- needed to handle z-order change in cached render commands.

#rb andrew.lauritzen
#fyi graham.wihlidal

[CL 15162791 by Ola Olsson in ue5-main branch]
2021-01-22 04:59:02 -04:00
andrew lauritzen
a380d97b0e More non-Nanite VSM fixes
#rb graham.wihlidal
#fyi ola.olsson

[CL 15161956 by andrew lauritzen in ue5-main branch]
2021-01-21 23:47:09 -04:00
andrew lauritzen
e0478fe99c - Enable SMRT for spot lights (still a few minor issues but mostly working well)
- Change VSM page table to single packed uint with a field to allow single-lookup to find any mapped MIP
- Page table lookups go through helper function to encode/decode
- Remove some unused shadow emit code

#rb brian.karis
#fyi ola.olsson

[CL 15160590 by andrew lauritzen in ue5-main branch]
2021-01-21 19:15:53 -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
Ola Olsson
3b528bb5d5 Move Virtual SM common parameters to a uniform buffer to resolve shader name class issues.
#rb andrew.lauritzen

[CL 15135494 by Ola Olsson in ue5-main branch]
2021-01-19 10:17:05 -04:00
Brian Karis
baed699817 Point light VSM
#rb andrew.lauritzen

[CL 15133841 by Brian Karis in ue5-main branch]
2021-01-18 22:44:41 -04:00
andrew lauritzen
bd45865fd2 Fix toggling nanite off/on and nanite viewflags off by centralizing the location from which we decide on whether we're using Virtual Shadow Maps or not (top of Render()).
Centralize VSM enable CVar.

#rb ola.olsson

[CL 15052915 by andrew lauritzen in ue5-main branch]
2021-01-12 14:40:19 -04:00
zach bethel
c6cb1e82be Deprecated and gutted FSceneRenderTargets. Moved all textures over to FSceneTextures. Refactored the renderer to use RDG textures from FSceneTextures instead.
#rb arne.schober, luke.thatcher, christopher.waters, kenzo.terelst

[CL 15040082 by zach bethel in ue5-main branch]
2021-01-11 14:49:16 -04:00
andrew lauritzen
43ac742379 Fix/improve a variety of VSM artifacts:
- Use engine contact shadow trace function to respect a few tweaks there including the cast contact shadow flag
  - Had to stop short of including all the hair/eye-specific stuff as it is very hard-coded currently and not appropriate for general VSM shader...
- Fix self-intersection issues with short contact shadow traces
- Reduce default length of contact shadow trace to reduce artifacts
- Add normal-based offset to shadow lookup positions to reduce issues with projection aliasing and Nanite mesh LOD
- Add small page dilation region to avoid normal offset walking off mapped pages
  - Will likely eventually converge some of the sampling logic with SMRT to make it more robust as well, but dilation is a useful feature regardless
- Sample both clipmap levels with SMRT by default as performance of dynamically only sampling one doesn't seem to gain much and some artifacts are avoided.

#review brian.karis
#jira UE-103582

[CL 15031479 by andrew lauritzen in ue5-main branch]
2021-01-08 22:26:52 -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
zach bethel
924417b66f Moved more Nanite resources over to RDG.
#fyi graham.wihlidal
#jira none

[CL 14917602 by zach bethel in ue5-main branch]
2020-12-14 15:13:06 -04:00
Krzysztof Narkowicz
f484d3a594 Lumen - implemented virtual shadow map support for shadowing Lumen's surface cache.
#jira none
#rb Andrew.Lauritzen

[CL 14915815 by Krzysztof Narkowicz in ue5-main branch]
2020-12-14 14:39:11 -04:00
Rune Stubbe
00e07341c2 Added support for two-pass HZB culling with Nanite multi-view
Two pass occlusion for Non-VSM shadows
Changes shadowmap atlas rendering to render into the border, so we have real data for wide shadowmap filtering kernels. Also improves atlas HZB performance.

#rb ola.olsson
#fyi graham.wihlidal, brian.karis, andrew.lauritzen

[CL 14762582 by Rune Stubbe in ue5-main branch]
2020-11-17 06:16:49 -04:00
Ola Olsson
a9b6b0e0a8 Refactor virtual shadow maps to remove needless extract and register external of RDG resources.
- Changed (most) intermediate buffers & textures in FVirtualShadowMapArray to RDG buffers/textures
- Removed GenerateIdentityPageTables as it was no longer working.
- Renamed GeneratePageFlagsFromLightGrid -> BuildPageAllocations to better reflect current function.

#rnx
#rb Andrew.Lauritzen

[CL 14693244 by Ola Olsson in ue5-main branch]
2020-11-09 15:47:39 -04:00
zach bethel
f3fb7ddab6 Moved RDG builder to top of Deferred Shading Render function. Ported hit proxy rendering to RDG.
#rb christopher.waters
#jira none

[CL 14589785 by zach bethel in ue5-main branch]
2020-10-27 13:40:36 -04:00
Marc Audy
50a3d7d368 Merge Release-Engine-Staging to Main @ CL# 14467590
This represents UE4/Main @ 14432125 + some cherrypick fixes

[CL 14468207 by Marc Audy in ue5-main branch]
2020-10-09 22:42:26 -04:00
Marcus Wassmer
3b81cf8201 Merging using //UE5/Main_to_//UE5/Release-Engine-Staging @14384769
autoresolved files
#rb none

[CL 14384911 by Marcus Wassmer in ue5-main branch]
2020-09-24 00:43:27 -04:00
andrew lauritzen
fa0a428cb1 Rename virtual shadow map sampling parameters structure.
Fix issues with contact shadow offset in virtual shadow map shader
- Need to ensure we only offset the  depth test, not the clipmap level selection or occluder distance computation

#fyi ola.olsson
#rb none

[CL 14206061 by andrew lauritzen in ue5-main branch]
2020-08-27 20:31:32 -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
graham wihlidal
2f504476a0 Fixed remaining cases where Nanite/VSMs shouldn't be compiled on certain platforms (including Metal/Vulkan)
#rb none
#fyi brandon.schaefer, josh.adams, ola.olsson

[CL 14145867 by graham wihlidal in ue5-main branch]
2020-08-19 14:22:37 -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