Commit Graph

109 Commits

Author SHA1 Message Date
tiago costa
9b94e09a38 Fix issues when compiling callable shaders using ddx/ddy.
#jira UE-155126
#rb aleksander.netzel
#preflight na

[CL 20431304 by tiago costa in ue5-main branch]
2022-05-30 11:25:24 -04:00
Jeremy Moore
dd8b90c9fb Remove unnecessary/unused use of INVARIANT in shader code.
INVARIANT is now only used on specific vertex shader outputs.
#preflight 627ecf70631ab437051a315a

[CL 20189879 by Jeremy Moore in ue5-main branch]
2022-05-13 17:41:28 -04:00
Dmitriy Dyomin
b3da0b39ae Use half precision for world vertex normal interpolators on mobile
#rb none
#jira none
#preflight none

[CL 20021938 by Dmitriy Dyomin in ue5-main branch]
2022-05-03 02:33:13 -04:00
Dmitriy Dyomin
bbbba527b5 Fixed: missing reflections when clustered option is enabled on mobile
#jira none
#rb none
#preflight 6267a961853fdb6fddad0e13

[CL 19916726 by Dmitriy Dyomin in ue5-main branch]
2022-04-26 04:21:05 -04:00
graham wihlidal
44f8bc1bb8 Implemented NaniteReplace material expression that can allow materials to special case Nanite vs non-Nanite material evaluation in the same graph
#rb ben.ingram
[FYI] brian.karis, jamie.hayes, rune.stubbe, jordan.walker
#preflight skip

#ROBOMERGE-AUTHOR: graham.wihlidal
#ROBOMERGE-SOURCE: CL 19729407 via CL 19729723 via CL 19730127
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v938-19570697)

[CL 19733277 by graham wihlidal in ue5-main branch]
2022-04-12 21:18:24 -04:00
Wei Liu
410565c3b6 Change the presicion of length2 from half to float to fix artifacts on mobile vulkan.
#jira none

#rb Dmitriy.Dyomin, Carl.Lloyd
#preflight 62328131ef5d0f0e8ffcc7fb

[CL 19415899 by Wei Liu in ue5-main branch]
2022-03-16 20:51:51 -04:00
guillaume abadie
fc45b950e2 Fixes remaining short-circuit in the renderer
#rb rune.stubbe

#ROBOMERGE-AUTHOR: guillaume.abadie
#ROBOMERGE-SOURCE: CL 19352016 via CL 19352024
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v926-19321884)

[CL 19356595 by guillaume abadie in ue5-main branch]
2022-03-11 12:09:45 -05:00
chris kulla
0d5620b07e Implement LightmassReplace for GPULM
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]
2022-03-07 11:49:42 -05:00
Ben Ingram
a321c34314 Remove Dot operation from new HLSL translator, replace with new 'Sum' unary op, combined with a Mul
#rb none
#jira none
#preflight none

[CL 19082779 by Ben Ingram in ue5-main branch]
2022-02-22 17:29:26 -05:00
tiantian xie
84a9e28627 Fix voxel reflection for Lumen. Add 1D buffer support when 3D texture is not compatible.
#jira 140266
#preflight 620c0938475fb819ddcbbb49

#ROBOMERGE-AUTHOR: tiantian.xie
#ROBOMERGE-SOURCE: CL 19060179 in //UE5/Release-5.0/... via CL 19075206
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v921-19075845)

[CL 19076831 by tiantian xie in ue5-main branch]
2022-02-22 13:59:49 -05:00
rune stubbe
2cc1d9d10f Made Lightmap/ShadowMask/AO sampling functions derivative aware, so they don't produce 2x2 quad artifacts when used with Nanite.
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]
2022-01-28 09:51:07 -05:00
Wei Liu
b7b3dd7fa6 Fix a bug that the GlobalClipPlane doesn't work on depth only vertex shader on mobile preview shader platform.
#jira none

#robomerge 5.0

#rb Dmitriy.Dyomin
#preflight 61e52196904123989a05d171

