Commit Graph

382 Commits

Author SHA1 Message Date
charles derousiers
9e90b4f326 Fix Substrate versioning issue.
* Register added nodes into EditorOnly expression collection to be saved/displayed correctly
* Fix conversion invalidation when a node is deleted
* Change Substrate version meaning:
  * -1 no conversion has run
  *   0 the conversion fonction has run and no conversion was done. Or the material has been changed/touched since its conversion
  * >=0 the conversion function has run

#rb sebastien.hillaire

[CL 36760583 by charles derousiers in 5.5 branch]
2024-10-01 19:58:10 -04:00
charles derousiers
5637a69cff Add Substrate's auto-conversion versioning.
#rb sebastien.hillaire

[CL 36386671 by charles derousiers in 5.5 branch]
2024-09-18 08:13:27 -04:00
sebastien hillaire
333317d164 Substrate - preview tab now update when while material is edited, to show for instance the UI preview when editing Substrate UI material.
[FYI] Charles.deRousiers
#rnx

[CL 35487770 by sebastien hillaire in ue5-main branch]
2024-08-13 05:18:44 -04:00
jason nadro
8e0689548a Create the correct type of material expression when you promote the Shader Model output pin to a parameter.
#jira UE-221389
#rb Jeremy.Moore
[FYI] massimo.tristano, Jon.Cain
[RN] minor, Rendering / Materials and Shaders

[CL 35422134 by jason nadro in ue5-main branch]
2024-08-09 10:44:20 -04:00
JayLu2000
e04a0ccdd5 PR #12150: [MetaXR]: Integrate Adreno Offline Shader Compiler into UE
#jira UE-220969
#rnx
#rb Dmitriy.Dyomin, Florin.Pascu

[CL 35369646 by JayLu2000 in ue5-main branch]
2024-08-07 11:07:33 -04:00
jon cain
8ae2c2f1ab Change behaviour of the MLB function expressions to support legacy Vertex/Pixel attribute pathways + Substrate UseBlendParameters by allowing their settings to be changed via function call inputs (all default to false).
#rb massimo.tristano


#virtualized

[CL 35365361 by jon cain in ue5-main branch]
2024-08-07 07:55:03 -04:00
sameer mirza
67dcb0d674 Make SubstrateTreeView available in MaterialEditor
#rb Jon.Cain
#jira UE-219078

[CL 35364670 by sameer mirza in ue5-main branch]
2024-08-07 06:49:03 -04:00
jason nadro
13d65cc307 Fix missing Material Parameter Groups
- The underlying data still existed, but was removed from the property window (UI) so wasn't exposed to artists.
- This broke in the change that converted material editor only data into a separate sub object.
- When the sub object was moved it lost all its property specifiers that made it visible in the property window.
- Since this is a sub object there was special markup we needed to make it edit-inline and display correctly.

- Added the following property specifiers to make this work correctly:

**VisibleAnywhere**:  Indicates that this property is visible in all property windows, but cannot be edited. This Specifier is incompatible with the "Edit" Specifiers.
**Instanced**: Object ( UCLASS ) properties only. When an instance of this class is created, it will be given a unique copy of the Object assigned to this property in defaults. Used for instancing subobjects defined in class default properties. Implies EditInline and Export.
**AllowEditInlineCustomization**: Used for edit inline UObject* properties, enables detail class customization for instanced UObject properties.
**ShowInnerProperties**: Since this is a object pointer property, we want to show the inner properties in the property window (instead of a pointer to the UObject).

- Fixed a bug with the parameter groups which was adding a separate group for _each_ parameter that had that group name.  So if you had 10 parameters in the _Inputs_ group, you would end up with 10 groups in the array all named _Inputs_.  Now we add unique groups to the array.

#jira UE-176110
#rb dave.jones2
#tests Duplicating materials, adding parameter groups, renaming groups, sorting groups
[FYI] Colton.Daniels, bree.levy

[CL 35253147 by jason nadro in ue5-main branch]
2024-08-01 14:54:05 -04:00
jon cain
ea5a7e6e71 Merging of Get/SetSubstrateAttributes with Get/SetMaterialAttributes. Substrate specific nodes was introduced to simplify the creation of the upgraded material layering system but was only intended to act as a stop gap during the upgrade process. This change ensures we upgrade the existing material attribute nodes to be compatible with Substrate types.
Also updated the existing legacy->Substrate layers/blends to be compatible with this swapped out behaviour, and updated the existing Substrate (non-legacy) test layers/blends manually in the team test project.

