This allows static lighting to be baked with a simpler material, or to tweak the color of indirect lighting.
Ensure the simplified material gets picked up by GPULM
#jira UE-144577
#rb Juan.Canada
#preflight 62263609123eef55e6f0cce8
[CL 19286047 by chris kulla in ue5-main branch]
Reduced Nanite material VS exports in GBuffer pass. Instead of it exporting the entire FVertexFactoryInterpolantsVSToPS struct, it now only exports ViewIndex and the remaining members are initialized in the PS.
Promoted FloatDerivX structs and constructers to common.ush, so they can be used be used globally, instead of just inside material shaders.
#jira UE-139652
#preflight 61f3f6e174510448a67c79b6
#rb graham.wihlidal
[FYI] brian.karis
#ROBOMERGE-AUTHOR: rune.stubbe
#ROBOMERGE-SOURCE: CL 18770882 in //UE5/Release-5.0/... via CL 18770890 via CL 18770983
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v903-18687472)
[CL 18770986 by rune stubbe in ue5-main branch]
#ROBOMERGE-AUTHOR: jeremy.moore
#ROBOMERGE-SOURCE: CL 18272828 via CL 18373230 via CL 18373286
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v895-18170469)
[CL 18373441 by jeremy moore in ue5-release-engine-test branch]
- USE_EDITOR_SHADERS moved MaterialTemplate.ush -> Common.ush to allow use in global shaders as well as in includes that happen earlier in MaterialTemplate.ush
- PLATFORM_SUPPORTS_EDITOR_SHADERS default define moved to Platform.ush to enable use in Common.ush
- Fetch vertex shader custom data from GPU-Scene whenever GPU-scene instance culling path is used.
- Plumb through per-instance editor data to upload in the payload buffer of GPU-Scene
- Skip uploading per-instance vertex attributes and creating VF uniform buffer when GPU-Scene is active (ISM)
- Fetch all instance attributes from GPU-Scene, custom data and editor data, and only do so for editor platforms (LocalVF)
- When doing UpdateInstances only recreate mesh draw commands if the instance count changed. Since we no longer have the per instance render data buffers they no longer are in the MDC and don't need to update. The only thing left in the MDC that needs updating is the instance count.
- Skip creating/flushing per-instance render data buffers for ISM proxies.
#rb Ola.Olsson, Jason.Nadro
#preflight 6171d98395715b0001872c00, 6171e2a94d6efa00018197af
#lockdown Michal.Valient
#ddcfill: 61729e14c33baf00011f4e8b
#ROBOMERGE-OWNER: jason.nadro
#ROBOMERGE-AUTHOR: jason.nadro
#ROBOMERGE-SOURCE: CL 17896781 via CL 18006634 via CL 18370361 via CL 18370432
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v895-18170469)
[CL 18370505 by jason nadro in ue5-release-engine-test branch]
Basic approach is to add HLSL types FLWCScalar, FLWCMatrix, FLWCVector, etc. Inside shaders, absolute world space position values should be represented as FLWCVector3. Matrices that transform *into* absolute world space become FLWCMatrix. Matrices that transform *from* world space become FLWCInverseMatrix. Generally LWC values work by extending the regular 'float' value with an additional tile coordinate. Final tile size will be a trade-off between scale/accuracy; I'm using 256k for now, but may need to be adjusted. Value represented by a FLWCVector thus becomes V.Tile * TileSize + V.Offset. Most operations can be performed directly on LWC values. There are HLSL functions like LWCAdd, LWCSub, LWCMultiply, LWCDivide (operator overloading would be really nice here). The goal is to stay with LWC values for as long as needed, then convert to regular float values when possible. One thing that comes up a lot is working in translated (rather than absolute) world space. WorldSpace + View.PrevPreViewTranslation = TranslatedWorldspace. Except 'View.PrevPreViewTranslation' is now a FLWCVector3, and WorldSpace quantities should be as well. So that becomes LWCAdd(WorldSpace, View.PrevPreViewTranslation) = TranslatedWorldspace. Assuming that we're talking about a position that's "reasonably close" to the camera, it should be safe to convert the translated WS value to float. The 'tile' coordinate of the 2 LWC values should cancel out when added together in this case. I've done some work throughout the shader code to do this. Materials are fully supporting LWC-values as well. Projective texturing and vertex animation materials that I've tested work correctly even when positioned "far away" from the origin.
Lots of work remains to fully convert all of our shader code. There's a function LWCHackToFloat(), which is a simple wrapper for LWCToFloat(). The idea of HackToFloat is to mark places that need further attention, where I'm simply converting absolute WS positions to float, to get shaders to compile. Shaders converted in this way should continue to work for all existing content (without LWC-scale values), but they will break if positions get too large.
General overview of changed files:
LargeWorldCoordinates.ush - This defines the FLWC types and operations
GPUScene.cpp, SceneData.ush - Primitives add an extra 'float3' tile coordinate. Instance data is unchanged, so instances need to stay within single-precision range of the primitive origin. Could potentially split instances behind the scenes (I think) if we don't want this limitation
HLSLMaterialDerivativeAutogen.cpp, HLSLMaterialTranslator.cpp, Preshader.cpp - Translated materials to use LWC values
SceneView.cpp, SceneRelativeViewMatrices.cpp, ShaderCompiler.cpp, InstancedStereo.ush - View uniform buffer includes LWC values where appropriate
#jira UE-117101
#rb arne.schober, Michael.Galetzka
#ROBOMERGE-AUTHOR: ben.ingram
#ROBOMERGE-SOURCE: CL 17787435 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v881-17767770)
[CL 17787478 by ben ingram in ue5-release-engine-test branch]
This shading node works very similarly to the RayTracingQualitySwitch, but only picks up its alternate port when compiling the material's path tracing permutation. This allows artists to customize the behavior of materials for the path tracer in cases where hacks are necessary for regular materials that are not needed on the path tracing side (glass in particular).
#rb Ben.Ingram
#preflight 61422a3e9bba9a000198c028
#ROBOMERGE-AUTHOR: chris.kulla
#ROBOMERGE-SOURCE: CL 17525755 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v870-17433530)
[CL 17525767 by chris kulla in ue5-release-engine-test branch]
Run a compute job that packs most commonly used instance data (LocalToWorld matrix and some other bits - 80 bytes) into per-instance vertex buffer. Vertex shader does not have access to GPUScene and instead loads instance data from a per-instance vertex buffer. If it needs more primitive/instance data than available then it will load it from Primitive UB, binding unique uniform buffer and breaking auto-instancing. Pixel shader has a full access to a GPUScene
There are 3 ways how FSceneDataIntermediates gets populated
1. PrimitiveId + GPUScene (Desktop)
2. Per-Instance data + Primitive UB (Mobile)
3. Primitive UB (auto-instancing disabled)
Details for GPUScene specific vertex inputs and access to FSceneDataIntermediates are hidden behind a macro:
VF_GPUSCENE_DECLARE_INPUT_BLOCK
VF_GPUSCENE_GET_INTERMEDIATES
FSceneDataIntermediates is now stored in FVertexFactoryIntermediates, FMaterialVertexParameters. Added a few GetPrimitiveData() overloads that allows you to access PrimitiveData depending on current context. Removed most of the cases where GetPrimitiveData() gets used with PrimitiveId.
#rb Ola.Ollson
#ROBOMERGE-SOURCE: CL 17093848 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v853-17066230)
[CL 17093856 by dmitriy dyomin in ue5-release-engine-test branch]