Commit Graph

235 Commits

Author SHA1 Message Date
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
jamie hayes
4a2eaa711f Spline mesh updates:
- Add system for spline meshes to cache their slice transforms into look-up textures to optimize spline evaluations in shaders.
- Optimize the Nanite cluster culling shader with spline mesh deformation enabled to limit the cost of this shader added to all Nanite culling.
- More tightly pack the spline mesh parameters into 7 float4s from 8 and rearrange them to optimize shader access.
- Add "Nanite Cluster Bounds Scale" to spline mesh parameters as a means of fixing rare artifacts caused by inaccurate cluster culling bounds.
- A few other various tweaks and fixes to Nanite spline meshes.
- With these improvements, r.Nanite.AllowSplineMeshes is now on by default

NOTE: This is a re-submission of a change that had been previously rolled back. It is now being resubmitted with fixes to the following issues:
- Gaps in spline meshes due to calculating endpoint tangents using finite differencing of the texture.
- Fixed an issue where spline mesh deformation was broken in RVT rendering.
- Fix to an assert that would trip in some commandlets that were using the scene uniform buffer without having first initialized FSystemTextures
- Handle extrapolation of spline sampling from manually specifying mesh extents that are smaller than the actual mesh boundaries.

#rb brian.karis
#jira UE-181795

[CL 27697936 by jamie hayes in ue5-main branch]
2023-09-07 20:32:42 -04:00
graham wihlidal
987e25e552 Renamed NoImplicitDerivatives -> NoDerivativeOps to also handle the explicit derivative cases, and cleaned up cflag naming
#rb rune.stubbe
[FYI] dan.elksnitis

[CL 27697881 by graham wihlidal in ue5-main branch]
2023-09-07 20:30:26 -04:00
graham wihlidal
3295fddd4f Implemented RDNA 1 & 2 ISA parser to optionally detect if a compute shader has any need for implicit derivatives (image sample, ddx, ddy, etc.). Certain shaders can be marked with CFLAG_ExplicitDerivatives, indicating the shaders prefer to handle derivatives explicitly, and this instructs the shader compiler - on supporting platforms - to parse the compiled ISA and look if any instructions requiring implicit derivatives are present. If none are found, the shader is decorated with NoImplicitDerivatives, indicating it is safe to ignore shading quads, etc..
#rb jason.nadro, luke.thatcher, dan.elksnitis
[FYI] brian.karis, rune.stubbe

[CL 27697142 by graham wihlidal in ue5-main branch]
2023-09-07 20:10:55 -04:00
andrew lauritzen
5f78653f1d Remove "Draw only VSM invalidating objects" and associated code.
Broken for a long while and different visualizations available now.

#rb ola.olsson
#jira UE-184606

[CL 27578246 by andrew lauritzen in ue5-main branch]
2023-09-02 18:44:30 -04:00
marc audy
65de35fdfb Lof elements that were not renamed yet.
- MSM_Substrate
- MCT_Substrate
- FStrataMaterialInput

#rb charles.derousiers

[CL 27563163 by marc audy in ue5-main branch]
2023-09-01 15:06:19 -04:00
sebastien hillaire
4f274d1ef3 Substrate - Rename/move file(s)
#rb none
[FYI] charles.derousiers

[CL 27514986 by sebastien hillaire in ue5-main branch]
2023-08-31 04:47:50 -04:00
sebastien hillaire
bbc5a450fc Substrate
- Legacy shading model node can now be used as a regular node.
- We can have multiple legacy shading model node in a isngle material now.
- There is now a ShadinModel drop down on the node that is used when the ShadingModel input is not plugged in
- Material instance shading model override is now accounted for by the legacy shading model node. Overriden from the HLSLTranslator when detected.


The data flow now for legacy mateiral conversion is as such:

--- Conversion time - UMaterial::ConvertMaterialToStrataMaterial()
Shading model => legacy node setup (shading model from expression: relink input, otherwise: set shading model on the conversion node)

--- GatherStrataMaterialInfo
Send back what is the shadingmodel used (or if it is "from expression")

--- UMaterial::RebuildShadingModelField()
Set material Domain, ShadingModel and ShadingModels according ot the returned value (FromExpression, etc.) from GatherStrataMaterialInfo.
Those values are not authorable but do enable shading models via defines from the HLSLTranslator. Seeing them being correct also helps to understand and debug.

--- Material instance shading model override
Overriden from the HLSLTranslator when detected.



#rb charles.derousiers

[CL 27504675 by sebastien hillaire in ue5-main branch]
2023-08-30 18:17:58 -04:00
rune stubbe
bccf39e9bc Implemented support for Nanite streaming pool larger than 2GB when it is supported by the hardware.
Fixed NANITE_SANITY_CHECK_STREAMING_REQUESTS path so it compiles again and reduced size of Magic to make room for wider page indices.
Changed independent coding of PageIndex and ClusterIndex in FVisibleCluster to a smaller combined encoding.
Added more descriptive error messages when running out of pool space.
#rb graham.wihlidal
[FYI] brian.karis, jamie.hayes