#jira UE-215192
#rb Charles.deRousiers


#virtualized

[CL 35144171 by jon cain in ue5-main branch]
2024-07-29 12:51:01 -04:00
jason nadro
92f51ab48f The grid in the material editor has been hardcoded disabled for ~12 years, but we left in the ability to toggle the grid via the UI. This UI element didn't do anything and was useless.
- Remove the toggle in the UI for the grid (since it doesn't do anything).
- The Material Instance Editor still had the ability to toggle the grid, so this change effectively removes this behavior to keep the editors consistent.

#jira UE-176977, UE-139132
#rb Jon.Cain

[CL 34901704 by jason nadro in ue5-main branch]
2024-07-18 10:52:40 -04:00
massimo tristano
01b852097e [Material Editor] New material translator.
- Added FMaterialInsights, a new collector of material translation reflection data, to be used for accurate tracking of referenced resource, pin and connection type information  and which outputs the material writes to.
- Material connections insights wired up to pins and connection coloring.

[CL 34813969 by massimo tristano in ue5-main branch]
2024-07-15 11:30:34 -04:00
jason hoerner
1f9dc079aa Post Process: Upgraded material instance support, with overrides for User Scene Texture inputs / outputs and Blendable Location / Priority. Allows a base post process material to be reused in different places or multiple times in the post process pipeline without requiring a completely different Material graph. For example, a generic upsample, downsample, or blur Material can be implemented, rather than having to create a duplicate asset for each variation of location and input. Besides saving time creating content, material instances, unlike materials, can be created dynamically in code, allowing game logic or future editing tools to interactively configure the pipeline.
Preview windows and the r.PostProcessing.UserSceneTextureDebug mode were updated to handle material instances.  If both a base material and an instance of it are being edited, the instance will be preferred in other preview windows over the base material, rather than including both and having their effects potentially overlap.  Sorting of previewed materials was improved by ordering them in the reverse order they are encountered, so dependencies earlier in a chain are added first.  Fixed cases where preview windows weren't refreshed on certain types of changes or debug mode toggling.

To handle generic materials that can work at multiple resolutions, a "ScaleRelativeToInput" field was added, which generates the output resolution relative to a given User Scene Texture input.  Positive divisors downsample, while negative divisors upsample (so 2 would divide resolution by 2, while -2 would multiply by 2).  To handle the use of a generic material where you want the input or output to be SceneColor (say a first pass that reads SceneColor, or a last pass that writes SceneColor), you now have the option to specify "SceneColor" as a User Scene Texture input or output name.  This special name doesn't create a transient User Scene Texture, but just hooks up SceneColor itself.

The final feature added is a flag which suppresses PreExposure adjustments (multiply by View.OneOverPreExposure on input, multiply by View.PreExposure on output), useful if creating a material that doesn't care about the absolute value of linear colors (such as a blur where the inputs and outputs have the same scale), or where the output is not a linear color (such as a mask, modulation, or some sort of non-color data like positions, normals, offsets, IDs, etc).  Especially simplifies writing custom HLSL by avoiding the need for confusing View.OneOverPreExposure.xxx boilerplate, in addition to providing a minor perf gain.

#jira UE-215194
#rb eric.renaudhoude, Jason.Nadro, Ruslan.Idrisov

[CL 34375539 by jason hoerner in ue5-main branch]
2024-06-14 12:50:09 -04:00
jon cain
f00532eaf9 Update to Legacy Material Layering to support Substrate blend functionality.
- Currently disabled by the macro ENABLE_MATERIAL_LAYER_PROTOTYPE until we have a fully fleshed out system to enable.
- Implemented 2 new Substrate nodes: Get and Set attributes. Get allows the embedding of a Front Material with general Material Attributes for passing between functions, and Set splits the Material Attributes back into Front Material and Non-Substrate attributes. These are not strictly for use in Layering. This allows the Material Attributes including Substrate data to pass between Layers and Blends smoothly.
- Changed the autopopulation of Layer and Blend function material graphs to utilise the Get and Set attributes nodes. Non Substrate Attributes continue to pass through the legacy blend node, which only supports Horizontal blending. The Front Material is now separated and passes through the Substrate Horizontal Mixing node. This all occurs via a new engine level Blend Material Function MLB_Horizontal.
- Created update paths to convert legacy material layers to utilise the new Substrate structure (automatically converts to Horizontal mixing only)
- Created these structures using the "MaterialFunctionUsage" flags at the Function level -> This will ensure the ability to create contextual re-use of material functions regardless of whether they are marked layer or not.
- Altered the Preview functionality of Blend nodes so the expected output is clearer (uses the Input's embedded PreviewValue). Created a static default substrate slab creator function which supports this with any override color.
- Changed the colour of the Substrate utility nodes to match Substrate

#rb Jason.Nadro, sam.gateau, Sebastien.Hillaire
#jira UE-215192


#virtualized

[CL 34157861 by jon cain in ue5-main branch]
2024-06-06 11:04:13 -04:00
jason hoerner
311f875d30 [Re-submit Backout attempt take 2 -- original horde failure didn't repro on preflight, so maybe it was a spurious issue?]
Post Process Material:  Support for "UserSceneTextures" -- transient intermediate render targets that can be written and read by name in post process materials.  The post process section of materials has a UserSceneTexture output name, and a new UserSceneTexture node type has been added to read back those outputs as inputs.

Shader features:
* A resolution divisor can be specified on the output to allow things like half resolution targets.  If the same name is used with multiple resolutions, the most recently written resolution is used as an input.
* A UV clamping option was added to solve out of bounds interpolation issues when bilinear sampling lower resolution targets from a higher resolution pass.
* A human readable define based on the user specified name is added to HLSL (with prefix "PPIUser_"), allowing Custom HLSL nodes to refer to UserSceneTexture inputs by name.  Necessary because input slots are dynamically allocated.  Useful for things like blur kernels that use Custom HLSL to sample a range of inputs.
* All 5 Post Process Input slots are potentially available to UserSceneTextures -- built-in SceneTexture slots for a given location (like SceneColor, SeparateTranslucency, or SceneVelocity) are used for UserSceneTextures if not referenced in the shader.
* Supports translucent blending.  If the first write to a UserSceneTexture includes blending, it will be primed with the current input for the given location.
* Missing inputs are replaced with black.
* Simplified syntax for accessing SceneTextures / UserSceneTextures in Custom HLSL (see "SceneTextureFetch" macro).

Editing / debug features:
* Material editor preview window automatically includes other edited materials that feed inputs into the current material, allowing multi-pass effects to be interactively edited.
* Debug display of post process passes with UserSceneTexture inputs or output via r.PostProcessing.UserSceneTextureDebug.  Allows seeing order, location, and priority of passes, plus names of material, inputs, and output, and whether an output is written with blending.
* Debug display pops up automatically on error conditions (missing input, unused output), improving discoverability.  Suppressed by DisableAllScreenMessages (or setting CVar itself to zero).
* FRDGViewableResource can now be given dynamically generated heap allocated debug names (indicated by setting a flag immediately after construction), instead of only supporting static const strings.  Allows UserSceneTexture names to be displayed in debug displays, VisualizeTexture, GPU captures, and GPU dumps, instead of every resource getting the same name.

Mobile doesn't support post process domain materials at all, so the feature is not relevant there.  Tested on scene captures, split screen, and both legacy and new material translate code paths.  An existing bug was fixed where rendering post process materials with blending before bloom would crash, due to the output not being allocated with the render target flag set.

#rb eric.renaudhoude, Ruslan.Idrisov

[CL 34055494 by jason hoerner in ue5-main branch]
2024-06-01 13:02:37 -04:00
jason hoerner
45b4f68dc3 [Backout] - CL33992852 -- version bumps didn't seem to work -- hit same serialization errors, need to investigate further...
[FYI] jason.hoerner
Original CL Desc
-----------------------------------------------------------------
[Re-submit following Backout, with version bumps added]

Post Process Material:  Support for "UserSceneTextures" -- transient intermediate render targets that can be written and read by name in post process materials.  The post process section of materials has a UserSceneTexture output name, and a new UserSceneTexture node type has been added to read back those outputs as inputs.

Shader features:
* A resolution divisor can be specified on the output to allow things like half resolution targets.  If the same name is used with multiple resolutions, the most recently written resolution is used as an input.
* A UV clamping option was added to solve out of bounds interpolation issues when bilinear sampling lower resolution targets from a higher resolution pass.
* A human readable define based on the user specified name is added to HLSL (with prefix "PPIUser_"), allowing Custom HLSL nodes to refer to UserSceneTexture inputs by name.  Necessary because input slots are dynamically allocated.  Useful for things like blur kernels that use Custom HLSL to sample a range of inputs.
* All 5 Post Process Input slots are potentially available to UserSceneTextures -- built-in SceneTexture slots for a given location (like SceneColor, SeparateTranslucency, or SceneVelocity) are used for UserSceneTextures if not referenced in the shader.
* Supports translucent blending.  If the first write to a UserSceneTexture includes blending, it will be primed with the current input for the given location.
* Missing inputs are replaced with black.
* Simplified syntax for accessing SceneTextures / UserSceneTextures in Custom HLSL (see "SceneTextureFetch" macro).

Editing / debug features:
* Material editor preview window automatically includes other edited materials that feed inputs into the current material, allowing multi-pass effects to be interactively edited.
* Debug display of post process passes with UserSceneTexture inputs or output via r.PostProcessing.UserSceneTextureDebug.  Allows seeing order, location, and priority of passes, plus names of material, inputs, and output, and whether an output is written with blending.
* Debug display pops up automatically on error conditions (missing input, unused output), improving discoverability.  Suppressed by DisableAllScreenMessages (or setting CVar itself to zero).
* FRDGViewableResource can now be given dynamically generated heap allocated debug names (indicated by setting a flag immediately after construction), instead of only supporting static const strings.  Allows UserSceneTexture names to be displayed in debug displays, VisualizeTexture, GPU captures, and GPU dumps, instead of every resource getting the same name.

Mobile doesn't support post process domain materials at all, so the feature is not relevant there.  Tested on scene captures, split screen, and both legacy and new material translate code paths.  An existing bug was fixed where rendering post process materials with blending before bloom would crash, due to the output not being allocated with the render target flag set.

#rb eric.renaudhoude, Ruslan.Idrisov

[CL 33995029 by jason hoerner in ue5-main branch]
2024-05-29 23:35:52 -04:00
jason hoerner
566b5f93d2 [Re-submit following Backout, with version bumps added]
Post Process Material:  Support for "UserSceneTextures" -- transient intermediate render targets that can be written and read by name in post process materials.  The post process section of materials has a UserSceneTexture output name, and a new UserSceneTexture node type has been added to read back those outputs as inputs.

Shader features:
* A resolution divisor can be specified on the output to allow things like half resolution targets.  If the same name is used with multiple resolutions, the most recently written resolution is used as an input.
* A UV clamping option was added to solve out of bounds interpolation issues when bilinear sampling lower resolution targets from a higher resolution pass.
* A human readable define based on the user specified name is added to HLSL (with prefix "PPIUser_"), allowing Custom HLSL nodes to refer to UserSceneTexture inputs by name.  Necessary because input slots are dynamically allocated.  Useful for things like blur kernels that use Custom HLSL to sample a range of inputs.
* All 5 Post Process Input slots are potentially available to UserSceneTextures -- built-in SceneTexture slots for a given location (like SceneColor, SeparateTranslucency, or SceneVelocity) are used for UserSceneTextures if not referenced in the shader.
* Supports translucent blending.  If the first write to a UserSceneTexture includes blending, it will be primed with the current input for the given location.
* Missing inputs are replaced with black.
* Simplified syntax for accessing SceneTextures / UserSceneTextures in Custom HLSL (see "SceneTextureFetch" macro).

Editing / debug features:
* Material editor preview window automatically includes other edited materials that feed inputs into the current material, allowing multi-pass effects to be interactively edited.
* Debug display of post process passes with UserSceneTexture inputs or output via r.PostProcessing.UserSceneTextureDebug.  Allows seeing order, location, and priority of passes, plus names of material, inputs, and output, and whether an output is written with blending.
* Debug display pops up automatically on error conditions (missing input, unused output), improving discoverability.  Suppressed by DisableAllScreenMessages (or setting CVar itself to zero).
* FRDGViewableResource can now be given dynamically generated heap allocated debug names (indicated by setting a flag immediately after construction), instead of only supporting static const strings.  Allows UserSceneTexture names to be displayed in debug displays, VisualizeTexture, GPU captures, and GPU dumps, instead of every resource getting the same name.

Mobile doesn't support post process domain materials at all, so the feature is not relevant there.  Tested on scene captures, split screen, and both legacy and new material translate code paths.  An existing bug was fixed where rendering post process materials with blending before bloom would crash, due to the output not being allocated with the render target flag set.

#rb eric.renaudhoude, Ruslan.Idrisov

[CL 33992870 by jason hoerner in ue5-main branch]
2024-05-29 20:02:34 -04:00
massimo tristano
b686ccdbc0 [Material Editor] Deprecated UMaterialExpression::GetInputsView() in favor of making GetInput() the only way to access all inputs in a material expression.
To facilitate iteration, this change introduces FExpressionInputIterator that only provides a convenience layer on top of UMaterialExpression::GetInput()

This change makes code more robust and consistent and enables future further simplifications & optimizations.
#rb Jason.Nadro, Jon.Cain

[CL 33967108 by massimo tristano in ue5-main branch]
2024-05-29 05:52:14 -04:00
bob tellez
0f96e8541d [Backout] - CL33961982
[FYI] jason.hoerner
Original CL Desc
-----------------------------------------------------------------
Post Process Material:  Support for "UserSceneTextures" -- transient intermediate render targets that can be written and read by name in post process materials.  The post process section of materials has a UserSceneTexture output name, and a new UserSceneTexture node type has been added to read back those outputs as inputs.

Shader features:
* A resolution divisor can be specified on the output to allow things like half resolution targets.  If the same name is used with multiple resolutions, the most recently written resolution is used as an input.
* A UV clamping option was added to solve out of bounds interpolation issues when bilinear sampling lower resolution targets from a higher resolution pass.
* A human readable define based on the user specified name is added to HLSL (with prefix "PPIUser_"), allowing Custom HLSL nodes to refer to UserSceneTexture inputs by name.  Necessary because input slots are dynamically allocated.  Useful for things like blur kernels that use Custom HLSL to sample a range of inputs.
* All 5 Post Process Input slots are potentially available to UserSceneTextures -- built-in SceneTexture slots for a given location (like SceneColor, SeparateTranslucency, or SceneVelocity) are used for UserSceneTextures if not referenced in the shader.
* Supports translucent blending.  If the first write to a UserSceneTexture includes blending, it will be primed with the current input for the given location.
* Missing inputs are replaced with black.
* Simplified syntax for accessing SceneTextures / UserSceneTextures in Custom HLSL (see "SceneTextureFetch" macro).

Editing / debug features:
* Material editor preview window automatically includes other edited materials that feed inputs into the current material, allowing multi-pass effects to be interactively edited.
* Debug display of post process passes with UserSceneTexture inputs or output via r.PostProcessing.UserSceneTextureDebug.  Allows seeing order, location, and priority of passes, plus names of material, inputs, and output, and whether an output is written with blending.
* Debug display pops up automatically on error conditions (missing input, unused output), improving discoverability.  Suppressed by DisableAllScreenMessages (or setting CVar itself to zero).
* FRDGViewableResource can now be given dynamically generated heap allocated debug names (indicated by setting a flag immediately after construction), instead of only supporting static const strings.  Allows UserSceneTexture names to be displayed in debug displays, VisualizeTexture, GPU captures, and GPU dumps, instead of every resource getting the same name.

Mobile doesn't support post process domain materials at all, so the feature is not relevant there.  Tested on scene captures, split screen, and both legacy and new material translate code paths.  An existing bug was fixed where rendering post process materials with blending before bloom would crash, due to the output not being allocated with the render target flag set.

#rb eric.renaudhoude, Ruslan.Idrisov

[CL 33964553 by bob tellez in ue5-main branch]
2024-05-29 01:55:42 -04:00
jason hoerner
c166a4df8f Post Process Material: Support for "UserSceneTextures" -- transient intermediate render targets that can be written and read by name in post process materials. The post process section of materials has a UserSceneTexture output name, and a new UserSceneTexture node type has been added to read back those outputs as inputs.
Shader features:
* A resolution divisor can be specified on the output to allow things like half resolution targets.  If the same name is used with multiple resolutions, the most recently written resolution is used as an input.
* A UV clamping option was added to solve out of bounds interpolation issues when bilinear sampling lower resolution targets from a higher resolution pass.
* A human readable define based on the user specified name is added to HLSL (with prefix "PPIUser_"), allowing Custom HLSL nodes to refer to UserSceneTexture inputs by name.  Necessary because input slots are dynamically allocated.  Useful for things like blur kernels that use Custom HLSL to sample a range of inputs.
* All 5 Post Process Input slots are potentially available to UserSceneTextures -- built-in SceneTexture slots for a given location (like SceneColor, SeparateTranslucency, or SceneVelocity) are used for UserSceneTextures if not referenced in the shader.
* Supports translucent blending.  If the first write to a UserSceneTexture includes blending, it will be primed with the current input for the given location.
* Missing inputs are replaced with black.
* Simplified syntax for accessing SceneTextures / UserSceneTextures in Custom HLSL (see "SceneTextureFetch" macro).

Editing / debug features:
* Material editor preview window automatically includes other edited materials that feed inputs into the current material, allowing multi-pass effects to be interactively edited.
* Debug display of post process passes with UserSceneTexture inputs or output via r.PostProcessing.UserSceneTextureDebug.  Allows seeing order, location, and priority of passes, plus names of material, inputs, and output, and whether an output is written with blending.
* Debug display pops up automatically on error conditions (missing input, unused output), improving discoverability.  Suppressed by DisableAllScreenMessages (or setting CVar itself to zero).
* FRDGViewableResource can now be given dynamically generated heap allocated debug names (indicated by setting a flag immediately after construction), instead of only supporting static const strings.  Allows UserSceneTexture names to be displayed in debug displays, VisualizeTexture, GPU captures, and GPU dumps, instead of every resource getting the same name.

Mobile doesn't support post process domain materials at all, so the feature is not relevant there.  Tested on scene captures, split screen, and both legacy and new material translate code paths.  An existing bug was fixed where rendering post process materials with blending before bloom would crash, due to the output not being allocated with the render target flag set.

#rb eric.renaudhoude, Ruslan.Idrisov

[CL 33962030 by jason hoerner in ue5-main branch]
2024-05-28 21:25:12 -04:00
jonathan bard
591e341634 Fix for TObjectIterator iterating over garbage objects in material-related code
#rb jason.nadro

[CL 33928582 by jonathan bard in ue5-main branch]
2024-05-27 14:30:03 -04:00
jonathan bard
1cc956ceea Fixed crash in material editor stats, when preview material instances get GCed
#jira UE-215555
#rb Jason.Nadro

[CL 33848908 by jonathan bard in ue5-main branch]
2024-05-22 19:00:29 -04:00
wouter dek
eb1958007e Added DumpMaterialInfo commandlet, which writes a CSV with many material properties to disk.
Also added LWCUsagesCS to the material info panels.

[CL 33393128 by wouter dek in ue5-main branch]
2024-05-02 06:55:03 -04:00
sebastien hillaire
fb7e318533 Added in material editor info about wether or not a material is compatible with the light function atlas.
#rb Jason.Nadro

[CL 32972784 by sebastien hillaire in ue5-main branch]
2024-04-15 11:59:50 -04:00
christopher waters
ae9b1051dc Adding Texture Collection
- UTextureCollection data asset that just holds an array of Texture assets.
- Uses the new RHIResourceCollection RHI resource type which puts all the texture bindless indices into its own buffer.
- Adding TextureCollection material nodes for accessing and sampling from Texture Collections.

#rb massimo.tristano

[CL 32897524 by christopher waters in ue5-main branch]
2024-04-11 13:49:14 -04:00
massimo tristano
ba8a14ed2a [Material Editor] Fixed occasional crash when trying to create the preview of a deleted expression.
#jira UE-209894
#rb Jason.Nadro

[CL 32320942 by massimo tristano in ue5-main branch]
2024-03-19 06:06:25 -04:00