[CL 18631143 by Wei Liu in ue5-main branch]
2022-01-17 03:11:26 -05:00
jeremy moore
86a38894dc Fix shader compilation error for some platforms that need explicit uint type.
#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]
2021-12-03 16:21:02 -05:00
jason nadro
4abe2c5fa2 Make LocalVF ISM/HISM not need any instance attributes except in editor, move remaining data to GPU-Scene.
- 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]
2021-12-03 13:43:00 -05:00
ben ingram
49c5694b2e LWCDdx/y respect FORCED_TEXTURE_MIP being 0, fix compile failure if these functions are included in compute shaders
#rb none
#jira none

#ROBOMERGE-AUTHOR: ben.ingram
#ROBOMERGE-SOURCE: CL 18355875 in //UE5/Release-5.0/... via CL 18355885
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v895-18170469)

[CL 18355898 by ben ingram in ue5-release-engine-test branch]
2021-12-02 14:49:18 -05:00
sebastien hillaire
f8e0092b8b New start material buffer: 2 uint using rop and the rest is written through UAV.
Huge optimisation for console.

#rb charles.derousiers

#ROBOMERGE-AUTHOR: sebastien.hillaire
#ROBOMERGE-SOURCE: CL 18309039 in //UE5/Release-5.0/... via CL 18309083
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v895-18170469)

[CL 18309131 by sebastien hillaire in ue5-release-engine-test branch]
2021-11-29 09:31:58 -05:00
ben ingram
0bb0a923a0 Merging Dev-LWCRendering into Main, this includes initial work to support rendering with LWC-scale position
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]
2021-10-12 13:31:00 -04:00
aurel cordonnier
69fe095547 Merge from Release-Engine-Staging @ 17636544 to Release-Engine-Test
This represents UE4/Main @17638339 and Dev-PerfTest @17636504

[CL 17638842 by aurel cordonnier in ue5-release-engine-test branch]
2021-09-27 19:54:25 -04:00
dmitriy dyomin
8d67fa5502 Fixed incorrect PackSnorm2x16
#ROBOMERGE-AUTHOR: dmitriy.dyomin
#ROBOMERGE-SOURCE: CL 17547832 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v870-17433530)

[CL 17547833 by dmitriy dyomin in ue5-release-engine-test branch]
2021-09-17 00:41:00 -04:00
chris kulla
062adee1c5 Add PathTracingQualitySwitch node
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]
2021-09-15 16:05:14 -04:00
tiago costa
ed8f0cf523 Fix missing light attenuation decoding on forward/mobile codepaths.
#jira UE-126089
#rb Florin.Pascu, Mickael.Gilabert
#preflight 61393f4c2d09b9000168a982

#ROBOMERGE-AUTHOR: tiago.costa
#ROBOMERGE-SOURCE: CL 17469597 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v870-17433530)

[CL 17469602 by tiago costa in ue5-release-engine-test branch]
2021-09-09 05:18:07 -04:00
ben ingram
2351588c6a Add texture cube array assets, support for sampling in materials
#rb graham.wihlidal
#preflight 611ebf1a2c1f1c0001355fe7

#ROBOMERGE-OWNER: ben.ingram
#ROBOMERGE-AUTHOR: ben.ingram
#ROBOMERGE-SOURCE: CL 17240322 via CL 17268789
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v858-17259218)

[CL 17268797 by ben ingram in ue5-release-engine-test branch]
2021-08-23 12:36:17 -04:00
charles derousiers
0b931c4d72 Move shader types used in generated uniform buffers into a common file, to be automatically included.
#rb daniel.wright
#preflight 61120e8eafd67e0001da5cea

#ROBOMERGE-SOURCE: CL 17113134 via CL 17113150
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v854-17104634)

[CL 17113154 by charles derousiers in ue5-release-engine-test branch]
2021-08-10 02:17:17 -04:00
dmitriy dyomin
b0828d6beb Mobile specific implementation for auto-instancing. (disabled by default atm)
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]
2021-08-07 07:20:52 -04:00
guillaume abadie
edc669e6dc Encodes sqrt of velocity in the velocity buffer to have enough precision for history reprojections under slow movements at 8k
#rb none
[FYI] michael.gilabert, jack.porter

#ROBOMERGE-SOURCE: CL 16667793 via CL 16667817
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v834-16658389)

[CL 16667820 by guillaume abadie in ue5-release-engine-test branch]
2021-06-14 20:43:57 -04:00