[CL 27504613 by rune stubbe in ue5-main branch]
2023-08-30 18:17:10 -04:00
xujie chen
20d86bdd33 Debug Visualization: Anyhitshader count, count the number of triangles hit per ray, and generate a heatmap for them
#rb tiago.costa, Tiantian.Xie, aleksander.netzel

[CL 27419469 by xujie chen in ue5-main branch]
2023-08-28 14:49:34 -04:00
guillaume abadie
9f963239c8 Implements UMaterial::bHasPixelAnimation
TSR's anti-flickering heuristic (r.TSR.ShadingRejection.Flickering=1) analyses how opaque pixels changes overtime and whenever the period of changes get lower than r.TSR.ShadingRejection.Flickering.Period, the heuristic tries to stabilise the pixel by relaxing the rejections.

The problems this creates is that any fast moving texture paning and other pixel animation made in material might looks identically flickering to TSR, because not knowing the motion of the pixels animations. TSR currently not having optical flow yet, the artists needs a way to say that the velocity buffer containing the geometric velocities used for reprojection actually exclude pixel animations.

This changes implements UMaterial::bHasPixelAnimation the artists can define on opaque geometry. It end up encoded forcing the primitive to draws velocity so that bit can be encoded in velocity buffer when VELOCITY_ENCODE_DEPTH==1 because there is no room left in stencil or gbuffer, and this has the advantage to works for both forward and deferred shading renderer.

This gets passdown to shaders through in the primitive uniform parameters so that nanite global shaders FEmitSceneDepthPS and FDepthExportCS can encode it when writing out velocity. It also allows to not need to compile additional material shader permutation of FVelocityPS for non masked opaque geometry. But this causes the limitation currently that any primitive that have at least one shader with this setting enabled will force the entire primitive's material slots to draw this bit in the velocity.

TSR in turn disables it's r.TSR.ShadingRejection.Flickering=1 heuristic on any pixel that have it sets using DecodeHasPixelAnimationFromVelocityTexture().

The flag can be visualized by artists with the VisualizeTemporalUpscaler show flag.

#rb jeremy.moore
#jira UE-187459

[CL 27385162 by guillaume abadie in ue5-main branch]
2023-08-25 14:12:42 -04:00
graham wihlidal
2f29df1243 Shader root constants support (initially) for DX12 - shader bundles now have a very fast path that pushes record index and 3 arbitrary pass data parms into root constants without the need for a global uniform buffer.
#rb luke.thatcher, yuriy.odonnell
[FYI] brian.karis, rune.stubbe, zach.bethel, mihnea.balta

[CL 27369189 by graham wihlidal in ue5-main branch]
2023-08-25 02:18:58 -04:00
dmitriy dyomin
0fdd2d15e2 Make sure we correctly setup single primitive data for "uniform view" path
[CL 27335763 by dmitriy dyomin in ue5-main branch]
2023-08-24 04:49:14 -04:00
jamie hayes
6cd9053b7c Effective backout of CL27173342 until spline mesh rendering issues can be addressed.
#jira UE-181795

#ushell-cherrypick of 27202918 by jamie.hayes

[CL 27204423 by jamie hayes in ue5-main branch]
2023-08-18 11:44:28 -04:00
jamie hayes
545fce3513 Spline mesh updates:
- Add system for spline meshes to cache their spline positions into a look-up texture to optimize spline evaluations in shaders.
- Optimize the Nanite cluster culling shader with spline mesh deformation enabled to limit the cost of this shader added to all Nanite culling.
- More tightly pack the spline mesh parameters into 7 float4s from 8 and rearrange them to optimize shader access.
- Add "Nanite Cluster Bounds Scale" to spline mesh parameters as a means of fixing rare artifacts caused by inaccurate cluster culling bounds.
- A few other various tweaks and fixes to Nanite spline meshes.
- With these improvements, r.Nanite.AllowSplineMeshes is now on by default

#rb brian.karis
[FYI] rune.stubbe, graham.wihlidal
#jira UE-181795

[CL 27187995 by jamie hayes in ue5-main branch]
2023-08-17 18:00:41 -04:00
marc audy
a75b48030b More compressible Nanite disk format (typically ~10% smaller after compression)
-Delta code vertex attributes and cluster refs
-ZigZag code deltas
-Store them as whole bytes
-Split high/mid/low bytes into separate streams

Transcode
-Transcode is now split into an independent pass and a number of dependent passes
-Launch a group per cluster instead of launching a group per potential cluster in a page and have them early out

Got rid of unused vertex color mode: NANITE_VERTEX_COLOR_MODE_WHITE
#rb brian.karis
[FYI] graham.wihlidal, jamie.hayes
#jira

