Commit Graph

17 Commits

Author SHA1 Message Date
andrew lauritzen
a49470a5ec VSM: disable screen ray and normal bias on subsurface materials
Can cause various artifacts with extreme opacity values

#jira UE-200409
#rb Ola.Olsson

[CL 31296340 by andrew lauritzen in ue5-main branch]
2024-02-08 13:34:46 -05:00
wouter dek
8f310241b2 Use DoubleFloat instead of tile+offset in various systems on GPU to improve numerical precision.
#jira UE-171685
#rb Charles.deRousiers, tim.doerries

[CL 30763421 by wouter dek in ue5-main branch]
2024-01-21 21:02:35 -05:00
andrew lauritzen
57a2260da0 Per-instance static/dynamic caching and support clipmap-level-specific WPO disable distance
- Improves various situations around instanced geometry (commonly foliage) getting transitioned to dynamic caching and never going back
- Improves performance in scenes with heavy foliage using WPO animation and WPO distance disable
- Support disabling WPO animation in clipmaps past a certain point (based on the WPO disable distance). Works even when caching/static caching is disabled as it can still be a good performance tool.
- Add cvar for greedy clipmap level selection; disabled by default. While this is a behavior change it addresses some old issues around coarse pages getting greedily chosen at certain angles, and also makes the behavior around the new WPO distance disable more predictable
- Invalidate instances when the evaluate WPO/WPO distance changes
- Invalidate clipmaps when the resolution changes enough that it would trigger different clipmap levels to enable/disable animation. This can be caused by resolution or FOV changes. While it's possible for dynamic resolution to trigger this, TBD whether it's a practical issue for it to happen occasionally. If need be we could add some hysteresis but it would also add additional tracking and complexity and just move when we have to invalidate anyways.

Few other misc fixes and improvements.

#jira UE-197817
#rb ola.olsson

[CL 30273485 by andrew lauritzen in ue5-main branch]
2023-12-12 15:12:11 -05:00
chris kulla
fffb652a2e RayTracing: Implement a new light grid used in raytracing passes (Translucency and Lumen Hit Lighting) based on the method used in the Path Tracer
The new light grid can localize the influcence of each light much better despite being built only in 2D. Some logic is duplicated between the path tracer and decals which use a similar system.  It should be possible to share some of the logic with future refactors.

This refactor also allows more than 256 lights (no code was actively depending on this limit anymore after the removal of RTR and RTGI). However there is still a fixed number of lights available per grid cell. Using the "Light Grid Occupancy" debug mode can help visualize where this might be occurring.

The following cvars can be used to control memory usage and performance:
 * r.RayTracing.LightGridResolution: Resolution of the 2D grid which holds lights
 * r.RayTracing.LightGridMaxCount: Maximum number of lights per grid cell (if there are fewer lights than this in the scene, that number will be used instead)

Code cleanup: Refactor  LIGHT_TYPE_* definitions to be shared across shaders and C++ code and remove duplicated definitions.

#jira UE-170690
#rb Aleksander.Netzel

[CL 29508005 by chris kulla in ue5-main branch]
2023-11-06 20:11:26 -05:00
andrew lauritzen
8c6ff8ce29 Few misc improvements for VSM:
1) Fix issue with r.SceneCulling 1 where instance culling was not respecting the detail geometry flag (and thus rendering all the small stuff into coarse pages)
2) Make clipmap visualization colors based on absolute level so they are consistent with the clipmap virtual address space visualization, and make more sense when you modify things like resolutionlodbias and clipmapfirstlevel, etc.
3) Add a cvar to scale the size of the nanite occluded instances buffer. This is related to UE-197175, but not really a proper fix. Added a cvar so we can at least use it to test if flicker/shadow issues are due to this.

#jira UE-197175
#rb ola.olsson

[CL 28793741 by andrew lauritzen in ue5-main branch]
2023-10-16 08:23:44 -04:00
christopher waters
bc786a735f Fixing BRANCH statements.
[FYI] andrew.lauritzen

[CL 28494900 by christopher waters in ue5-main branch]
2023-10-05 08:26:12 -04:00
andrew lauritzen
6d29db735f Allocate VSM shadow mask slots based on pruned light grid rather than relying on sorted light order
This avoids issues with simple lights getting sorted to the front of the list (required for some other passes) and wasting slots, and makes the allocation more robust against light ordering
Update clustered shading path to properly sample the new packed mask
Separate out VSM directional/local light sampling functions so that callers who know what the light type is (ex. anything light grid for local lights) do not need to include the other code paths in the shader

#rb ola.olsson

[CL 28494774 by andrew lauritzen in ue5-main branch]
2023-10-05 08:24:51 -04:00
andrew lauritzen
0ba82e077c Support nanite overdraw visualization in VSMs
#rb graham.wihlidal

[CL 27798209 by andrew lauritzen in ue5-main branch]
2023-09-12 13:19:05 -04:00
andrew lauritzen
e325509de6 Add simple "dynamic resolution" for VSMs that can dynamically decrease the global resolution LOD bias based on page pool pressure.
#jira UE-122101
#rb jamie.hayes

[CL 27112362 by andrew lauritzen in ue5-main branch]
2023-08-15 14:22:03 -04:00
andrew lauritzen
090b64dcc2 Significant changes and refactoring to VSM physical page allocation to support more persistent allocations:
- Support keeping pages that are not requested in a given frame, disabled to start but will be enabled soon. r.Shadow.Virtual.Cache.KeepOnlyRequestedPages
- Support LRU allocation of new pages. Only particularly meaningful with persistent allocations. Also disabled to start. r.Shadow.Virtual.Cache.AllocateViaLRU
- Lots of cleanup and refactoring of page allocation passes and shaders.
- Move page marking shaders into their own file as they are relatively independent from the allocation/caching and have dependencies on other systems (hair, water, etc)
- Clean up various cases of cache enabled/available/etc.
- Some minor cleanup of invalidations in prep for future work