[CL 27132972 by marc audy in ue5-main branch]
2023-08-16 00:39:49 -04:00
wouter dek
fd75a3ce32 Render Nanite primitives to static, non-static and uncached shadow maps (non-vsm), and use Nanite primitive filtering to select the primitives with the matching mobility on gpu.
Previously, geometry was only rendered to static maps, resulting in missing shadows when no static map was present.

#jira UE-190827
#rb andrew.lauritzen
#rb ola.olsson

[CL 26824413 by wouter dek in ue5-main branch]
2023-08-03 15:59:35 -04:00
rune stubbe
494a9aa930 Fixed builder crash when mesh vertex position coordinates become extremely large.
Clusters already have a max range for position. An additional exponent bit has been added to the position encoding to cover that range.
Added sanity check to make sure the largest possible cluster bound can always be encoded with the current position encoding parameters.
#rb jamie.hayes
[FYI] brian.karis, graham.wihlidal

[CL 26630917 by rune stubbe in ue5-main branch]
2023-07-26 21:23:48 -04:00
rune stubbe
7070422ce9 Refactor to remove assumption about page disk size being 2x the gpu page size.
Disk pages sizes can now have arbitrary sizes, but are assumed to rarely be more than ~1.5x when reserving memory or sizing the upload staging buffer.
#rb ola.olsson
[FYI] brian.karis, graham.wihlidal, jamie.hayes

[CL 26534981 by rune stubbe in ue5-main branch]
2023-07-22 06:33:46 -04:00
yuriy odonnell
5f5a14be1d Add support for enabling occlusion query based instance culling only for specific scene primitive types
* Add FPrimitiveSceneProxy::AllowInstanceCullingOcclusionQueries() method to allow occlusion queries (disallowed by default)
* Add PRIMITIVE_SCENE_DATA_FLAG_INSTANCE_CULLING_OCCLUSION_QUERIES
* Allow OQ for static meshes only
* Incompatible instances are treated as visible during OQ instance culling pass
* Tweak help text forVisualizeInstanceOcclusionQueries visualize menu entry

Only certain objects may benefit from per-pixel occlusion culling and otherwise HZB-based culling is sufficient.

#rb Jeremy.Moore

[CL 26501221 by yuriy odonnell in ue5-main branch]
2023-07-20 19:32:10 -04:00
jamie hayes
8fdbe295bf New material option: "Always Evaluate World Position Offset". This new option is used to force World Position Offset to always be evaluated for a material so that it cannot be disabled by the likes of "Evaluate World Position Offset" or "World Position Offset Disable Distance" on the component. This is useful for meshes that use WPO for behavior like billboarding (i.e. imposters) where WPO shouldn't be disabled for performance.
This option has the following knock-on effects of other rendering systems to prevent potential bugs or artifacts:
* For non-Nanite meshes, enabling this option will force instances of draw commands with this material applied to always invalidate VSM page cache when instance culling for VSM shadows.
* For Nanite meshes, enabling this option will force all clusters of all instances to pad cluster culling bounds and invalidate cached VSM pages, even if clusters don't have this material applied to it, as it would be prohibitively expensive to determine if no materials on the cluster would force invalidation.

#rb ola.olsson, massimo.tristano

[CL 26456226 by jamie hayes in ue5-main branch]
2023-07-19 05:48:22 -04:00
jeannoe morissette
28b4d2dc2a VulkanRHI: VKRT WIP: Add SystemParameters as shader_record to all ray tracing shaders.
#rb Aleksander.Netzel
#jira UE-171798
#rnx

[CL 26355446 by jeannoe morissette in ue5-main branch]
2023-06-30 16:53:02 -04:00
marc audy
1b8e7f29c4 Rework GPUScene support on mobile platforms.
Platforms that do support uniform buffer objects can now provide batched primitive data through UBO. There is a limit UBO range that can be accessed in shaders, so we group instances into batches that fit into this limit. Switch uses 64KB views, other platfroms16KB views. For each primitive we allocate 512Bytes and 256Bytes for instance. Mobile platforms that do not support UBO will use a desktop version of GPUScene.
There are a few things that still missing: Dynamic mesh passes,  static lighting
#rb ola.olsson, benjamin.rouveyrol

[CL 26354848 by marc audy in ue5-main branch]
2023-06-30 16:34:38 -04:00
andrew lauritzen
2a901165d1 Make VSM cache more persistent and robust against multiple renders in a single "frame" (scene captures, etc).
Remove multiple cache managesr that were implemented to work around issues with the previous naive implementation
Fixes some invalidation issues in cases where multiple managers existed previously

NOTE: This change brings pages from scene captures and ndisplay and similar systems back into the main physical page pool, so it may be necessary in some of these cases to increase the page pool size.

#rb ola.olsson jason.hoerner

[CL 26352061 by andrew lauritzen in ue5-main branch]
2023-06-30 15:15:06 -04:00
charles derousiers
ef61547e50 Fix incorrect RBF weight loading/streaming.
#rb none
#jira UE-184743

[CL 26351859 by charles derousiers in ue5-main branch]
2023-06-30 15:08:24 -04:00