#rb ola.olsson
#jira UE-147454
#preflight 642cad58da7f9583709d3172

[CL 24932187 by andrew lauritzen in ue5-main branch]
2023-04-05 13:48:25 -04:00
Charles deRousiers
c98a240ba9 Fix shader compilation warning.
#rb none
#jira UE-164924
#preflight shader
#fyi krzysztof.narkowicz, andrew.lauritzen

[CL 22451574 by Charles deRousiers in ue5-main branch]
2022-10-11 02:41:13 -04:00
wouter dek
517c4ca25d Make VSM clipmap CornerOffset relative and upgrade WorldCenter to 64-bit type to fix directional shadow LWC glitches
#jira ue-155125
#rb andrew.lauritzen
#preflight 631eded95b06877acb759720

[CL 21961247 by wouter dek in ue5-main branch]
2022-09-12 03:42:35 -04:00
andrew lauritzen
ae31bd8019 SMRT local lights updates
- Improvements to cube map filtering to eliminate various leaking artifacts at cube edges/corners
- Implement texel dither and optimal bias for local lights
- Remove some half stuff that was causing some sub-optimal compilation
- Fix VSM visualization alignment
- Add a general purpose permutation parameter that can be set for A/B testing projection performance that affects register allocation
- General cleanup

#rb ola.olsson
#preflight 62b350da767c9aaf349e3243

#ROBOMERGE-AUTHOR: andrew.lauritzen
#ROBOMERGE-SOURCE: CL 20779131 via CL 20780276 via CL 20780946
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v970-20704180)

[CL 20782054 by andrew lauritzen in ue5-main branch]
2022-06-22 17:22:27 -04:00
andrew lauritzen
70a2837739 Move static separate cache to second texture array slice rather than "below" in UV space:
- Avoid gotchas with max texture size when static separate enabled
- Simplify addressing logic in a number of places
- Avoid allocating extra HZB that we never use

Details:
- Support rendering/sampling to 2D depth texture array in Nanite and virtual shadow map pass
- Remove some unnecessary HZB-related cvars
- Remove unused permutations from VSM HW raster

#preflight 624f4e5611261bc7b2171208
#rb jamie.hayes

#ROBOMERGE-AUTHOR: andrew.lauritzen
#ROBOMERGE-SOURCE: CL 19679616 via CL 19679656 via CL 19679706
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v938-19570697)

[CL 19680680 by andrew lauritzen in ue5-main branch]
2022-04-07 18:36:13 -04:00
andrew lauritzen
e1b38f74a1 Support fallback to coarser pages in directional light SMRT
- Check the page table at the ray start as a guess at what resolution is available; iterate in that clipmap
- Support fallback while iterating, albeit at a performance cost

For current mapping strategies, similar performance and comparable quality to the "trilinear-like" solution today
- Resolution changes can now appear more directly at page boundaries rather than explicitly across clipmap boundaries, so depending on the given situation you may see "blocky" versions of the range bands rather than the range bands themselves. Not really a better or worse artifact, but worth noting.

NOTE: Fallbacks to very coarse data should technically also involve significant optimal biases, but we do not want to compute an optimal bias per tap. For now the texel dither optimal bias is sufficient based on the clipmap we are iterating in. We could put a minimum clamp on this but there's a direct tradeoff with losing potentially important fine-scale shadows.

#rb ola.olsson

#ROBOMERGE-AUTHOR: andrew.lauritzen
#ROBOMERGE-SOURCE: CL 19528017 via CL 19528309 via CL 19528326
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v937-19513599)

[CL 19532753 by andrew lauritzen in ue5-main branch]
2022-03-28 16:28:18 -04:00
andrew lauritzen
bd803d7e43 SMRT improvements:
- Add slope-based depth extrapolation which improves the quality of penumbras on angled receivers. Costs ~10% performance in some cases so maintaining a permutation/cvar (default on) for scalability.
- Change screen ray trace to be a simple "space skipping" ray that terminates as soon as it goes behind geometry and continue VSM trace from that distance. This avoids various contact-shadow-like artifacts and undesirable/inconsistent contact shadows from things that aren't in the VSM. In certain cases if regular contact shadows are desired on top of VSM the engine contact shadows can be enabled, as it is with CSMs.
- Remove a bunch of use of "halfs" in the shaders as they cause some extra ALU on some platforms and don't appear to really be helping with occupancy anymore
- Small bump to minimum normal bias clamp (only affects things very close to the camera)

#rb brian.karis
[FYI] ola.olsson

#ROBOMERGE-AUTHOR: andrew.lauritzen
#ROBOMERGE-SOURCE: CL 19411300 via CL 19411627
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v928-19376421)

[CL 19413239 by andrew lauritzen in ue5-main branch]
2022-03-16 17:30:21 -04:00
charles derousiers
2a2828c8a4 Add VirtualShadowMap prefix to all shaders related to virtual shadow map.
#rb andrew.lauritzen
#jira none
#preflight 620a2a37015ab8f37a3e2d2c
#lockdown juan.canada

#ROBOMERGE-AUTHOR: charles.derousiers
#ROBOMERGE-SOURCE: CL 18977253 in //UE5/Release-5.0/... via CL 18977320 via CL 18977399
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)

[CL 18977416 by charles derousiers in ue5-main branch]
2022-02-14 05:44:50 -05:00