diff --git a/TestProjects/HDRP_DXR_Tests/Assets/Scenes/902_Materials_SG_Variants/StackLit/Shader Graphs_StackLit_Transparent.mat b/TestProjects/HDRP_DXR_Tests/Assets/Scenes/902_Materials_SG_Variants/StackLit/Shader Graphs_StackLit_Transparent.mat index 922cddc3af2..ca63d1088db 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/Scenes/902_Materials_SG_Variants/StackLit/Shader Graphs_StackLit_Transparent.mat +++ b/TestProjects/HDRP_DXR_Tests/Assets/Scenes/902_Materials_SG_Variants/StackLit/Shader Graphs_StackLit_Transparent.mat @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 4 + version: 5 --- !u!21 &2100000 Material: serializedVersion: 6 @@ -33,10 +33,9 @@ Material: MotionVector: User RenderType: Transparent disabledShaderPasses: - - MOTIONVECTORS + - TransparentDepthPostpass - TransparentBackface - TransparentDepthPrepass - - TransparentDepthPostpass m_SavedProperties: serializedVersion: 3 m_TexEnvs: @@ -52,12 +51,21 @@ Material: m_Texture: {fileID: 2800000, guid: fcecce6d2c9be8d418a27f0658a2210d, type: 3} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} + - _Texture2DAsset_6ea313656c2744b59b6ca90317e3dc1c_Out_0: + m_Texture: {fileID: 2800000, guid: a720075b2a0ff8440bc021a465769340, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} - _Texture2DAsset_da5ed3679908438d89ee705e2cccd98c_Out_0: m_Texture: {fileID: 2800000, guid: a720075b2a0ff8440bc021a465769340, type: 3} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} + - _Texture2DAsset_fb70cff2f9454b0193c4b5eaff34a18b_Out_0: + m_Texture: {fileID: 2800000, guid: fcecce6d2c9be8d418a27f0658a2210d, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} m_Floats: - Vector1_555A0A0: 0.5 + - _AddPrecomputedVelocity: 0 - _AlphaCutoffEnable: 0 - _AlphaDstBlend: 10 - _AlphaSrcBlend: 1 @@ -65,13 +73,16 @@ Material: - _BlendMode: 0 - _CullMode: 2 - _CullModeForward: 2 + - _DepthOffsetEnable: 0 - _DoubleSidedEnable: 0 - _DoubleSidedNormalMode: 2 - _DstBlend: 10 + - _EnableBlendModePreserveSpecularLighting: 0 - _EnableFogOnTransparent: 1 + - _OpaqueCullMode: 2 - _ReceivesSSR: 1 - _ReceivesSSRTransparent: 0 - - _RenderQueueType: 1 + - _RenderQueueType: 4 - _RequireSplitLighting: 0 - _SrcBlend: 1 - _StencilRef: 0 @@ -84,12 +95,14 @@ Material: - _StencilWriteMaskDistortionVec: 4 - _StencilWriteMaskGBuffer: 14 - _StencilWriteMaskMV: 40 + - _SupportDecals: 1 - _SurfaceType: 1 - _TransparentBackfaceEnable: 0 - _TransparentCullMode: 2 - _TransparentDepthPostpassEnable: 0 - _TransparentDepthPrepassEnable: 0 - _TransparentSortPriority: 0 + - _TransparentWritingMotionVec: 0 - _TransparentZWrite: 0 - _UseShadowThreshold: 0 - _ZTestDepthEqualForOpaque: 4 diff --git a/TestProjects/HDRP_DXR_Tests/ProjectSettings/HDRPProjectSettings.asset b/TestProjects/HDRP_DXR_Tests/ProjectSettings/HDRPProjectSettings.asset index e536bbd68e8..d421a0c8270 100644 --- a/TestProjects/HDRP_DXR_Tests/ProjectSettings/HDRPProjectSettings.asset +++ b/TestProjects/HDRP_DXR_Tests/ProjectSettings/HDRPProjectSettings.asset @@ -22,4 +22,4 @@ MonoBehaviour: m_WizardActiveTab: 0 m_WizardNeedRestartAfterChangingToDX12: 0 m_WizardNeedToRunFixAllAgainAfterDomainReload: 0 - m_LastMaterialVersion: 4 + m_LastMaterialVersion: 5 diff --git a/TestProjects/HDRP_HybridTests/ProjectSettings/HDRPProjectSettings.asset b/TestProjects/HDRP_HybridTests/ProjectSettings/HDRPProjectSettings.asset index 790b9e50395..4a8969d4d38 100644 --- a/TestProjects/HDRP_HybridTests/ProjectSettings/HDRPProjectSettings.asset +++ b/TestProjects/HDRP_HybridTests/ProjectSettings/HDRPProjectSettings.asset @@ -22,4 +22,4 @@ MonoBehaviour: m_WizardActiveTab: 0 m_WizardNeedRestartAfterChangingToDX12: 0 m_WizardNeedToRunFixAllAgainAfterDomainReload: 0 - m_LastMaterialVersion: 4 + m_LastMaterialVersion: 5 diff --git a/TestProjects/HDRP_PerformanceTests/ProjectSettings/HDRPProjectSettings.asset b/TestProjects/HDRP_PerformanceTests/ProjectSettings/HDRPProjectSettings.asset index 474a353f44b..396b7a34b6a 100644 --- a/TestProjects/HDRP_PerformanceTests/ProjectSettings/HDRPProjectSettings.asset +++ b/TestProjects/HDRP_PerformanceTests/ProjectSettings/HDRPProjectSettings.asset @@ -22,4 +22,4 @@ MonoBehaviour: m_WizardActiveTab: 0 m_WizardNeedRestartAfterChangingToDX12: 0 m_WizardNeedToRunFixAllAgainAfterDomainReload: 0 - m_LastMaterialVersion: 4 + m_LastMaterialVersion: 5 diff --git a/TestProjects/HDRP_RuntimeTests/ProjectSettings/HDRPProjectSettings.asset b/TestProjects/HDRP_RuntimeTests/ProjectSettings/HDRPProjectSettings.asset index c3b1e121026..d1b2277884b 100644 --- a/TestProjects/HDRP_RuntimeTests/ProjectSettings/HDRPProjectSettings.asset +++ b/TestProjects/HDRP_RuntimeTests/ProjectSettings/HDRPProjectSettings.asset @@ -22,4 +22,4 @@ MonoBehaviour: m_WizardActiveTab: 0 m_WizardNeedRestartAfterChangingToDX12: 0 m_WizardNeedToRunFixAllAgainAfterDomainReload: 0 - m_LastMaterialVersion: 4 + m_LastMaterialVersion: 5 diff --git a/TestProjects/HDRP_Tests/ProjectSettings/HDRPProjectSettings.asset b/TestProjects/HDRP_Tests/ProjectSettings/HDRPProjectSettings.asset index 474a353f44b..396b7a34b6a 100644 --- a/TestProjects/HDRP_Tests/ProjectSettings/HDRPProjectSettings.asset +++ b/TestProjects/HDRP_Tests/ProjectSettings/HDRPProjectSettings.asset @@ -22,4 +22,4 @@ MonoBehaviour: m_WizardActiveTab: 0 m_WizardNeedRestartAfterChangingToDX12: 0 m_WizardNeedToRunFixAllAgainAfterDomainReload: 0 - m_LastMaterialVersion: 4 + m_LastMaterialVersion: 5 diff --git a/TestProjects/SRP_SmokeTest/ProjectSettings/HDRPProjectSettings.asset b/TestProjects/SRP_SmokeTest/ProjectSettings/HDRPProjectSettings.asset index 1bcee60c90c..3d732e41574 100644 --- a/TestProjects/SRP_SmokeTest/ProjectSettings/HDRPProjectSettings.asset +++ b/TestProjects/SRP_SmokeTest/ProjectSettings/HDRPProjectSettings.asset @@ -18,4 +18,4 @@ MonoBehaviour: m_ProjectSettingFolderPath: HDRPDefaultResources m_WizardPopupAtStart: 0 m_WizardActiveTab: 0 - m_LastMaterialVersion: 4 + m_LastMaterialVersion: 5 diff --git a/TestProjects/VisualEffectGraph_HDRP/ProjectSettings/HDRPProjectSettings.asset b/TestProjects/VisualEffectGraph_HDRP/ProjectSettings/HDRPProjectSettings.asset index 1a57960fd77..8e073ba2a69 100644 --- a/TestProjects/VisualEffectGraph_HDRP/ProjectSettings/HDRPProjectSettings.asset +++ b/TestProjects/VisualEffectGraph_HDRP/ProjectSettings/HDRPProjectSettings.asset @@ -21,4 +21,4 @@ MonoBehaviour: m_WizardActiveTab: 0 m_WizardNeedRestartAfterChangingToDX12: 0 m_WizardNeedToRunFixAllAgainAfterDomainReload: 0 - m_LastMaterialVersion: 4 + m_LastMaterialVersion: 5 diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md index 05afdc80ff3..4a9cce10e94 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md @@ -81,6 +81,8 @@ From Unity 2020.2, HDRP includes a new rectangular area shadow evaluation functi From Unity 2020.2, the macro ENABLE_RAYTRACING, SHADEROPTIONS_RAYTRACING, and RAYTRACING_ENABLED have been removed. A new multicompile is introduce for forward pass: SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON. This allow to enable raytracing effect without requiring edition of shader config file. +From Unity 2020.2,SHADERPASS for TransparentDepthPrepass and TransparentDepthPostpass identification is using respectively SHADERPASS_TRANSPARENT_DEPTH_PREPASS and SHADERPASS_TRANSPARENT_DEPTH_POSTPASS. Previously it was SHADERPASS_DEPTH_ONLY. Define CUTOFF_TRANSPARENT_DEPTH_PREPASS and CUTOFF_TRANSPARENT_DEPTH_POSTPASS and been removed as the new path macro can now be used. + ## Custom pass API The signature of the Execute function has changed to simplify the parameters, now it only takes a CustomPassContext as its input: diff --git a/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/MaterialPostProcessor.cs b/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/MaterialPostProcessor.cs index 1af4d13b30b..8972fc47c26 100644 --- a/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/MaterialPostProcessor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/MaterialPostProcessor.cs @@ -193,6 +193,7 @@ static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAsse ZWriteForTransparent, RenderQueueUpgrade, ShaderGraphStack, + MoreMaterialSurfaceOptionFromShaderGraph, }; #region Migrations @@ -393,6 +394,32 @@ static void ShaderGraphStack(Material material, HDShaderUtils.ShaderID id) HDShaderUtils.ResetMaterialKeywords(material); } + static void MoreMaterialSurfaceOptionFromShaderGraph(Material material, HDShaderUtils.ShaderID id) + { + if (material.shader.IsShaderGraph()) + { + // Synchronize properties we exposed from SG to the material + ResetFloatProperty(kReceivesSSR); + ResetFloatProperty(kReceivesSSRTransparent); + ResetFloatProperty(kEnableDecals); + ResetFloatProperty(kEnableBlendModePreserveSpecularLighting); + ResetFloatProperty(kTransparentWritingMotionVec); + ResetFloatProperty(kAddPrecomputedVelocity); + ResetFloatProperty(kDepthOffsetEnable); + } + + void ResetFloatProperty(string propName) + { + int propIndex = material.shader.FindPropertyIndex(propName); + if (propIndex == -1) + return; + float defaultValue = material.shader.GetPropertyDefaultFloatValue(propIndex); + material.SetFloat(propName, defaultValue); + } + + HDShaderUtils.ResetMaterialKeywords(material); + } + #region Serialization_API //Methods in this region interact on the serialized material //without filtering on what used shader knows diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeGUI.cs deleted file mode 100644 index 083a42d386d..00000000000 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeGUI.cs +++ /dev/null @@ -1,53 +0,0 @@ -using UnityEngine; -using UnityEngine.Rendering; - -// Include material common properties names -using static UnityEngine.Rendering.HighDefinition.HDMaterialProperties; - -namespace UnityEditor.Rendering.HighDefinition -{ - /// - /// GUI for HDRP Eye shader graphs - /// - class EyeGUI : HDShaderGUI - { - // For surface option shader graph we only want all unlit features but alpha clip, back then front rendering and SSR - const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit - ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold - ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass; - - MaterialUIBlockList uiBlocks = new MaterialUIBlockList - { - new SurfaceOptionUIBlock(MaterialUIBlock.Expandable.Base, features: surfaceOptionFeatures), - new ShaderGraphUIBlock(MaterialUIBlock.Expandable.ShaderGraph), - }; - - protected override void OnMaterialGUI(MaterialEditor materialEditor, MaterialProperty[] props) - { - using (var changed = new EditorGUI.ChangeCheckScope()) - { - uiBlocks.OnGUI(materialEditor, props); - ApplyKeywordsAndPassesIfNeeded(changed.changed, uiBlocks.materials); - } - } - - public static void SetupMaterialKeywordsAndPass(Material material) - { - SynchronizeShaderGraphProperties(material); - - BaseLitGUI.SetupBaseLitKeywords(material); - BaseLitGUI.SetupBaseLitMaterialPass(material); - - bool receiveSSR = material.HasProperty(kReceivesSSR) ? material.GetInt(kReceivesSSR) != 0 : false; - bool useSplitLighting = material.HasProperty(kUseSplitLighting) ? material.GetInt(kUseSplitLighting) != 0: false; - BaseLitGUI.SetupStencil(material, receiveSSR, useSplitLighting); - if (material.HasProperty(kAddPrecomputedVelocity)) - { - CoreUtils.SetKeyword(material, "_ADD_PRECOMPUTED_VELOCITY", material.GetInt(kAddPrecomputedVelocity) != 0); - } - - } - - protected override void SetupMaterialKeywordsAndPassInternal(Material material) => SetupMaterialKeywordsAndPass(material); - } -} diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeGUI.cs.meta b/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeGUI.cs.meta deleted file mode 100644 index 84abf7fc806..00000000000 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeGUI.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1664b7f0f74e9984aa08311658a6f3da -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeSubTarget.Migration.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeSubTarget.Migration.cs index d39bfdd48e8..581652235c7 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeSubTarget.Migration.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeSubTarget.Migration.cs @@ -27,8 +27,8 @@ public bool TryUpgradeFromMasterNode(IMasterNode1 masterNode, out Dictionary passTemplateMaterialDirectories; - protected override string customInspector => "Rendering.HighDefinition.EyeGUI"; + protected override string customInspector => "Rendering.HighDefinition.LightingShaderGraphGUI"; protected override string subTargetAssetGuid => "864e4e09d6293cf4d98457f740bb3301"; protected override ShaderID shaderID => HDShaderUtils.ShaderID.SG_Eye; protected override string subShaderInclude => "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Eye/Eye.hlsl"; diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricGUI.cs deleted file mode 100644 index 5f6a6d7df02..00000000000 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricGUI.cs +++ /dev/null @@ -1,53 +0,0 @@ -using UnityEngine; -using UnityEngine.Rendering; - -// Include material common properties names -using static UnityEngine.Rendering.HighDefinition.HDMaterialProperties; - -namespace UnityEditor.Rendering.HighDefinition -{ - /// - /// GUI for HDRP Fabric shader graphs - /// - class FabricGUI : HDShaderGUI - { - // For surface option shader graph we only want all unlit features but alpha clip, back then front rendering and SSR - const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit - ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold - ^ SurfaceOptionUIBlock.Features.BackThenFrontRendering - ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass; - - MaterialUIBlockList uiBlocks = new MaterialUIBlockList - { - new SurfaceOptionUIBlock(MaterialUIBlock.Expandable.Base, features: surfaceOptionFeatures), - new ShaderGraphUIBlock(MaterialUIBlock.Expandable.ShaderGraph), - }; - - protected override void OnMaterialGUI(MaterialEditor materialEditor, MaterialProperty[] props) - { - using (var changed = new EditorGUI.ChangeCheckScope()) - { - uiBlocks.OnGUI(materialEditor, props); - ApplyKeywordsAndPassesIfNeeded(changed.changed, uiBlocks.materials); - } - } - - public static void SetupMaterialKeywordsAndPass(Material material) - { - SynchronizeShaderGraphProperties(material); - - BaseLitGUI.SetupBaseLitKeywords(material); - BaseLitGUI.SetupBaseLitMaterialPass(material); - bool receiveSSR = material.GetSurfaceType() == SurfaceType.Opaque ? (material.HasProperty(kReceivesSSR) ? material.GetInt(kReceivesSSR) != 0 : false) - : (material.HasProperty(kReceivesSSRTransparent) ? material.GetInt(kReceivesSSRTransparent) != 0 : false); - bool useSplitLighting = material.HasProperty(kUseSplitLighting) ? material.GetInt(kUseSplitLighting) != 0: false; - BaseLitGUI.SetupStencil(material, receiveSSR, useSplitLighting); - if (material.HasProperty(kAddPrecomputedVelocity)) - { - CoreUtils.SetKeyword(material, "_ADD_PRECOMPUTED_VELOCITY", material.GetInt(kAddPrecomputedVelocity) != 0); - } - } - - protected override void SetupMaterialKeywordsAndPassInternal(Material material) => SetupMaterialKeywordsAndPass(material); - } -} diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricGUI.cs.meta b/com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricGUI.cs.meta deleted file mode 100644 index eb951f6bc7c..00000000000 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricGUI.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 771870527d8c38a4692f6a237d0b183e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricSubTarget.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricSubTarget.cs index a0d9edec048..c477cc86ef2 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricSubTarget.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricSubTarget.cs @@ -26,7 +26,7 @@ sealed partial class FabricSubTarget : LightingSubTarget, ILegacyTarget, IRequir protected override string[] templateMaterialDirectories => passTemplateMaterialDirectories; protected override string subTargetAssetGuid => "74f1a4749bab90d429ac01d094be0aeb"; // FabricSubTarget.cs - protected override string customInspector => "Rendering.HighDefinition.FabricGUI"; + protected override string customInspector => "Rendering.HighDefinition.LightingShaderGraphGUI"; protected override ShaderID shaderID => HDShaderUtils.ShaderID.SG_Fabric; protected override string subShaderInclude => "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Fabric/Fabric.hlsl"; protected override string raytracingInclude => CoreIncludes.kFabricRaytracing; diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairGUI.cs deleted file mode 100644 index 5aae48b1a33..00000000000 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairGUI.cs +++ /dev/null @@ -1,54 +0,0 @@ -using UnityEngine; -using UnityEngine.Rendering; - -// Include material common properties names -using static UnityEngine.Rendering.HighDefinition.HDMaterialProperties; - -namespace UnityEditor.Rendering.HighDefinition -{ - /// - /// GUI for HDRP Hair shader graphs - /// - class HairGUI : HDShaderGUI - { - // For surface option shader graph we only want all unlit features but alpha clip and back then front rendering - const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit - ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold - ^ SurfaceOptionUIBlock.Features.BackThenFrontRendering - ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass; - - MaterialUIBlockList uiBlocks = new MaterialUIBlockList - { - new SurfaceOptionUIBlock(MaterialUIBlock.Expandable.Base, features: surfaceOptionFeatures), - new ShaderGraphUIBlock(MaterialUIBlock.Expandable.ShaderGraph), - }; - - protected override void OnMaterialGUI(MaterialEditor materialEditor, MaterialProperty[] props) - { - using (var changed = new EditorGUI.ChangeCheckScope()) - { - uiBlocks.OnGUI(materialEditor, props); - ApplyKeywordsAndPassesIfNeeded(changed.changed, uiBlocks.materials); - } - } - - public static void SetupMaterialKeywordsAndPass(Material material) - { - SynchronizeShaderGraphProperties(material); - - BaseLitGUI.SetupBaseLitKeywords(material); - BaseLitGUI.SetupBaseLitMaterialPass(material); - bool receiveSSR = material.GetSurfaceType() == SurfaceType.Opaque ? (material.HasProperty(kReceivesSSR) ? material.GetInt(kReceivesSSR) != 0 : false) - : (material.HasProperty(kReceivesSSRTransparent) ? material.GetInt(kReceivesSSRTransparent) != 0 : false); - bool useSplitLighting = material.HasProperty(kUseSplitLighting) ? material.GetInt(kUseSplitLighting) != 0: false; - BaseLitGUI.SetupStencil(material, receiveSSR, useSplitLighting); - if (material.HasProperty(kAddPrecomputedVelocity)) - { - CoreUtils.SetKeyword(material, "_ADD_PRECOMPUTED_VELOCITY", material.GetInt(kAddPrecomputedVelocity) != 0); - } - - } - - protected override void SetupMaterialKeywordsAndPassInternal(Material material) => SetupMaterialKeywordsAndPass(material); - } -} diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairSubTarget.Migration.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairSubTarget.Migration.cs index 3e07eedddf4..b1df17231d4 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairSubTarget.Migration.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairSubTarget.Migration.cs @@ -27,8 +27,8 @@ public bool TryUpgradeFromMasterNode(IMasterNode1 masterNode, out Dictionary passTemplateMaterialDirectories; - protected override string customInspector => "Rendering.HighDefinition.HairGUI"; + protected override string customInspector => "Rendering.HighDefinition.LightingShaderGraphGUI"; protected override string subTargetAssetGuid => "7e681cc79dd8e6c46ba1e8412d519e26"; // HairSubTarget.cs protected override ShaderID shaderID => HDShaderUtils.ShaderID.SG_Hair; protected override string subShaderInclude => CoreIncludes.kHair; diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/LayeredLit/LayeredLitGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/LayeredLit/LayeredLitGUI.cs index ebfafab095c..dd31c5a05ca 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/LayeredLit/LayeredLitGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/LayeredLit/LayeredLitGUI.cs @@ -26,7 +26,7 @@ class LayeredLitGUI : HDShaderGUI MaterialUIBlockList uiBlocks = new MaterialUIBlockList { - new SurfaceOptionUIBlock(MaterialUIBlock.Expandable.Base, 4, SurfaceOptionUIBlock.Features.All ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass), + new SurfaceOptionUIBlock(MaterialUIBlock.Expandable.Base, 4, SurfaceOptionUIBlock.Features.Lit), new TessellationOptionsUIBlock(MaterialUIBlock.Expandable.Tesselation), new LitSurfaceInputsUIBlock(MaterialUIBlock.Expandable.Input, kMaxLayerCount, features: commonLitSurfaceInputsFeatures), new LayerListUIBlock(MaterialUIBlock.Expandable.MaterialReferences), diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/BaseLitGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/BaseLitGUI.cs index b9bddb7d48c..3ace404101a 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/BaseLitGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/BaseLitGUI.cs @@ -11,7 +11,6 @@ abstract class BaseLitGUI { // Properties for Base Lit material keyword setup protected const string kDoubleSidedNormalMode = "_DoubleSidedNormalMode"; - protected const string kDepthOffsetEnable = "_DepthOffsetEnable"; protected const string kDisplacementMode = "_DisplacementMode"; protected const string kDisplacementLockObjectScale = "_DisplacementLockObjectScale"; @@ -79,6 +78,12 @@ static public void SetupBaseLitKeywords(Material material) bool depthOffsetEnable = (material.GetFloat(kDepthOffsetEnable) > 0.0f) && enablePixelDisplacement; CoreUtils.SetKeyword(material, "_DEPTHOFFSET_ON", depthOffsetEnable); } + else if (material.HasProperty(kDepthOffsetEnable)) // ShaderGraphs don't have the displacement mode but they have a depth offset + { + // Depth offset is only enabled if per pixel displacement is + bool depthOffsetEnable = (material.GetFloat(kDepthOffsetEnable) > 0.0f); + CoreUtils.SetKeyword(material, "_DEPTHOFFSET_ON", depthOffsetEnable); + } CoreUtils.SetKeyword(material, "_VERTEX_WIND", false); diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/LitGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/LitGUI.cs index 628351dbd8e..443503197ce 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/LitGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/LitGUI.cs @@ -17,7 +17,7 @@ class LitGUI : HDShaderGUI MaterialUIBlockList uiBlocks = new MaterialUIBlockList { - new SurfaceOptionUIBlock(MaterialUIBlock.Expandable.Base, features: SurfaceOptionUIBlock.Features.Lit ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass), + new SurfaceOptionUIBlock(MaterialUIBlock.Expandable.Base, features: SurfaceOptionUIBlock.Features.Lit), new TessellationOptionsUIBlock(MaterialUIBlock.Expandable.Tesselation), new LitSurfaceInputsUIBlock(MaterialUIBlock.Expandable.Input, features: litSurfaceFeatures), new DetailInputsUIBlock(MaterialUIBlock.Expandable.Detail), diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitGUI.cs.meta b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitGUI.cs.meta deleted file mode 100644 index 8202caacd28..00000000000 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitGUI.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9932957a675f26c4f80761ce43958e89 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitSubTarget.Migration.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitSubTarget.Migration.cs index f56db7589b6..5bfeca69ea1 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitSubTarget.Migration.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitSubTarget.Migration.cs @@ -109,8 +109,8 @@ void UpgradeHDLitMasterNode(HDLitMasterNode1 hdLitMasterNode, out Dictionary passTemplateMaterialDirectories; - protected override string customInspector => "Rendering.HighDefinition.HDLitGUI"; + protected override string customInspector => "Rendering.HighDefinition.LightingShaderGraphGUI"; protected override string subTargetAssetGuid => "caab952c840878340810cca27417971c"; // HDLitSubTarget.cs protected override string postDecalsInclude => "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDecalData.hlsl"; protected override ShaderID shaderID => HDShaderUtils.ShaderID.SG_Lit; diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDFields.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDFields.cs index 67d4d191ff1..8de96beb9e7 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDFields.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDFields.cs @@ -48,15 +48,8 @@ static class HDFields public static FieldDescriptor SpecularOcclusionCustom = new FieldDescriptor(string.Empty, "SpecularOcclusionCustom", "_SPECULAR_OCCLUSION_CUSTOM 1"); // Misc - public static FieldDescriptor DoAlphaTest = new FieldDescriptor(string.Empty, "DoAlphaTest", "_DO_ALPHA_TEST 1"); public static FieldDescriptor DoAlphaTestShadow = new FieldDescriptor(string.Empty, "DoAlphaTestShadow", "_DO_ALPHA_TEST_SHADOW 1"); public static FieldDescriptor DoAlphaTestPrepass = new FieldDescriptor(string.Empty, "DoAlphaTestPrepass", "_DO_ALPHA_TEST_PREPASS 1"); - public static FieldDescriptor DoAlphaTestPostpass = new FieldDescriptor(string.Empty, "DoAlphaTestPostpass", "_DO_ALPHA_TEST_POSTPASS 1"); - public static FieldDescriptor AlphaFog = new FieldDescriptor(string.Empty, "AlphaFog", "_ENABLE_FOG_ON_TRANSPARENT 1"); - public static FieldDescriptor BlendPreserveSpecular = new FieldDescriptor(Fields.kBlendMode, "PreserveSpecular", "_BLENDMODE_PRESERVE_SPECULAR_LIGHTING 1"); - public static FieldDescriptor DisableDecals = new FieldDescriptor(string.Empty, "DisableDecals", "_DISABLE_DECALS 1"); - public static FieldDescriptor DisableSSR = new FieldDescriptor(string.Empty, "DisableSSR", "_DISABLE_SSR 1"); - public static FieldDescriptor DisableSSRTransparent = new FieldDescriptor(string.Empty, "DisableSSRTransparent", "_DISABLE_SSR_TRANSPARENT 1"); public static FieldDescriptor BentNormal = new FieldDescriptor(string.Empty, "BentNormal", "_BENT_NORMAL 1"); public static FieldDescriptor AmbientOcclusion = new FieldDescriptor(string.Empty, "AmbientOcclusion", "_AMBIENT_OCCLUSION 1"); public static FieldDescriptor CoatMask = new FieldDescriptor(string.Empty, "CoatMask", "_COAT_MASK 1"); @@ -64,7 +57,6 @@ static class HDFields public static FieldDescriptor LightingGI = new FieldDescriptor(string.Empty, "LightingGI", "_LIGHTING_GI 1"); public static FieldDescriptor BackLightingGI = new FieldDescriptor(string.Empty, "BackLightingGI", "_BACK_LIGHTING_GI 1"); public static FieldDescriptor DepthOffset = new FieldDescriptor(string.Empty, "DepthOffset", "_DEPTH_OFFSET 1"); - public static FieldDescriptor TransparentWritesMotionVec = new FieldDescriptor(string.Empty, "TransparentWritesMotionVec", "_WRITE_TRANSPARENT_MOTION_VECTOR 1"); public static FieldDescriptor TransparentBackFace = new FieldDescriptor(string.Empty, "TransparentBackFace", string.Empty); public static FieldDescriptor TransparentDepthPrePass = new FieldDescriptor(string.Empty, "TransparentDepthPrePass", string.Empty); public static FieldDescriptor TransparentDepthPostPass = new FieldDescriptor(string.Empty, "TransparentDepthPostPass", string.Empty); diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDShaderPasses.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDShaderPasses.cs index 8cd14696c30..22f002e479f 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDShaderPasses.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDShaderPasses.cs @@ -229,13 +229,31 @@ public static PassDescriptor GenerateDepthForwardOnlyPass(bool supportLighting) // Collections requiredFields = GenerateRequiredFields(), - renderStates = CoreRenderStates.DepthOnly, + renderStates = GenerateRenderState(), pragmas = CorePragmas.DotsInstancedInV2Only, defines = supportLighting ? CoreDefines.DepthMotionVectors : null, keywords = CoreKeywords.DepthMotionVectorsNoNormal, includes = GenerateIncludes(), }; + RenderStateCollection GenerateRenderState() + { + var renderState = CoreRenderStates.DepthOnly; + + if (!supportLighting) + { + // Caution: When using MSAA we have normal and depth buffer bind. + // Unlit objects need to NOT write in normal buffer (or write 0) - Disable color mask for this RT + // Note: ShaderLab doesn't allow to have a variable on the second parameter of ColorMask + // - When MSAA: disable target 1 (normal buffer) + // - When no MSAA: disable target 0 (normal buffer) and 1 (unused) + renderState.Add(RenderState.ColorMask("ColorMask [_ColorMaskNormal]")); + renderState.Add(RenderState.ColorMask("ColorMask 0 1")); + } + + return renderState; + } + FieldCollection GenerateRequiredFields() { return new FieldCollection() @@ -321,6 +339,11 @@ RenderStateCollection GenerateRenderState() if (!supportLighting) { + // Caution: When using MSAA we have motion vector, normal and depth buffer bind. + // Unlit objects need to NOT write in normal buffer (or write 0) - Disable color mask for this RT + // Note: ShaderLab doesn't allow to have a variable on the second parameter of ColorMask + // - When MSAA: disable target 2 (normal buffer) + // - When no MSAA: disable target 1 (normal buffer) and 2 (unused) renderState.Add(RenderState.ColorMask("ColorMask [_ColorMaskNormal] 1")); renderState.Add(RenderState.ColorMask("ColorMask 0 2")); } @@ -370,7 +393,7 @@ IncludeCollection GenerateIncludes() #region Forward Only - public static PassDescriptor GenereateForwardOnlyPass(bool supportLighting) + public static PassDescriptor GenerateForwardOnlyPass(bool supportLighting) { return new PassDescriptor { @@ -388,7 +411,7 @@ public static PassDescriptor GenereateForwardOnlyPass(bool supportLighting) keywords = supportLighting ? CoreKeywords.Forward : UnlitForwardKeywords, includes = GenerateIncludes(), - virtualTextureFeedback = supportLighting ? false : true, + virtualTextureFeedback = true, }; IncludeCollection GenerateIncludes() @@ -446,8 +469,8 @@ public static PassDescriptor GenerateBackThenFront(bool supportLighting) requiredFields = CoreRequiredFields.LitMinimal, renderStates = CoreRenderStates.TransparentBackface, pragmas = CorePragmas.DotsInstancedInV1AndV2, - defines = CoreDefines.Forward, - keywords = CoreKeywords.Forward, + defines = CoreDefines.BackThenFront, + keywords = supportLighting ? CoreKeywords.BackThenFrontTransparent : UnlitForwardKeywords, includes = GenerateIncludes(), }; @@ -491,38 +514,50 @@ public static PassDescriptor GenerateTransparentDepthPrepass(bool supportLightin { // Definition displayName = "TransparentDepthPrepass", - referenceName = "SHADERPASS_DEPTH_ONLY", + referenceName = "SHADERPASS_TRANSPARENT_DEPTH_PREPASS", lightMode = "TransparentDepthPrepass", useInPreview = true, - validPixelBlocks = new BlockFieldDescriptor[] - { - BlockFields.SurfaceDescription.Alpha, - HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPrepass, - HDBlockFields.SurfaceDescription.DepthOffset, - BlockFields.SurfaceDescription.NormalTS, - BlockFields.SurfaceDescription.NormalWS, - BlockFields.SurfaceDescription.NormalOS, - BlockFields.SurfaceDescription.Smoothness, - }, + validPixelBlocks = supportLighting ? + new BlockFieldDescriptor[] + { + BlockFields.SurfaceDescription.Alpha, + HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPrepass, + BlockFields.SurfaceDescription.AlphaClipThreshold, + HDBlockFields.SurfaceDescription.DepthOffset, + BlockFields.SurfaceDescription.NormalTS, + BlockFields.SurfaceDescription.NormalWS, + BlockFields.SurfaceDescription.NormalOS, + BlockFields.SurfaceDescription.Smoothness, + } : + new BlockFieldDescriptor[] + { + BlockFields.SurfaceDescription.Alpha, + HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPrepass, + BlockFields.SurfaceDescription.AlphaClipThreshold, + HDBlockFields.SurfaceDescription.DepthOffset, + }, // Collections requiredFields = TransparentDepthPrepassFields, renderStates = GenerateRenderState(), pragmas = CorePragmas.DotsInstancedInV1AndV2, - defines = GenerateDefines(), - keywords = CoreKeywords.HDBase, + defines = CoreDefines.TransparentDepthPrepass, + keywords = GenerateKeywords(), includes = GenerateIncludes(), }; - DefineCollection GenerateDefines() + KeywordCollection GenerateKeywords() { - var defines = new DefineCollection{ { RayTracingNode.GetRayTracingKeyword(), 0 } }; + KeywordCollection keywords = new KeywordCollection { CoreKeywords.HDBase }; - if (supportLighting) - defines.Add(CoreKeywordDescriptors.WriteNormalBufferDefine, 1, new FieldCondition(HDFields.DisableSSRTransparent, false)); + // For now we can generate WriteNormalBuffer the way we want with SG generator + // as it require a conditional define. So instead it is hard coded in + // ShaderPass.template. Looks for SHADERPASS_TRANSPARENT_DEPTH_PREPASS in the file + //if (supportLighting) + // keywords.Add(CoreKeywordDescriptors.WriteNormalBuffer); - return defines; + return keywords; } RenderStateCollection GenerateRenderState() @@ -543,6 +578,11 @@ RenderStateCollection GenerateRenderState() if (!supportLighting) { + // Caution: When using MSAA we have normal and depth buffer bind. + // Unlit objects need to NOT write in normal buffer (or write 0) - Disable color mask for this RT + // Note: ShaderLab doesn't allow to have a variable on the second parameter of ColorMask + // - When MSAA: disable target 1 (normal buffer) + // - When no MSAA: disable target 0 (normal buffer) and 1 (unused) renderState.Add(RenderState.ColorMask("ColorMask [_ColorMaskNormal]")); renderState.Add(RenderState.ColorMask("ColorMask 0 1")); } @@ -598,7 +638,7 @@ public static PassDescriptor GenerateTransparentDepthPostpass(bool supportLighti { // Definition displayName = "TransparentDepthPostpass", - referenceName = "SHADERPASS_DEPTH_ONLY", + referenceName = "SHADERPASS_TRANSPARENT_DEPTH_POSTPASS", lightMode = "TransparentDepthPostpass", useInPreview = true, @@ -607,12 +647,13 @@ public static PassDescriptor GenerateTransparentDepthPostpass(bool supportLighti BlockFields.SurfaceDescription.Alpha, HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPostpass, HDBlockFields.SurfaceDescription.DepthOffset, + BlockFields.SurfaceDescription.AlphaClipThreshold, }, // Collections renderStates = GenerateRenderState(), pragmas = CorePragmas.DotsInstancedInV1AndV2, - defines = CoreDefines.ShaderGraphRaytracingHigh, + defines = CoreDefines.TransparentDepthPostpass, keywords = CoreKeywords.HDBase, includes = GenerateIncludes(), }; @@ -771,7 +812,7 @@ public static PassDescriptor GenerateLitForward() // Collections requiredFields = CoreRequiredFields.LitMinimal, - renderStates = CoreRenderStates.ForwardColorMask, + renderStates = CoreRenderStates.Forward, pragmas = CorePragmas.DotsInstancedInV1AndV2, defines = CoreDefines.Forward, keywords = CoreKeywords.Forward, @@ -864,7 +905,7 @@ public static PassDescriptor GenerateRaytracingIndirect(bool supportLighting) // Collections pragmas = CorePragmas.RaytracingBasic, defines = supportLighting ? RaytracingIndirectDefines : null, - keywords = CoreKeywords.RaytracingIndirect, + keywords = supportLighting ? CoreKeywords.RaytracingIndirect : CoreKeywords.RaytracingIndirectUnlit, includes = GenerateIncludes(), }; @@ -980,7 +1021,7 @@ public static PassDescriptor GenerateRaytracingForward(bool supportLighting) // Collections pragmas = CorePragmas.RaytracingBasic, defines = supportLighting ? RaytracingForwardDefines : null, - keywords = CoreKeywords.RaytracingGBufferForward, + keywords = supportLighting ? CoreKeywords.RaytracingForward : CoreKeywords.RaytracingForwardUnlit, includes = GenerateIncludes(), }; @@ -1047,7 +1088,7 @@ public static PassDescriptor GenerateRaytracingGBuffer(bool supportLighting) // Collections pragmas = CorePragmas.RaytracingBasic, defines = supportLighting ? RaytracingGBufferDefines : null, - keywords = CoreKeywords.RaytracingGBufferForward, + keywords = supportLighting ? CoreKeywords.RaytracingGBuffer : CoreKeywords.RaytracingGBufferUnlit, includes = GenerateIncludes(), }; @@ -1174,7 +1215,7 @@ public static PassDescriptor GenerateRaytracingSubsurface() //Collections pragmas = CorePragmas.RaytracingBasic, defines = RaytracingSubsurfaceDefines, - keywords = CoreKeywords.RaytracingGBufferForward, + keywords = CoreKeywords.RaytracingForward, includes = GenerateIncludes(), }; diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubShaderUtilities.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubShaderUtilities.cs index 8f6a4e3685e..a25ed447e89 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubShaderUtilities.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubShaderUtilities.cs @@ -70,16 +70,24 @@ static void AddToggleProperty(this PropertyCollector collector, string reference public static void AddStencilShaderProperties(PropertyCollector collector, SystemData systemData, LightingData lightingData, bool splitLighting) { bool ssrStencil = false; - bool receiveSSROpaque = false; - bool receiveSSRTransparent = false; if (lightingData != null) { ssrStencil = systemData.surfaceType == SurfaceType.Opaque ? lightingData.receiveSSR : lightingData.receiveSSRTransparent; - receiveSSROpaque = lightingData.receiveSSR; - receiveSSRTransparent = lightingData.receiveSSRTransparent; + bool receiveSSROpaque = lightingData.receiveSSR; + bool receiveSSRTransparent = lightingData.receiveSSRTransparent; + bool receiveDecals = lightingData.receiveDecals; + bool blendPreserveSpecular = lightingData.blendPreserveSpecular; + + // Don't add those property on Unlit + collector.AddToggleProperty(kUseSplitLighting, splitLighting); + collector.AddToggleProperty(kReceivesSSR, receiveSSROpaque); + collector.AddToggleProperty(kReceivesSSRTransparent, receiveSSRTransparent); + collector.AddToggleProperty(kEnableBlendModePreserveSpecularLighting, blendPreserveSpecular); + collector.AddToggleProperty(kSupportDecals, receiveDecals); } + // Configure render state BaseLitGUI.ComputeStencilProperties(ssrStencil, splitLighting, out int stencilRef, out int stencilWriteMask, out int stencilRefDepth, out int stencilWriteMaskDepth, out int stencilRefGBuffer, out int stencilWriteMaskGBuffer, out int stencilRefMV, out int stencilWriteMaskMV @@ -101,10 +109,6 @@ public static void AddStencilShaderProperties(PropertyCollector collector, Syste collector.AddIntProperty("_StencilWriteMaskGBuffer", stencilWriteMaskGBuffer); collector.AddIntProperty("_StencilRefGBuffer", stencilRefGBuffer); collector.AddIntProperty("_ZTestGBuffer", 4); - - collector.AddToggleProperty(kUseSplitLighting, splitLighting); - collector.AddToggleProperty(kReceivesSSR, receiveSSROpaque); - collector.AddToggleProperty(kReceivesSSRTransparent, receiveSSRTransparent); } public static void AddBlendingStatesShaderProperties( diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubTarget.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubTarget.cs index 89fefaf868f..bb801f40233 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubTarget.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubTarget.cs @@ -79,10 +79,6 @@ public override void Setup(ref TargetSetupContext context) public override void GetFields(ref TargetFieldContext context) { // Common properties between all HD master nodes - // Surface Type - context.AddField(Fields.SurfaceOpaque, systemData.surfaceType == SurfaceType.Opaque); - context.AddField(Fields.SurfaceTransparent, systemData.surfaceType != SurfaceType.Opaque); - // Dots context.AddField(HDFields.DotsInstancing, systemData.dotsInstancing); } diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDTarget.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDTarget.cs index 09a26988a3e..9c27346f065 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDTarget.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDTarget.cs @@ -485,8 +485,6 @@ static class CoreFieldDependencies new FieldDependency(StructFields.SurfaceDescriptionInputs.uv3, HDStructFields.FragInputs.texCoord3), new FieldDependency(StructFields.SurfaceDescriptionInputs.VertexColor, HDStructFields.FragInputs.color), new FieldDependency(StructFields.SurfaceDescriptionInputs.FaceSign, HDStructFields.FragInputs.IsFrontFace), - - new FieldDependency(HDFields.DepthOffset, HDStructFields.FragInputs.positionRWS), }; public static DependencyCollection Default = new DependencyCollection @@ -666,42 +664,7 @@ public static class Uniforms { RenderState.Blend(Uniforms.srcBlend, Uniforms.dstBlend, Uniforms.alphaSrcBlend, Uniforms.alphaDstBlend) }, { RenderState.Cull(Uniforms.cullModeForward) }, { RenderState.ZWrite(Uniforms.zWrite) }, - { RenderState.ZTest(Uniforms.zTestDepthEqualForOpaque), new FieldCondition[] { - new FieldCondition(Fields.SurfaceOpaque, true), - new FieldCondition(Fields.AlphaTest, false) - } }, - { RenderState.ZTest(Uniforms.zTestDepthEqualForOpaque), new FieldCondition[] { - new FieldCondition(Fields.SurfaceOpaque, false), - } }, - { RenderState.ZTest(ZTest.Equal), new FieldCondition[] { - new FieldCondition(Fields.SurfaceOpaque, true), - new FieldCondition(Fields.AlphaTest, true) - } }, - { RenderState.Stencil(new StencilDescriptor() - { - WriteMask = Uniforms.stencilWriteMask, - Ref = Uniforms.stencilRef, - Comp = "Always", - Pass = "Replace", - }) }, - }; - - public static RenderStateCollection ForwardColorMask = new RenderStateCollection - { - { RenderState.Blend(Uniforms.srcBlend, Uniforms.dstBlend, Uniforms.alphaSrcBlend, Uniforms.alphaDstBlend) }, - { RenderState.Cull(Uniforms.cullModeForward) }, - { RenderState.ZWrite(Uniforms.zWrite) }, - { RenderState.ZTest(Uniforms.zTestDepthEqualForOpaque), new FieldCondition[] { - new FieldCondition(Fields.SurfaceOpaque, true), - new FieldCondition(Fields.AlphaTest, false) - } }, - { RenderState.ZTest(Uniforms.zTestDepthEqualForOpaque), new FieldCondition[] { - new FieldCondition(Fields.SurfaceOpaque, false), - } }, - { RenderState.ZTest(ZTest.Equal), new FieldCondition[] { - new FieldCondition(Fields.SurfaceOpaque, true), - new FieldCondition(Fields.AlphaTest, true) - } }, + { RenderState.ZTest(Uniforms.zTestDepthEqualForOpaque) }, { RenderState.ColorMask("ColorMask [_ColorMaskTransparentVel] 1") }, { RenderState.Stencil(new StencilDescriptor() { @@ -820,23 +783,27 @@ static class CorePragmas #region Keywords static class CoreKeywords { - public static KeywordCollection HDBase = new KeywordCollection + public static KeywordCollection HDBaseNoCrossFade = new KeywordCollection { - { CoreKeywordDescriptors.LodFadeCrossfade, new FieldCondition(Fields.LodCrossFade, true) }, { CoreKeywordDescriptors.SurfaceTypeTransparent }, { CoreKeywordDescriptors.BlendMode }, { CoreKeywordDescriptors.DoubleSided, new FieldCondition(HDFields.Unlit, false) }, + { CoreKeywordDescriptors.DisableDecals, new FieldCondition(HDFields.Unlit, false) }, + { CoreKeywordDescriptors.DisableSSR, new FieldCondition(HDFields.Unlit, false) }, + { CoreKeywordDescriptors.DisableSSRTransparent, new FieldCondition(HDFields.Unlit, false) }, + // { CoreKeywordDescriptors.EnableGeometricSpecularAA, new FieldCondition(HDFields.Unlit, false) }, + { CoreKeywordDescriptors.BlendModePreserveSpecularLighting, new FieldCondition(HDFields.Unlit, false) }, + { CoreKeywordDescriptors.AddPrecomputedVelocity }, + { CoreKeywordDescriptors.TransparentWritesMotionVector }, + { CoreKeywordDescriptors.DepthOffset, new FieldCondition(HDFields.DepthOffset, true) }, { CoreKeywordDescriptors.FogOnTransparent }, { CoreKeywordDescriptors.AlphaTest, new FieldCondition(Fields.AlphaTest, true) }, }; - public static KeywordCollection HDBaseNoCrossFade = new KeywordCollection + public static KeywordCollection HDBase = new KeywordCollection { - { CoreKeywordDescriptors.SurfaceTypeTransparent }, - { CoreKeywordDescriptors.BlendMode }, - { CoreKeywordDescriptors.DoubleSided, new FieldCondition(HDFields.Unlit, false) }, - { CoreKeywordDescriptors.FogOnTransparent }, - { CoreKeywordDescriptors.AlphaTest, new FieldCondition(Fields.AlphaTest, true) }, + { CoreKeywordDescriptors.LodFadeCrossfade, new FieldCondition(Fields.LodCrossFade, true) }, + { HDBaseNoCrossFade } }; public static KeywordCollection Lightmaps = new KeywordCollection @@ -846,6 +813,12 @@ static class CoreKeywords { CoreKeywordDescriptors.DynamicLightmap }, }; + public static KeywordCollection LightmapsRaytracing = new KeywordCollection + { + { CoreKeywordDescriptors.Lightmap }, + { CoreKeywordDescriptors.DirectionalLightmapCombined }, + }; + public static KeywordCollection WriteMsaaDepth = new KeywordCollection { { CoreKeywordDescriptors.WriteMsaaDepth }, @@ -863,7 +836,7 @@ static class CoreKeywords { CoreKeywordDescriptors.AlphaToMask, new FieldCondition(Fields.AlphaToMask, true) }, }; - public static KeywordCollection Forward = new KeywordCollection + public static KeywordCollection ForwardBase = new KeywordCollection { { HDBase }, { CoreKeywordDescriptors.DebugDisplay }, @@ -872,19 +845,57 @@ static class CoreKeywords { CoreKeywordDescriptors.Shadow }, { CoreKeywordDescriptors.ScreenSpaceShadow }, { CoreKeywordDescriptors.Decals }, - { CoreKeywordDescriptors.LightList, new FieldCondition(Fields.SurfaceOpaque, true) }, + }; + + public static KeywordCollection Forward = new KeywordCollection + { + { ForwardBase }, + { CoreKeywordDescriptors.LightList }, + }; + + public static KeywordCollection BackThenFrontTransparent = new KeywordCollection + { + { ForwardBase }, }; public static KeywordCollection RaytracingIndirect = new KeywordCollection { { HDBaseNoCrossFade }, - { Lightmaps }, + { CoreKeywordDescriptors.DebugDisplay }, + { LightmapsRaytracing }, }; - public static KeywordCollection RaytracingGBufferForward = new KeywordCollection + public static KeywordCollection RaytracingIndirectUnlit = new KeywordCollection { { HDBaseNoCrossFade }, - { Lightmaps }, + { CoreKeywordDescriptors.DebugDisplay }, + }; + + public static KeywordCollection RaytracingForward = new KeywordCollection + { + { HDBaseNoCrossFade }, + { CoreKeywordDescriptors.DebugDisplay }, + { LightmapsRaytracing }, + }; + + public static KeywordCollection RaytracingForwardUnlit = new KeywordCollection + { + { HDBaseNoCrossFade }, + { CoreKeywordDescriptors.DebugDisplay }, + }; + + public static KeywordCollection RaytracingGBuffer = new KeywordCollection + { + { HDBaseNoCrossFade }, + { CoreKeywordDescriptors.DebugDisplay }, + { LightmapsRaytracing }, + { CoreKeywordDescriptors.RaytraceMinimalGBuffer }, + }; + + public static KeywordCollection RaytracingGBufferUnlit = new KeywordCollection + { + { HDBaseNoCrossFade }, + { CoreKeywordDescriptors.DebugDisplay }, }; public static KeywordCollection RaytracingVisiblity = new KeywordCollection @@ -918,14 +929,24 @@ static class CoreDefines public static DefineCollection TransparentDepthPrepass = new DefineCollection { { RayTracingNode.GetRayTracingKeyword(), 0 }, - { CoreKeywordDescriptors.WriteNormalBufferDefine, 1, new FieldCondition(HDFields.DisableSSRTransparent, false) }, + }; + + public static DefineCollection TransparentDepthPostpass = new DefineCollection + { + { RayTracingNode.GetRayTracingKeyword(), 0 }, }; public static DefineCollection Forward = new DefineCollection { { CoreKeywordDescriptors.HasLightloop, 1 }, - { CoreKeywordDescriptors.LightList, 1, new FieldCondition(Fields.SurfaceTransparent, true) }, - { RayTracingNode.GetRayTracingKeyword(), 0, new FieldCondition(Fields.SurfaceTransparent, true) }, + { RayTracingNode.GetRayTracingKeyword(), 0 }, + }; + + public static DefineCollection BackThenFront = new DefineCollection + { + { CoreKeywordDescriptors.HasLightloop, 1 }, + { RayTracingNode.GetRayTracingKeyword(), 0 }, + { CoreKeywordDescriptors.LightList, 1 }, // BackThenFront Transparent use #define USE_CLUSTERED_LIGHTLIST }; } #endregion @@ -1043,15 +1064,6 @@ static class CoreIncludes #region KeywordDescriptors static class CoreKeywordDescriptors { - public static KeywordDescriptor WriteNormalBufferDefine = new KeywordDescriptor() - { - displayName = "Write Normal Buffer", - referenceName = "WRITE_NORMAL_BUFFER", - type = KeywordType.Boolean, - definition = KeywordDefinition.Predefined, - scope = KeywordScope.Global, - }; - public static KeywordDescriptor WriteNormalBuffer = new KeywordDescriptor() { displayName = "Write Normal Buffer", @@ -1305,6 +1317,87 @@ static class CoreKeywordDescriptors definition = KeywordDefinition.MultiCompile, scope = KeywordScope.Global }; + + public static KeywordDescriptor RaytraceMinimalGBuffer = new KeywordDescriptor() + { + displayName = "Minimal GBuffer", + referenceName = "MINIMAL_GBUFFER", + type = KeywordType.Boolean, + definition = KeywordDefinition.MultiCompile, + scope = KeywordScope.Global + }; + + public static KeywordDescriptor DisableDecals = new KeywordDescriptor + { + displayName = "Disable Decals", + referenceName = "_DISABLE_DECALS", + type = KeywordType.Boolean, + definition = KeywordDefinition.ShaderFeature, + scope = KeywordScope.Local, + }; + + public static KeywordDescriptor DisableSSR = new KeywordDescriptor + { + displayName = "Disable SSR", + referenceName = "_DISABLE_SSR", + type = KeywordType.Boolean, + definition = KeywordDefinition.ShaderFeature, + scope = KeywordScope.Local, + }; + + public static KeywordDescriptor DisableSSRTransparent = new KeywordDescriptor + { + displayName = "Disable SSR Transparent", + referenceName = "_DISABLE_SSR_TRANSPARENT", + type = KeywordType.Boolean, + definition = KeywordDefinition.ShaderFeature, + scope = KeywordScope.Local, + }; + + public static KeywordDescriptor EnableGeometricSpecularAA = new KeywordDescriptor + { + displayName = "Enable Geometric Specular AA", + referenceName = "_ENABLE_GEOMETRIC_SPECULAR_AA", + type = KeywordType.Boolean, + definition = KeywordDefinition.ShaderFeature, + scope = KeywordScope.Local, + }; + + public static KeywordDescriptor BlendModePreserveSpecularLighting = new KeywordDescriptor + { + displayName = "BlendMode Preserve Specular Lighting", + referenceName = "_BLENDMODE_PRESERVE_SPECULAR_LIGHTING", + type = KeywordType.Boolean, + definition = KeywordDefinition.ShaderFeature, + scope = KeywordScope.Local, + }; + + public static KeywordDescriptor AddPrecomputedVelocity = new KeywordDescriptor + { + displayName = "Add Precomputed Velocity", + referenceName = "_ADD_PRECOMPUTED_VELOCITY", + type = KeywordType.Boolean, + definition = KeywordDefinition.ShaderFeature, + scope = KeywordScope.Local, + }; + + public static KeywordDescriptor TransparentWritesMotionVector = new KeywordDescriptor + { + displayName = "Transparent Writes Motion Vector", + referenceName = "_TRANSPARENT_WRITES_MOTION_VEC", + type = KeywordType.Boolean, + definition = KeywordDefinition.ShaderFeature, + scope = KeywordScope.Local, + }; + + public static KeywordDescriptor DepthOffset = new KeywordDescriptor + { + displayName = "Depth Offset", + referenceName = "_DEPTHOFFSET_ON", + type = KeywordType.Boolean, + definition = KeywordDefinition.ShaderFeature, + scope = KeywordScope.Local, + }; } #endregion } diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/LightingSubTarget.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/LightingSubTarget.cs index b94a70682a4..8212e43d042 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/LightingSubTarget.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/LightingSubTarget.cs @@ -73,10 +73,6 @@ public override void GetFields(ref TargetFieldContext context) var descs = context.blocks.Select(x => x.descriptor); // Misc - context.AddField(BlendPreserveSpecular, systemData.surfaceType != SurfaceType.Opaque && lightingData.blendPreserveSpecular); - context.AddField(DisableDecals, !lightingData.receiveDecals); - context.AddField(DisableSSR, !lightingData.receiveSSR); - context.AddField(DisableSSRTransparent, !lightingData.receiveSSRTransparent); context.AddField(SpecularAA, lightingData.specularAA && context.pass.validPixelBlocks.Contains(HDBlockFields.SurfaceDescription.SpecularAAThreshold) && context.pass.validPixelBlocks.Contains(HDBlockFields.SurfaceDescription.SpecularAAScreenSpaceVariance)); @@ -127,5 +123,14 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera // Add all shader properties required by the inspector HDSubShaderUtilities.AddStencilShaderProperties(collector, systemData, lightingData, requireSplitLighting); } + + public override void ProcessPreviewMaterial(Material material) + { + base.ProcessPreviewMaterial(material); + + material.SetFloat(kEnableBlendModePreserveSpecularLighting, lightingData.blendPreserveSpecular ? 1 : 0); + material.SetFloat(kReceivesSSR, lightingData.receiveSSR ? 1 : 0); + material.SetFloat(kReceivesSSRTransparent, lightingData.receiveSSRTransparent ? 1 : 0); + } } } diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceOptionPropertyBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceOptionPropertyBlock.cs index a71d01a705e..bde3e02903f 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceOptionPropertyBlock.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceOptionPropertyBlock.cs @@ -65,8 +65,8 @@ protected override void CreatePropertyGUI() AddProperty(transparentCullModeText, () => systemData.transparentCullMode, (newValue) => systemData.transparentCullMode = newValue); AddProperty(transparentSortPriorityText, () => systemData.sortPriority, (newValue) => systemData.sortPriority = HDRenderQueue.ClampsTransparentRangePriority(newValue)); AddProperty(transparentBackfaceEnableText, () => builtinData.backThenFrontRendering, (newValue) => builtinData.backThenFrontRendering = newValue); - AddProperty(transparentDepthPrepassEnableText, () => systemData.alphaTestDepthPrepass, (newValue) => systemData.alphaTestDepthPrepass = newValue); - AddProperty(transparentDepthPostpassEnableText, () => systemData.alphaTestDepthPostpass, (newValue) => systemData.alphaTestDepthPostpass = newValue); + AddProperty(transparentDepthPrepassEnableText, () => systemData.transparentDepthPrepass, (newValue) => systemData.transparentDepthPrepass = newValue); + AddProperty(transparentDepthPostpassEnableText, () => systemData.transparentDepthPostpass, (newValue) => systemData.transparentDepthPostpass = newValue); AddProperty(transparentWritingMotionVecText, () => builtinData.transparentWritesMotionVec, (newValue) => builtinData.transparentWritesMotionVec = newValue); if (lightingData != null) diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceSubTarget.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceSubTarget.cs index 6dfffa84e9b..fb2f8bf326e 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceSubTarget.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceSubTarget.cs @@ -79,31 +79,26 @@ PassCollection GetPasses() HDShaderPasses.GenerateSceneSelection(supportLighting), HDShaderPasses.GenerateMotionVectors(supportLighting, supportForward), { HDShaderPasses.GenerateBackThenFront(supportLighting), new FieldCondition(HDFields.TransparentBackFace, true)}, - { HDShaderPasses.GenerateTransparentDepthPostpass(supportLighting), new FieldCondition(HDFields.TransparentDepthPostPass, true) }, + { HDShaderPasses.GenerateTransparentDepthPostpass(supportLighting), new FieldCondition(HDFields.TransparentDepthPostPass, true)} }; if (supportLighting) { - passes.Add(HDShaderPasses.GenerateTransparentDepthPrepass(supportLighting), new FieldCondition[]{ - new FieldCondition(HDFields.TransparentDepthPrePass, true), - new FieldCondition(HDFields.DisableSSRTransparent, true) }); - passes.Add(HDShaderPasses.GenerateTransparentDepthPrepass(supportLighting), new FieldCondition[]{ - new FieldCondition(HDFields.TransparentDepthPrePass, true), - new FieldCondition(HDFields.DisableSSRTransparent, false) }); - passes.Add(HDShaderPasses.GenerateTransparentDepthPrepass(supportLighting), new FieldCondition[]{ - new FieldCondition(HDFields.TransparentDepthPrePass, false), - new FieldCondition(HDFields.DisableSSRTransparent, false) }); - } + // We always generate the TransparentDepthPrepass as it can be use with SSR transparent + passes.Add(HDShaderPasses.GenerateTransparentDepthPrepass(true)); + } else { - passes.Add(HDShaderPasses.GenerateTransparentDepthPrepass(supportLighting), new FieldCondition(HDFields.TransparentDepthPrePass, true)); + // We only generate the pass if requested + passes.Add(HDShaderPasses.GenerateTransparentDepthPrepass(false), new FieldCondition(HDFields.TransparentDepthPrePass, true)); } if (supportForward) { passes.Add(HDShaderPasses.GenerateDepthForwardOnlyPass(supportLighting)); - passes.Add(HDShaderPasses.GenereateForwardOnlyPass(supportLighting)); + passes.Add(HDShaderPasses.GenerateForwardOnlyPass(supportLighting)); } + if (supportDistortion) passes.Add(HDShaderPasses.GenerateDistortionPass(supportLighting), new FieldCondition(HDFields.TransparentDistortion, true)); @@ -213,12 +208,7 @@ public override void GetFields(ref TargetFieldContext context) context.AddField(HDFields.Unlit); // Common properties between all "surface" master nodes (everything except decal right now) - context.AddField(HDStructFields.FragInputs.IsFrontFace, systemData.doubleSidedMode != DoubleSidedMode.Disabled && context.pass.referenceName != "SHADERPASS_MOTION_VECTORS"); - - // Blend Mode - context.AddField(Fields.BlendAdd, systemData.surfaceType != SurfaceType.Opaque && systemData.blendMode == BlendMode.Additive); - context.AddField(Fields.BlendAlpha, systemData.surfaceType != SurfaceType.Opaque && systemData.blendMode == BlendMode.Alpha); - context.AddField(Fields.BlendPremultiply, systemData.surfaceType != SurfaceType.Opaque && systemData.blendMode == BlendMode.Premultiply); + context.AddField(HDStructFields.FragInputs.IsFrontFace, systemData.doubleSidedMode != DoubleSidedMode.Disabled && context.pass.referenceName != "SHADERPASS_MOTION_VECTORS"); // Double Sided context.AddField(HDFields.DoubleSided, systemData.doubleSidedMode != DoubleSidedMode.Disabled); @@ -234,32 +224,26 @@ public override void GetFields(ref TargetFieldContext context) // Regular alpha test is only done if artist haven't ask to use the specific alpha test shadow one bool isShadowPass = context.pass.lightMode == "ShadowCaster"; bool isTransparentDepthPrepass = context.pass.lightMode == "TransparentDepthPrepass"; - bool isTransparentDepthPostpass = context.pass.lightMode == "TransparentDepthPostpass"; - context.AddField(HDFields.DoAlphaTest, systemData.alphaTest && (context.pass.validPixelBlocks.Contains(BlockFields.SurfaceDescription.AlphaClipThreshold) && - !(isShadowPass && builtinData.alphaTestShadow && context.pass.validPixelBlocks.Contains(HDBlockFields.SurfaceDescription.AlphaClipThresholdShadow)) - )); - + // Shadow use the specific alpha test only if user have ask to override it context.AddField(HDFields.DoAlphaTestShadow, systemData.alphaTest && builtinData.alphaTestShadow && isShadowPass && context.pass.validPixelBlocks.Contains(HDBlockFields.SurfaceDescription.AlphaClipThresholdShadow)); // Pre/post pass always use the specific alpha test provided for those pass - context.AddField(HDFields.DoAlphaTestPrepass, systemData.alphaTest && systemData.alphaTestDepthPrepass && isTransparentDepthPrepass && + context.AddField(HDFields.DoAlphaTestPrepass, systemData.alphaTest && systemData.transparentDepthPrepass && isTransparentDepthPrepass && context.pass.validPixelBlocks.Contains(HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPrepass)); - context.AddField(HDFields.DoAlphaTestPostpass, systemData.alphaTest && systemData.alphaTestDepthPostpass && isTransparentDepthPostpass && - context.pass.validPixelBlocks.Contains(HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPostpass)); + // Features & Misc + context.AddField(Fields.LodCrossFade, systemData.supportLodCrossFade); + context.AddField(Fields.AlphaToMask, systemData.alphaTest); + context.AddField(HDFields.TransparentBackFace, builtinData.backThenFrontRendering); + context.AddField(HDFields.TransparentDepthPrePass, systemData.transparentDepthPrepass); + context.AddField(HDFields.TransparentDepthPostPass, systemData.transparentDepthPostpass); - context.AddField(HDFields.TransparentDepthPrePass, systemData.surfaceType != SurfaceType.Opaque && systemData.alphaTestDepthPrepass); - context.AddField(HDFields.TransparentDepthPostPass, systemData.surfaceType != SurfaceType.Opaque && systemData.alphaTestDepthPostpass); + context.AddField(HDFields.DepthOffset, builtinData.depthOffset && context.pass.validPixelBlocks.Contains(HDBlockFields.SurfaceDescription.DepthOffset)); - // Features & Misc - context.AddField(Fields.LodCrossFade, systemData.supportLodCrossFade); - context.AddField(Fields.VelocityPrecomputed, builtinData.addPrecomputedVelocity); - context.AddField(HDFields.TransparentWritesMotionVec, systemData.surfaceType != SurfaceType.Opaque && builtinData.transparentWritesMotionVec); - context.AddField(Fields.AlphaToMask, systemData.alphaTest && context.pass.validPixelBlocks.Contains(BlockFields.SurfaceDescription.AlphaClipThreshold) && builtinData.alphaToMask); - context.AddField(HDFields.DepthOffset, builtinData.depthOffset && context.pass.validPixelBlocks.Contains(HDBlockFields.SurfaceDescription.DepthOffset)); - context.AddField(HDFields.AlphaFog, systemData.surfaceType != SurfaceType.Opaque && builtinData.transparencyFog); - context.AddField(HDFields.TransparentBackFace, systemData.surfaceType != SurfaceType.Opaque && builtinData.backThenFrontRendering); + // Depth offset needs positionRWS and is now a multi_compile + if (builtinData.depthOffset) + context.AddField(HDStructFields.FragInputs.positionRWS); } protected void AddDistortionFields(ref TargetFieldContext context) @@ -290,15 +274,12 @@ public override void GetActiveBlocks(ref TargetActiveBlockContext context) context.AddBlock(BlockFields.SurfaceDescription.AlphaClipThreshold, systemData.alphaTest); // Alpha Test - context.AddBlock(HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPrepass, - systemData.surfaceType == SurfaceType.Transparent && systemData.alphaTest && systemData.alphaTestDepthPrepass); - context.AddBlock(HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPostpass, - systemData.surfaceType == SurfaceType.Transparent && systemData.alphaTest && systemData.alphaTestDepthPostpass); - context.AddBlock(HDBlockFields.SurfaceDescription.AlphaClipThresholdShadow, - systemData.alphaTest && builtinData.alphaTestShadow); + context.AddBlock(HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPrepass, systemData.alphaTest && systemData.transparentDepthPrepass); + context.AddBlock(HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPostpass, systemData.alphaTest && systemData.transparentDepthPostpass); + context.AddBlock(HDBlockFields.SurfaceDescription.AlphaClipThresholdShadow, systemData.alphaTest && builtinData.alphaTestShadow); // Misc - context.AddBlock(HDBlockFields.SurfaceDescription.DepthOffset, builtinData.depthOffset); + context.AddBlock(HDBlockFields.SurfaceDescription.DepthOffset, builtinData.depthOffset); } protected void AddDistortionBlocks(ref TargetActiveBlockContext context) @@ -336,20 +317,31 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera }); //See SG-ADDITIONALVELOCITY-NOTE - if (builtinData.addPrecomputedVelocity) + collector.AddShaderProperty(new BooleanShaderProperty { - collector.AddShaderProperty(new BooleanShaderProperty - { - value = true, - hidden = true, - overrideReferenceName = kAddPrecomputedVelocity, - }); - } + value = builtinData.addPrecomputedVelocity, + hidden = true, + overrideReferenceName = kAddPrecomputedVelocity, + }); + + collector.AddShaderProperty(new BooleanShaderProperty + { + value = builtinData.depthOffset, + hidden = true, + overrideReferenceName = kDepthOffsetEnable + }); + + collector.AddShaderProperty(new BooleanShaderProperty + { + value = builtinData.transparentWritesMotionVec, + hidden = true, + overrideReferenceName = kTransparentWritingMotionVec + }); // Common properties for all "surface" master nodes HDSubShaderUtilities.AddAlphaCutoffShaderProperties(collector, systemData.alphaTest, builtinData.alphaTestShadow); HDSubShaderUtilities.AddDoubleSidedProperty(collector, systemData.doubleSidedMode); - HDSubShaderUtilities.AddPrePostPassProperties(collector, systemData.alphaTestDepthPrepass, systemData.alphaTestDepthPostpass); + HDSubShaderUtilities.AddPrePostPassProperties(collector, systemData.transparentDepthPrepass, systemData.transparentDepthPostpass); // Add all shader properties required by the inspector HDSubShaderUtilities.AddBlendingStatesShaderProperties( @@ -384,7 +376,7 @@ public override void ProcessPreviewMaterial(Material material) // No sorting priority for shader graph preview material.renderQueue = (int)HDRenderQueue.ChangeType(systemData.renderingPass, offset: 0, alphaTest: systemData.alphaTest); - HDLitGUI.SetupMaterialKeywordsAndPass(material); + LightingShaderGraphGUI.SetupMaterialKeywordsAndPass(material); } } } diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/TargetData/SystemData.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/TargetData/SystemData.cs index 863869e3225..2de372cc6cd 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/TargetData/SystemData.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/TargetData/SystemData.cs @@ -1,7 +1,8 @@ -using System; +using System; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; +using UnityEngine.Serialization; using RenderQueueType = UnityEngine.Rendering.HighDefinition.HDRenderQueue.RenderQueueType; @@ -89,20 +90,20 @@ public bool alphaTest set => m_AlphaTest = value; } - [SerializeField] - bool m_AlphaTestDepthPrepass; - public bool alphaTestDepthPrepass + [SerializeField, FormerlySerializedAs("m_AlphaTestDepthPrepass")] + bool m_TransparentDepthPrepass; + public bool transparentDepthPrepass { - get => m_AlphaTestDepthPrepass; - set => m_AlphaTestDepthPrepass = value; + get => m_TransparentDepthPrepass; + set => m_TransparentDepthPrepass = value; } - [SerializeField] - bool m_AlphaTestDepthPostpass; - public bool alphaTestDepthPostpass + [SerializeField, FormerlySerializedAs("m_AlphaTestDepthPostpass")] + bool m_TransparentDepthPostpass; + public bool transparentDepthPostpass { - get => m_AlphaTestDepthPostpass; - set => m_AlphaTestDepthPostpass = value; + get => m_TransparentDepthPostpass; + set => m_TransparentDepthPostpass = value; } [SerializeField] diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Templates/ShaderPass.template b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Templates/ShaderPass.template index 8538b795546..fa113a05eae 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Templates/ShaderPass.template +++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Templates/ShaderPass.template @@ -27,17 +27,6 @@ Pass // -------------------------------------------------- // Defines - // Lighting Material only (will not affect unlit) - $DisableDecals: #define _DISABLE_DECALS 1 - $DisableSSR: #define _DISABLE_SSR 1 - $DisableSSRTransparent: #define _DISABLE_SSR_TRANSPARENT 1 - $BlendMode.PreserveSpecular: #define _BLENDMODE_PRESERVE_SPECULAR_LIGHTING 1 - - // Precomputed velocity is used for alembic - $AddPrecomputedVelocity: #define _ADD_PRECOMPUTED_VELOCITY - $TransparentWritesMotionVec: #define _TRANSPARENT_WRITES_MOTION_VEC 1 - $DepthOffset: #define _DEPTHOFFSET_ON 1 - // Attribute $AttributesMesh.normalOS: #define ATTRIBUTES_NEED_NORMAL $AttributesMesh.tangentOS: #define ATTRIBUTES_NEED_TANGENT @@ -53,14 +42,36 @@ Pass $VaryingsMeshToPS.texCoord2: #define VARYINGS_NEED_TEXCOORD2 $VaryingsMeshToPS.texCoord3: #define VARYINGS_NEED_TEXCOORD3 $VaryingsMeshToPS.color: #define VARYINGS_NEED_COLOR - $VaryingsMeshToPS.cullFace: #define VARYINGS_NEED_CULLFACE $features.graphVertex: #define HAVE_MESH_MODIFICATION $splice(GraphDefines) + #ifndef SHADER_UNLIT + // We need isFrontFace when using double sided - it is not required for unlit as in case of unlit double sided only drive the cullmode + #ifdef _DOUBLESIDED_ON + #define VARYINGS_NEED_CULLFACE + #endif + #endif + // Specific Material Define $include("ShaderPassDefine.template.hlsl") // Caution: we can use the define SHADER_UNLIT onlit after the above Material include as it is the Unlit template who define it + // To handle SSR on transparent correctly with a possibility to enable/disable it per framesettings + // we should have a code like this: + // #if !defined(_DISABLE_SSR_TRANSPARENT) + // #pragma multi_compile _ WRITE_NORMAL_BUFFER + // #endif + // i.e we enable the multicompile only if we can receive SSR or not, and then C# code drive + // it based on if SSR transparent in frame settings and not (and stripper can strip it). + // this is currently not possible with our current preprocessor as _DISABLE_SSR_TRANSPARENT is a keyword not a define + // so instead we used this and chose to pay the extra cost of normal write even if SSR transaprent is disabled. + // Ideally the shader graph generator should handle it but condition below can't be handle correctly for now. + #if SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_PREPASS + #if !defined(_DISABLE_SSR_TRANSPARENT) && !defined(SHADER_UNLIT) + #define WRITE_NORMAL_BUFFER + #endif + #endif + #ifndef DEBUG_DISPLAY // In case of opaque we don't want to perform the alpha test, it is done in depth prepass and we use depth equal for ztest (setup from UI) // Don't do it with debug display mode as it is possible there is no depth prepass in this case @@ -73,13 +84,6 @@ Pass #endif #endif - #ifndef SHADER_UNLIT - // We need isFontFace when using double sided - #if defined(_DOUBLESIDED_ON) && !defined(VARYINGS_NEED_CULLFACE) - #define VARYINGS_NEED_CULLFACE - #endif - #endif - // Translate transparent motion vector define #if defined(_TRANSPARENT_WRITES_MOTION_VEC) && defined(_SURFACE_TYPE_TRANSPARENT) #define _WRITE_TRANSPARENT_MOTION_VECTOR @@ -160,14 +164,25 @@ Pass // Perform alpha test very early to save performance (a killed pixel will not sample textures) // TODO: split graph evaluation to grab just alpha dependencies first? tricky.. #ifdef _ALPHATEST_ON - $DoAlphaTest: GENERIC_ALPHA_TEST(surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold); - $DoAlphaTestPrepass: GENERIC_ALPHA_TEST(surfaceDescription.Alpha, surfaceDescription.AlphaClipThresholdDepthPrepass); - $DoAlphaTestPostpass: GENERIC_ALPHA_TEST(surfaceDescription.Alpha, surfaceDescription.AlphaClipThresholdDepthPostpass); - $DoAlphaTestShadow: GENERIC_ALPHA_TEST(surfaceDescription.Alpha, surfaceDescription.AlphaClipThresholdShadow); + float alphaCutoff = surfaceDescription.AlphaClipThreshold; + #if SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_PREPASS + // The TransparentDepthPrepass is also used with SSR transparent. + // If an artists enable transaprent SSR but not the TransparentDepthPrepass itself, then we use AlphaClipThreshold + // otherwise if TransparentDepthPrepass is enabled we use AlphaClipThresholdDepthPrepass + $DoAlphaTestPrepass: alphaCutoff = surfaceDescription.AlphaClipThresholdDepthPrepass; + #elif SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_POSTPASS + // DepthPostpass always use its own alpha threshold + alphaCutoff = surfaceDescription.AlphaClipThresholdDepthPostpass; + #elif SHADERPASS == SHADERPASS_SHADOWS + // If use shadow threshold isn't enable we don't allow any test + $DoAlphaTestShadow: alphaCutoff = _UseShadowThreshold ? surfaceDescription.AlphaClipThresholdShadow : alphaCutoff; + #endif + + GENERIC_ALPHA_TEST(surfaceDescription.Alpha, alphaCutoff); #endif - #if !defined(SHADER_STAGE_RAY_TRACING) - $DepthOffset: ApplyDepthOffsetPositionInput(V, surfaceDescription.DepthOffset, GetViewForwardDir(), GetWorldToHClipMatrix(), posInput); + #if !defined(SHADER_STAGE_RAY_TRACING) && _DEPTHOFFSET_ON + ApplyDepthOffsetPositionInput(V, surfaceDescription.DepthOffset, GetViewForwardDir(), GetWorldToHClipMatrix(), posInput); #endif #ifndef SHADER_UNLIT @@ -194,11 +209,8 @@ Pass #endif // SHADER_UNLIT #ifdef _ALPHATEST_ON - // Used for sharpening by alpha to mask - $DoAlphaTest: builtinData.alphaClipTreshold = surfaceDescription.AlphaClipThreshold; - $DoAlphaTestPrepass: builtinData.alphaClipTreshold = surfaceDescription.AlphaClipThresholdDepthPrepass; - $DoAlphaTestPostpass: builtinData.alphaClipTreshold = surfaceDescription.AlphaClipThresholdDepthPostpass; - $DoAlphaTestShadow: builtinData.alphaClipTreshold = surfaceDescription.AlphaClipThresholdShadow; + // Used for sharpening by alpha to mask - Alpha to covertage is only used with depth only and forward pass (no shadow pass, no transparent pass) + builtinData.alphaClipTreshold = alphaCutoff; #endif // override sampleBakedGI - not used by Unlit @@ -212,7 +224,9 @@ Pass // This is a limitation of the current MRT approach. $SurfaceDescription.VTPackedFeedback: builtinData.vtPackedFeedback = surfaceDescription.VTPackedFeedback; - $DepthOffset: builtinData.depthOffset = surfaceDescription.DepthOffset; + #if _DEPTHOFFSET_ON + builtinData.depthOffset = surfaceDescription.DepthOffset; + #endif // TODO: We should generate distortion / distortionBlur for non distortion pass #if (SHADERPASS == SHADERPASS_DISTORTION) diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Templates/SharedCode.template.hlsl b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Templates/SharedCode.template.hlsl index c10f99c951e..e9830282f40 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Templates/SharedCode.template.hlsl +++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Templates/SharedCode.template.hlsl @@ -16,11 +16,10 @@ FragInputs BuildFragInputs(VaryingsMeshToPS input) $FragInputs.texCoord2: output.texCoord2 = input.texCoord2; $FragInputs.texCoord3: output.texCoord3 = input.texCoord3; $FragInputs.color: output.color = input.color; - #if _DOUBLESIDED_ON && SHADER_STAGE_FRAGMENT + + #if defined(VARYINGS_NEED_CULLFACE) && SHADER_STAGE_FRAGMENT output.isFrontFace = IS_FRONT_VFACE(input.cullFace, true, false); - #elif SHADER_STAGE_FRAGMENT - $FragInputs.isFrontFace: output.isFrontFace = IS_FRONT_VFACE(input.cullFace, true, false); - #endif // SHADER_STAGE_FRAGMENT + #endif return output; } @@ -70,4 +69,4 @@ FragInputs UnpackVaryingsMeshToFragInputs(PackedVaryingsMeshToPS input) UNITY_SETUP_INSTANCE_ID(input); VaryingsMeshToPS unpacked= UnpackVaryingsMeshToPS(input); return BuildFragInputs(unpacked); -} \ No newline at end of file +} diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitGUI.cs deleted file mode 100644 index 1af452e47e6..00000000000 --- a/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitGUI.cs +++ /dev/null @@ -1,53 +0,0 @@ -using UnityEngine; -using UnityEngine.Rendering; - -// Include material common properties names -using static UnityEngine.Rendering.HighDefinition.HDMaterialProperties; - -namespace UnityEditor.Rendering.HighDefinition -{ - /// - /// GUI for HDRP StackLit shader graphs - /// - class StackLitGUI : HDShaderGUI - { - // For surface option shader graph we only want all unlit features but alpha clip and back then front rendering - const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit - ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold - ^ SurfaceOptionUIBlock.Features.BackThenFrontRendering - ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass; - - MaterialUIBlockList uiBlocks = new MaterialUIBlockList - { - new SurfaceOptionUIBlock(MaterialUIBlock.Expandable.Base, features: surfaceOptionFeatures), - new ShaderGraphUIBlock(MaterialUIBlock.Expandable.ShaderGraph), - }; - - protected override void OnMaterialGUI(MaterialEditor materialEditor, MaterialProperty[] props) - { - using (var changed = new EditorGUI.ChangeCheckScope()) - { - uiBlocks.OnGUI(materialEditor, props); - ApplyKeywordsAndPassesIfNeeded(changed.changed, uiBlocks.materials); - } - } - - public static void SetupMaterialKeywordsAndPass(Material material) - { - SynchronizeShaderGraphProperties(material); - - BaseLitGUI.SetupBaseLitKeywords(material); - BaseLitGUI.SetupBaseLitMaterialPass(material); - bool receiveSSR = material.GetSurfaceType() == SurfaceType.Opaque ? (material.HasProperty(kReceivesSSR) ? material.GetInt(kReceivesSSR) != 0 : false) - : (material.HasProperty(kReceivesSSRTransparent) ? material.GetInt(kReceivesSSRTransparent) != 0 : false); - bool useSplitLighting = material.HasProperty(kUseSplitLighting) ? material.GetInt(kUseSplitLighting) != 0: false; - BaseLitGUI.SetupStencil(material, receiveSSR, useSplitLighting); - if (material.HasProperty(kAddPrecomputedVelocity)) - { - CoreUtils.SetKeyword(material, "_ADD_PRECOMPUTED_VELOCITY", material.GetInt(kAddPrecomputedVelocity) != 0); - } - } - - protected override void SetupMaterialKeywordsAndPassInternal(Material material) => SetupMaterialKeywordsAndPass(material); - } -} diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitGUI.cs.meta b/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitGUI.cs.meta deleted file mode 100644 index a4095e8dd47..00000000000 --- a/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitGUI.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: afc8242902cdb3b45be946c5b8a09c19 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitSubTarget.cs b/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitSubTarget.cs index 2ab81d5ea2b..ccdbfeea445 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitSubTarget.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitSubTarget.cs @@ -28,7 +28,7 @@ sealed partial class StackLitSubTarget : LightingSubTarget, ILegacyTarget, IRequ }; protected override string[] templateMaterialDirectories => passTemplateMaterialDirectories; - protected override string customInspector => "Rendering.HighDefinition.StackLitGUI"; + protected override string customInspector => "Rendering.HighDefinition.LightingShaderGraphGUI"; protected override string subTargetAssetGuid => "5f7ba34a143e67647b202a662748dae3"; // StackLitSubTarget.cs protected override ShaderID shaderID => HDShaderUtils.ShaderID.SG_StackLit; protected override FieldDescriptor subShaderField => new FieldDescriptor(kSubShader, "StackLit SubShader", ""); diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/AdvancedOptionsUIBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/AdvancedOptionsUIBlock.cs index f5185ea04b1..490fcbd5bfd 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/AdvancedOptionsUIBlock.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/AdvancedOptionsUIBlock.cs @@ -77,8 +77,7 @@ void DrawAdvancedOptionsGUI() { if ( addPrecomputedVelocity != null) materialEditor.ShaderProperty(addPrecomputedVelocity, Styles.addPrecomputedVelocityText); + } } } } -} - diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/HDShaderGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/HDShaderGUI.cs similarity index 89% rename from com.unity.render-pipelines.high-definition/Editor/Material/Unlit/HDShaderGUI.cs rename to com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/HDShaderGUI.cs index bfdc596a810..dd39cb40d5b 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/HDShaderGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/HDShaderGUI.cs @@ -90,8 +90,7 @@ protected static void ResetMaterialCustomRenderQueue(Material material) } readonly static string[] floatPropertiesToSynchronize = { - "_UseShadowThreshold", kReceivesSSR, kReceivesSSRTransparent, kUseSplitLighting, - kTransparentDepthPrepassEnable, kTransparentDepthPostpassEnable + kUseSplitLighting, kTransparentBackfaceEnable }; protected static void SynchronizeShaderGraphProperties(Material material) @@ -100,6 +99,14 @@ protected static void SynchronizeShaderGraphProperties(Material material) foreach (var floatToSync in floatPropertiesToSynchronize) if (material.HasProperty(floatToSync)) material.SetFloat(floatToSync, defaultProperties.GetFloat(floatToSync)); + + // Reset properties that are not enabled in the shader graph: + if (defaultProperties.HasProperty("_AlphaCutoffShadow") && defaultProperties.GetFloat("_AlphaCutoffShadow") == 0.0f) + material.SetFloat("_AlphaCutoffShadow", 0.0f); + if (defaultProperties.HasProperty(kTransparentWritingMotionVec) && defaultProperties.GetFloat(kTransparentWritingMotionVec) == 0.0f) + material.SetFloat(kTransparentWritingMotionVec, 0.0f); + + CoreUtils.Destroy(defaultProperties); defaultProperties = null; } } diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/HDShaderGUI.cs.meta b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/HDShaderGUI.cs.meta similarity index 100% rename from com.unity.render-pipelines.high-definition/Editor/Material/Unlit/HDShaderGUI.cs.meta rename to com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/HDShaderGUI.cs.meta diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LightingShaderGraphGUI.cs similarity index 82% rename from com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitGUI.cs rename to com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LightingShaderGraphGUI.cs index e74586f523c..3f577ddb419 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LightingShaderGraphGUI.cs @@ -7,19 +7,20 @@ namespace UnityEditor.Rendering.HighDefinition { /// - /// GUI for HDRP Lit shader graphs + /// Common GUI for Lit ShaderGraphs /// - class HDLitGUI : HDShaderGUI + class LightingShaderGraphGUI : HDShaderGUI { // For surface option shader graph we only want all unlit features but alpha clip and back then front rendering - const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit - ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold - ^ SurfaceOptionUIBlock.Features.BackThenFrontRendering; + const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Lit + ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass + | SurfaceOptionUIBlock.Features.ShowDepthOffsetOnly; MaterialUIBlockList uiBlocks = new MaterialUIBlockList { new SurfaceOptionUIBlock(MaterialUIBlock.Expandable.Base, features: surfaceOptionFeatures), new ShaderGraphUIBlock(MaterialUIBlock.Expandable.ShaderGraph), + new AdvancedOptionsUIBlock(MaterialUIBlock.Expandable.Advance, ~AdvancedOptionsUIBlock.Features.SpecularOcclusion) }; protected override void OnMaterialGUI(MaterialEditor materialEditor, MaterialProperty[] props) @@ -43,14 +44,11 @@ public static void SetupMaterialKeywordsAndPass(Material material) receiveSSR = material.HasProperty(kReceivesSSRTransparent) ? material.GetFloat(kReceivesSSRTransparent) != 0 : false; else receiveSSR = material.HasProperty(kReceivesSSR) ? material.GetFloat(kReceivesSSR) != 0 : false; - - bool useSplitLighting = material.HasProperty(kUseSplitLighting) ? material.GetInt(kUseSplitLighting) != 0 : false; + bool useSplitLighting = material.HasProperty(kUseSplitLighting) ? material.GetInt(kUseSplitLighting) != 0: false; BaseLitGUI.SetupStencil(material, receiveSSR, useSplitLighting); + if (material.HasProperty(kAddPrecomputedVelocity)) - { CoreUtils.SetKeyword(material, "_ADD_PRECOMPUTED_VELOCITY", material.GetInt(kAddPrecomputedVelocity) != 0); - } - } protected override void SetupMaterialKeywordsAndPassInternal(Material material) => SetupMaterialKeywordsAndPass(material); diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairGUI.cs.meta b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LightingShaderGraphGUI.cs.meta similarity index 83% rename from com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairGUI.cs.meta rename to com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LightingShaderGraphGUI.cs.meta index 9c88e31c392..51427843e30 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairGUI.cs.meta +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LightingShaderGraphGUI.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 246699d388f28e94eabfefbb894d65bd +guid: bf12bd036361b6c418e28ca948dc860f MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/ShaderGraphUIBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/ShaderGraphUIBlock.cs index 5111809ebd0..e8073262a90 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/ShaderGraphUIBlock.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/ShaderGraphUIBlock.cs @@ -28,6 +28,7 @@ protected static class Styles { public const string header = "Exposed Properties"; public static readonly GUIContent bakedEmission = new GUIContent("Baked Emission", ""); + public static readonly GUIContent motionVectorForVertexAnimationText = new GUIContent("Motion Vector For Vertex Animation", "When enabled, HDRP will correctly handle velocity for vertex animated object. Only enable if there is vertex animation in the ShaderGraph."); } Expandable m_ExpandableBit; @@ -150,47 +151,40 @@ void DrawEmissionGI() EmissionUIBlock.BakedEmissionEnabledProperty(materialEditor); } - // Track additional velocity state. See SG-ADDITIONALVELOCITY-NOTE - bool m_AddPrecomputedVelocity = false; - void DrawMotionVectorToggle() { - // I absolutely don't know what this is meant to do + // We have no way to setup motion vector pass to be false by default for a shader graph + // So here we workaround it with materialTag system by checking if a tag exist to know if it is + // the first time we display this information. And thus setup the MotionVector Pass to false. const string materialTag = "MotionVector"; - foreach (var material in materials) + + string tag = materials[0].GetTag(materialTag, false, "Nothing"); + if (tag == "Nothing") { - string tag = material.GetTag(materialTag, false, "Nothing"); - if (tag == "Nothing") - { - material.SetShaderPassEnabled(HDShaderPassNames.s_MotionVectorsStr, false); - material.SetOverrideTag(materialTag, "User"); - } + materials[0].SetShaderPassEnabled(HDShaderPassNames.s_MotionVectorsStr, false); + materials[0].SetOverrideTag(materialTag, "User"); + } + + //In the case of additional velocity data we will enable the motion vector pass. + bool addPrecomputedVelocity = false; + if (materials[0].HasProperty(kAddPrecomputedVelocity)) + { + addPrecomputedVelocity = materials[0].GetInt(kAddPrecomputedVelocity) != 0; } - // If using multi-select, apply toggled material to all materials. - bool enabled = materials[0].GetShaderPassEnabled(HDShaderPassNames.s_MotionVectorsStr); + bool currentMotionVectorState = materials[0].GetShaderPassEnabled(HDShaderPassNames.s_MotionVectorsStr); + bool enabled = currentMotionVectorState || addPrecomputedVelocity; + EditorGUI.BeginChangeCheck(); - enabled = EditorGUILayout.Toggle("Motion Vector For Vertex Animation", enabled); - - // SG-ADDITIONALVELOCITY-NOTE: - // We would like to automatically enable the motion vector pass (handled on material UI side) - // in case we add precomputed velocity in a graph. Due to serialization of material, changing - // a value in between shadergraph compilations would have no effect on a material, so we instead - // inform the motion vector UI via the existence of the property at all and query against that. - bool hasPrecomputedVelocity = materials[0].HasProperty(kAddPrecomputedVelocity); - if (m_AddPrecomputedVelocity != hasPrecomputedVelocity) + + using (new EditorGUI.DisabledScope(addPrecomputedVelocity)) { - enabled |= hasPrecomputedVelocity; - m_AddPrecomputedVelocity = hasPrecomputedVelocity; - GUI.changed = true; + enabled = EditorGUILayout.Toggle(Styles.motionVectorForVertexAnimationText, enabled); } - if (EditorGUI.EndChangeCheck()) + if (EditorGUI.EndChangeCheck() || currentMotionVectorState != enabled) { - foreach (var material in materials) - { - material.SetShaderPassEnabled(HDShaderPassNames.s_MotionVectorsStr, enabled); - } + materials[0].SetShaderPassEnabled(HDShaderPassNames.s_MotionVectorsStr, enabled); } } diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/SurfaceOptionUIBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/SurfaceOptionUIBlock.cs index 9ed4b3bda52..59058982c0b 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/SurfaceOptionUIBlock.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/SurfaceOptionUIBlock.cs @@ -3,6 +3,7 @@ using UnityEngine; using UnityEngine.Rendering.HighDefinition; using UnityEngine.Rendering; +using UnityEditor.ShaderGraph; // Include material common properties names using static UnityEngine.Rendering.HighDefinition.HDMaterialProperties; @@ -24,11 +25,14 @@ public enum Features DoubleSidedNormalMode = 1 << 6, BackThenFrontRendering = 1 << 7, ReceiveSSR = 1 << 8, - ShowAfterPostProcessPass = 1 << 9, - AlphaToMask = 1 << 10, - ShowPrePassAndPostPass = 1 << 11, - Unlit = Surface | BlendMode | DoubleSided | DoubleSidedNormalMode | AlphaCutoff | AlphaCutoffShadowThreshold | AlphaCutoffThreshold | BackThenFrontRendering | ShowAfterPostProcessPass | AlphaToMask, - Lit = All, + ReceiveDecal = 1 << 9, + ShowAfterPostProcessPass = 1 << 10, + AlphaToMask = 1 << 11, + ShowPrePassAndPostPass = 1 << 12, + ShowDepthOffsetOnly = 1 << 13, + PreserveSpecularLighting = 1 << 14, + Unlit = Surface | BlendMode | DoubleSided | AlphaCutoff | AlphaCutoffThreshold | AlphaCutoffShadowThreshold| AlphaToMask | BackThenFrontRendering | ShowAfterPostProcessPass | ShowPrePassAndPostPass | ShowDepthOffsetOnly, + Lit = All ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass, // Lit can't be display in after postprocess pass All = ~0, } @@ -133,7 +137,6 @@ internal static class Styles MaterialProperty transparentSortPriority = null; const string kTransparentSortPriority = HDMaterialProperties.kTransparentSortPriority; MaterialProperty transparentWritingMotionVec = null; - const string kTransparentWritingMotionVec = "_TransparentWritingMotionVec"; MaterialProperty doubleSidedEnable = null; const string kDoubleSidedEnable = "_DoubleSidedEnable"; MaterialProperty blendMode = null; @@ -185,7 +188,6 @@ internal static class Styles const string kDisplacementLockTilingScale = "_DisplacementLockTilingScale"; MaterialProperty depthOffsetEnable = null; - const string kDepthOffsetEnable = "_DepthOffsetEnable"; MaterialProperty tessellationMode = null; const string kTessellationMode = "_TessellationMode"; @@ -295,7 +297,9 @@ public override void LoadMaterialProperties() transparentWritingMotionVec = FindProperty(kTransparentWritingMotionVec); - enableBlendModePreserveSpecularLighting = FindProperty(kEnableBlendModePreserveSpecularLighting); + if ((m_Features & Features.PreserveSpecularLighting) != 0) + enableBlendModePreserveSpecularLighting = FindProperty(kEnableBlendModePreserveSpecularLighting); + enableFogOnTransparent = FindProperty(kEnableFogOnTransparent); if ((m_Features & Features.DoubleSided) != 0) @@ -341,7 +345,10 @@ public override void LoadMaterialProperties() tessellationMode = FindProperty(kTessellationMode); // Decal - supportDecals = FindProperty(kSupportDecals); + if ((m_Features & Features.ReceiveDecal) != 0) + { + supportDecals = FindProperty(kSupportDecals); + } // specular AA enableGeometricSpecularAA = FindProperty(kEnableGeometricSpecularAA); @@ -391,19 +398,32 @@ void DrawSurfaceOptionGUI() void DrawAlphaCutoffGUI() { EditorGUI.BeginChangeCheck(); - if (alphaCutoffEnable != null) + + // For shadergraphs we show this slider only if the feature is enabled in the shader settings. + bool showAlphaClipThreshold = true; + var shader = materials[0].shader; + bool isShaderGraph = shader.IsShaderGraph(); + if (isShaderGraph) + showAlphaClipThreshold = shader.GetPropertyDefaultFloatValue(shader.FindPropertyIndex(kAlphaCutoffEnabled)) > 0.0f; + + if (showAlphaClipThreshold && alphaCutoffEnable != null) materialEditor.ShaderProperty(alphaCutoffEnable, Styles.alphaCutoffEnableText); - if (alphaCutoffEnable != null && alphaCutoffEnable.floatValue == 1.0f) + if (showAlphaClipThreshold && alphaCutoffEnable != null && alphaCutoffEnable.floatValue == 1.0f) { EditorGUI.indentLevel++; - if (alphaCutoff != null) + if (showAlphaClipThreshold && alphaCutoff != null) materialEditor.ShaderProperty(alphaCutoff, Styles.alphaCutoffText); - if ((m_Features & Features.AlphaCutoffThreshold) != 0) + if (showAlphaClipThreshold && (m_Features & Features.AlphaCutoffShadowThreshold) != 0) { - if (useShadowThreshold != null) + // For shadergraphs we show this slider only if the feature is enabled in the shader settings. + bool showUseShadowThreshold = useShadowThreshold != null; + if (isShaderGraph) + showUseShadowThreshold = shader.GetPropertyDefaultFloatValue(shader.FindPropertyIndex(kUseShadowThreshold)) > 0.0f; + + if (showUseShadowThreshold) materialEditor.ShaderProperty(useShadowThreshold, Styles.useShadowThresholdText); if (alphaCutoffShadow != null && useShadowThreshold != null && useShadowThreshold.floatValue == 1.0f && (m_Features & Features.AlphaCutoffShadowThreshold) != 0) @@ -414,7 +434,7 @@ void DrawAlphaCutoffGUI() } } - if ((m_Features & Features.AlphaToMask) != 0) + if (showAlphaClipThreshold && (m_Features & Features.AlphaToMask) != 0) { if (alphaToMask != null) materialEditor.ShaderProperty(alphaToMask, Styles.alphaToMaskText); @@ -422,8 +442,9 @@ void DrawAlphaCutoffGUI() // With transparent object and few specific materials like Hair, we need more control on the cutoff to apply // This allow to get a better sorting (with prepass), better shadow (better silhouettes fidelity) etc... - if (surfaceTypeValue == SurfaceType.Transparent) + if (showAlphaClipThreshold && surfaceTypeValue == SurfaceType.Transparent) { + // TODO: check if passes exists if (transparentDepthPrepassEnable != null && transparentDepthPrepassEnable.floatValue == 1.0f) { if (alphaCutoffPrepass != null) @@ -490,14 +511,17 @@ void DrawSurfaceGUI() else if (blendMode != null && showBlendModePopup) BlendModePopup(); - EditorGUI.indentLevel++; if (renderQueueHasMultipleDifferentValue) + if ((m_Features & Features.PreserveSpecularLighting) != 0) { - using (new EditorGUI.DisabledScope(true)) - EditorGUILayout.LabelField(Styles.enableBlendModePreserveSpecularLightingText, Styles.notSupportedInMultiEdition); + EditorGUI.indentLevel++; if (renderQueueHasMultipleDifferentValue) + { + using (new EditorGUI.DisabledScope(true)) + EditorGUILayout.LabelField(Styles.enableBlendModePreserveSpecularLightingText, Styles.notSupportedInMultiEdition); + } + else if (enableBlendModePreserveSpecularLighting != null && blendMode != null && showBlendModePopup) + materialEditor.ShaderProperty(enableBlendModePreserveSpecularLighting, Styles.enableBlendModePreserveSpecularLightingText); + EditorGUI.indentLevel--; } - else if (enableBlendModePreserveSpecularLighting != null && blendMode != null && showBlendModePopup) - materialEditor.ShaderProperty(enableBlendModePreserveSpecularLighting, Styles.enableBlendModePreserveSpecularLightingText); - EditorGUI.indentLevel--; if (transparentSortPriority != null) { @@ -513,15 +537,18 @@ void DrawSurfaceGUI() if (enableFogOnTransparent != null) materialEditor.ShaderProperty(enableFogOnTransparent, Styles.enableTransparentFogText); - if (transparentBackfaceEnable != null) + bool shaderHasBackThenFrontPass = materials[0].FindPass(HDShaderPassNames.s_TransparentBackfaceStr) != -1; + if (shaderHasBackThenFrontPass && transparentBackfaceEnable != null) materialEditor.ShaderProperty(transparentBackfaceEnable, Styles.transparentBackfaceEnableText); if ((m_Features & Features.ShowPrePassAndPostPass) != 0) { - if (transparentDepthPrepassEnable != null) + bool shaderHasDepthPrePass = materials[0].FindPass(HDShaderPassNames.s_TransparentDepthPrepassStr) != -1; + if (shaderHasDepthPrePass && transparentDepthPrepassEnable != null) materialEditor.ShaderProperty(transparentDepthPrepassEnable, Styles.transparentDepthPrepassEnableText); - if (transparentDepthPostpassEnable != null) + bool shaderHasDepthPostPass = materials[0].FindPass(HDShaderPassNames.s_TransparentDepthPostpassStr) != -1; + if (shaderHasDepthPostPass && transparentDepthPostpassEnable != null) materialEditor.ShaderProperty(transparentDepthPostpassEnable, Styles.transparentDepthPostpassEnableText); } @@ -769,7 +796,9 @@ void DrawLitSurfaceOptions() } } - if (displacementMode != null) + if ((m_Features & Features.ShowDepthOffsetOnly) != 0 && depthOffsetEnable != null) + materialEditor.ShaderProperty(depthOffsetEnable, Styles.depthOffsetEnableText); + else if (displacementMode != null) { EditorGUI.BeginChangeCheck(); FilterDisplacementMode(); diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/BaseUnlitGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/BaseUnlitGUI.cs index d81bbc37265..e76d5be4add 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/BaseUnlitGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/BaseUnlitGUI.cs @@ -321,8 +321,9 @@ static public void SetupBaseUnlitPass(this Material material) bool rayTracingEnable = (material.GetFloat(kRayTracing) > 0.0f); material.SetShaderPassEnabled(HDShaderPassNames.s_RayTracingPrepassStr, rayTracingEnable); } - + // Shader graphs materials have their own management of motion vector pass in the material inspector + // (see DrawMotionVectorToggle()) if (!material.shader.IsShaderGraph()) { //In the case of additional velocity data we will enable the motion vector pass. @@ -338,9 +339,7 @@ static public void SetupBaseUnlitPass(this Material material) // don't do any vertex deformation but we can still have // skinning / morph target material.SetShaderPassEnabled(HDShaderPassNames.s_MotionVectorsStr, addPrecomputedVelocity); - } - } } diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitGUI.cs index a3f577a6075..b416dccea53 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitGUI.cs @@ -12,16 +12,13 @@ namespace UnityEditor.Rendering.HighDefinition /// class HDUnlitGUI : HDShaderGUI { - // For surface option shader graph we only want all unlit features but alpha clip, double sided mode and back then front rendering - const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit - ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold - ^ SurfaceOptionUIBlock.Features.DoubleSidedNormalMode - ^ SurfaceOptionUIBlock.Features.BackThenFrontRendering; + const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit; MaterialUIBlockList uiBlocks = new MaterialUIBlockList { new SurfaceOptionUIBlock(MaterialUIBlock.Expandable.Base, features: surfaceOptionFeatures), new ShaderGraphUIBlock(MaterialUIBlock.Expandable.ShaderGraph, ShaderGraphUIBlock.Features.Unlit), + new AdvancedOptionsUIBlock(MaterialUIBlock.Expandable.Advance, ~AdvancedOptionsUIBlock.Features.SpecularOcclusion) }; protected override void OnMaterialGUI(MaterialEditor materialEditor, MaterialProperty[] props) diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDShaderUtils.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDShaderUtils.cs index 320dfbba9e9..69c21aa42e1 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDShaderUtils.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDShaderUtils.cs @@ -64,10 +64,10 @@ internal enum ShaderID { ShaderID.TerrainLit, TerrainLitGUI.SetupMaterialKeywordsAndPass }, { ShaderID.AxF, AxFGUI.SetupMaterialKeywordsAndPass }, { ShaderID.SG_Unlit, HDUnlitGUI.SetupMaterialKeywordsAndPass }, - { ShaderID.SG_Lit, HDLitGUI.SetupMaterialKeywordsAndPass }, - { ShaderID.SG_Hair, HairGUI.SetupMaterialKeywordsAndPass }, - { ShaderID.SG_Fabric, FabricGUI.SetupMaterialKeywordsAndPass }, - { ShaderID.SG_StackLit, StackLitGUI.SetupMaterialKeywordsAndPass }, + { ShaderID.SG_Lit, LightingShaderGraphGUI.SetupMaterialKeywordsAndPass }, + { ShaderID.SG_Hair, LightingShaderGraphGUI.SetupMaterialKeywordsAndPass }, + { ShaderID.SG_Fabric, LightingShaderGraphGUI.SetupMaterialKeywordsAndPass }, + { ShaderID.SG_StackLit, LightingShaderGraphGUI.SetupMaterialKeywordsAndPass }, // no entry for ShaderID.SG_Decal // no entry for ShaderID.SG_Eye }; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Compositor/Shaders/AlphaInjection.shader b/com.unity.render-pipelines.high-definition/Runtime/Compositor/Shaders/AlphaInjection.shader index f91612067df..90ac3d581ec 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Compositor/Shaders/AlphaInjection.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Compositor/Shaders/AlphaInjection.shader @@ -1,9 +1,9 @@ -Shader "Hidden/Shader/AlphaInjection" +Shader "Hidden/Shader/AlphaInjection" { HLSLINCLUDE #pragma target 4.5 - #pragma only_renderers d3d11 ps4 xboxone vulkan metal switch + #pragma only_renderers d3d11 playstation xboxone vulkan metal switch #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" diff --git a/com.unity.render-pipelines.high-definition/Runtime/Compositor/Shaders/ChromaKeying.shader b/com.unity.render-pipelines.high-definition/Runtime/Compositor/Shaders/ChromaKeying.shader index 5f865aabd74..1f2a41392e0 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Compositor/Shaders/ChromaKeying.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Compositor/Shaders/ChromaKeying.shader @@ -1,9 +1,9 @@ -Shader "Hidden/Shader/ChromaKeying" +Shader "Hidden/Shader/ChromaKeying" { HLSLINCLUDE #pragma target 4.5 - #pragma only_renderers d3d11 ps4 xboxone vulkan metal switch + #pragma only_renderers d3d11 playstation xboxone vulkan metal switch #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" diff --git a/com.unity.render-pipelines.high-definition/Runtime/Compositor/Shaders/CustomClear.shader b/com.unity.render-pipelines.high-definition/Runtime/Compositor/Shaders/CustomClear.shader index e3c59cc1307..85feaa9ec27 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Compositor/Shaders/CustomClear.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Compositor/Shaders/CustomClear.shader @@ -3,7 +3,7 @@ Shader "Hidden/HDRP/CustomClear" HLSLINCLUDE #pragma target 4.5 - #pragma only_renderers d3d11 ps4 xboxone vulkan metal switch + #pragma only_renderers d3d11 playstation xboxone vulkan metal switch #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl" diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/LightingDebug.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Debug/LightingDebug.cs.hlsl index 65580776c7c..7fc211fe0a9 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Debug/LightingDebug.cs.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/LightingDebug.cs.hlsl @@ -70,7 +70,8 @@ #define EXPOSUREDEBUGMODE_NONE (0) #define EXPOSUREDEBUGMODE_SCENE_EV100VALUES (1) #define EXPOSUREDEBUGMODE_HISTOGRAM_VIEW (2) -#define EXPOSUREDEBUGMODE_METERING_WEIGHTED (3) +#define EXPOSUREDEBUGMODE_FINAL_IMAGE_HISTOGRAM_VIEW (3) +#define EXPOSUREDEBUGMODE_METERING_WEIGHTED (4) // // UnityEngine.Rendering.HighDefinition.ProbeVolumeDebugMode: static fields diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxFData.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxFData.hlsl index 5a58b7cdeed..dd7d19525a3 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxFData.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxFData.hlsl @@ -509,10 +509,10 @@ void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs p float alphaCutoff = _AlphaCutoff; #if SHADERPASS == SHADERPASS_SHADOWS - GENERIC_ALPHA_TEST(alpha, _UseShadowThreshold ? _AlphaCutoffShadow : alphaCutoff); - #else - GENERIC_ALPHA_TEST(alpha, alphaCutoff); + alphaCutoff = _UseShadowThreshold ? _AlphaCutoffShadow : alphaCutoff; #endif + + GENERIC_ALPHA_TEST(alpha, alphaCutoff); #endif surfaceData.ambientOcclusion = 1.0; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalData.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalData.hlsl index a71afd0b49a..f74301959f3 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalData.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalData.hlsl @@ -23,9 +23,9 @@ void GetSurfaceData(FragInputs input, float3 V, PositionInputs posInput, out Dec ZERO_INITIALIZE(DecalSurfaceData, surfaceData); surfaceData.baseColor = _BaseColor; - surfaceData.emissive = _EmissiveColor * fadeFactor; + surfaceData.emissive = _EmissiveColor.rgb * fadeFactor; #ifdef _EMISSIVEMAP - surfaceData.emissive *= SAMPLE_TEXTURE2D(_EmissiveColorMap, sampler_EmissiveColorMap, texCoords); + surfaceData.emissive *= SAMPLE_TEXTURE2D(_EmissiveColorMap, sampler_EmissiveColorMap, texCoords).rgb; #endif // Inverse pre-expose using _EmissiveExposureWeight weight diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl index f944e94b1be..4bd1b0e3dbe 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl @@ -354,7 +354,7 @@ NormalData ConvertSurfaceDataToNormalData(SurfaceData surfaceData) // Note: When we are in the prepass (depth only or motion vector) and we need to export the normal/roughness - Mean we are lit forward. In deferred the normal buffer will not be exported // If the fragment that we are processing has clear cloat, we want to export the clear coat's perceptual roughness and geometric normal // instead of the base layer's roughness and the shader normal to be use by SSR - #if SHADERPASS == SHADERPASS_DEPTH_ONLY || SHADERPASS == SHADERPASS_MOTION_VECTORS + #if (SHADERPASS == SHADERPASS_DEPTH_ONLY) || (SHADERPASS == SHADERPASS_MOTION_VECTORS) || (SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_PREPASS) if (HasFlag(surfaceData.materialFeatures, MATERIALFEATUREFLAGS_LIT_CLEAR_COAT)) { normalData.normalWS = surfaceData.geomNormalWS; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.shader b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.shader index 5e52778b50b..e43a89af494 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.shader @@ -686,8 +686,7 @@ Shader "HDRP/Lit" // enable dithering LOD crossfade #pragma multi_compile _ LOD_FADE_CROSSFADE - #define SHADERPASS SHADERPASS_DEPTH_ONLY - #define CUTOFF_TRANSPARENT_DEPTH_PREPASS + #define SHADERPASS SHADERPASS_TRANSPARENT_DEPTH_PREPASS // If the transparent surface should have reflections, then we should output normal #if !defined(_DISABLE_SSR_TRANSPARENT) @@ -876,8 +875,7 @@ Shader "HDRP/Lit" // enable dithering LOD crossfade #pragma multi_compile _ LOD_FADE_CROSSFADE - #define SHADERPASS SHADERPASS_DEPTH_ONLY - #define CUTOFF_TRANSPARENT_DEPTH_POSTPASS + #define SHADERPASS SHADERPASS_TRANSPARENT_DEPTH_POSTPASS #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl index 5d1d048151e..490ee83361e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl @@ -218,18 +218,17 @@ void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs p float alphaValue = SAMPLE_UVMAPPING_TEXTURE2D(_BaseColorMap, sampler_BaseColorMap, layerTexCoord.base).a * _BaseColor.a; // Perform alha test very early to save performance (a killed pixel will not sample textures) + #if SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_PREPASS + float alphaCutoff = _AlphaCutoffPrepass; + #elif SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_POSTPASS + float alphaCutoff = _AlphaCutoffPostpass; + #elif SHADERPASS == SHADERPASS_SHADOWS + float alphaCutoff = _UseShadowThreshold ? _AlphaCutoffShadow : _AlphaCutoff; + #else float alphaCutoff = _AlphaCutoff; - #ifdef CUTOFF_TRANSPARENT_DEPTH_PREPASS - alphaCutoff = _AlphaCutoffPrepass; - #elif defined(CUTOFF_TRANSPARENT_DEPTH_POSTPASS) - alphaCutoff = _AlphaCutoffPostpass; #endif - #if SHADERPASS == SHADERPASS_SHADOWS - GENERIC_ALPHA_TEST(alphaValue, _UseShadowThreshold ? _AlphaCutoffShadow : alphaCutoff); - #else - GENERIC_ALPHA_TEST(alphaValue, alphaCutoff); - #endif + GENERIC_ALPHA_TEST(alphaValue, alphaCutoff); #endif // We perform the conversion to world of the normalTS outside of the GetSurfaceData diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitTessellation.shader b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitTessellation.shader index 74898d6e0a1..5b3915797b2 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitTessellation.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitTessellation.shader @@ -633,8 +633,7 @@ Shader "HDRP/LitTessellation" HLSLPROGRAM - #define SHADERPASS SHADERPASS_DEPTH_ONLY - #define CUTOFF_TRANSPARENT_DEPTH_PREPASS + #define SHADERPASS SHADERPASS_TRANSPARENT_DEPTH_PREPASS #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" @@ -789,8 +788,7 @@ Shader "HDRP/LitTessellation" HLSLPROGRAM - #define SHADERPASS SHADERPASS_DEPTH_ONLY - #define CUTOFF_TRANSPARENT_DEPTH_POSTPASS + #define SHADERPASS SHADERPASS_TRANSPARENT_DEPTH_POSTPASS #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitDepthPass.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.shader b/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.shader index 8c30ff42883..fa0c3a30344 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.shader @@ -452,6 +452,8 @@ Shader "HDRP/Unlit" #pragma only_renderers d3d11 #pragma raytracing surface_shader + #pragma multi_compile _ DEBUG_DISPLAY + #define SHADERPASS SHADERPASS_RAYTRACING_INDIRECT #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingMacros.hlsl" @@ -480,6 +482,8 @@ Shader "HDRP/Unlit" #pragma only_renderers d3d11 #pragma raytracing surface_shader + #pragma multi_compile _ DEBUG_DISPLAY + #define SHADERPASS SHADERPASS_RAYTRACING_FORWARD #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingMacros.hlsl" @@ -507,10 +511,6 @@ Shader "HDRP/Unlit" #pragma only_renderers d3d11 #pragma raytracing surface_shader - #pragma multi_compile _ LIGHTMAP_ON - #pragma multi_compile _ DIRLIGHTMAP_COMBINED - #pragma multi_compile _ DYNAMICLIGHTMAP_ON - #define SHADERPASS SHADERPASS_RAYTRACING_GBUFFER #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingMacros.hlsl" diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs index 9651448da5e..70a1400e68d 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs @@ -932,6 +932,7 @@ static class HDMaterialProperties public const string kReceivesSSRTransparent = "_ReceivesSSRTransparent"; public const string kAddPrecomputedVelocity = "_AddPrecomputedVelocity"; public const string kShadowMatteFilter = "_ShadowMatteFilter"; + public const string kDepthOffsetEnable = "_DepthOffsetEnable"; public static readonly Color[] kLayerColors = { diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/ColorPyramidPS.shader b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/ColorPyramidPS.shader index 2d3c0bad80b..79c17e5494f 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/ColorPyramidPS.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/ColorPyramidPS.shader @@ -1,4 +1,4 @@ -Shader "ColorPyramidPS" +Shader "Hidden/ColorPyramidPS" { SubShader { diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassUtils.shader b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassUtils.shader index 82f3ff92a6d..8d80e0b0aff 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassUtils.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassUtils.shader @@ -5,7 +5,7 @@ Shader "Hidden/HDRP/CustomPassUtils" #pragma vertex Vert #pragma target 4.5 - #pragma only_renderers d3d11 ps4 xboxone vulkan metal switch + #pragma only_renderers d3d11 playstation xboxone vulkan metal switch #pragma enable_d3d11_debug_symbols #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassCommon.hlsl" diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs index 4cbe667b0a0..33b67deefe3 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs @@ -11,6 +11,8 @@ enum ShaderPass ForwardUnlit, DeferredLighting, DepthOnly, + TransparentDepthPrepass, + TransparentDepthPostpass, MotionVectors, Distortion, LightTransport, diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl index fa2fad1b720..b65e587248b 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl @@ -12,24 +12,26 @@ #define SHADERPASS_FORWARD_UNLIT (2) #define SHADERPASS_DEFERRED_LIGHTING (3) #define SHADERPASS_DEPTH_ONLY (4) -#define SHADERPASS_MOTION_VECTORS (5) -#define SHADERPASS_DISTORTION (6) -#define SHADERPASS_LIGHT_TRANSPORT (7) -#define SHADERPASS_SHADOWS (8) -#define SHADERPASS_SUBSURFACE_SCATTERING (9) -#define SHADERPASS_VOLUMETRIC_LIGHTING (10) -#define SHADERPASS_DBUFFER_PROJECTOR (11) -#define SHADERPASS_DBUFFER_MESH (12) -#define SHADERPASS_FORWARD_EMISSIVE_PROJECTOR (13) -#define SHADERPASS_FORWARD_EMISSIVE_MESH (14) -#define SHADERPASS_RAYTRACING (15) -#define SHADERPASS_RAYTRACING_INDIRECT (16) -#define SHADERPASS_RAYTRACING_VISIBILITY (17) -#define SHADERPASS_RAYTRACING_FORWARD (18) -#define SHADERPASS_RAYTRACING_GBUFFER (19) -#define SHADERPASS_RAYTRACING_SUB_SURFACE (20) -#define SHADERPASS_PATH_TRACING (21) -#define SHADERPASS_CONSTANT (22) +#define SHADERPASS_TRANSPARENT_DEPTH_PREPASS (5) +#define SHADERPASS_TRANSPARENT_DEPTH_POSTPASS (6) +#define SHADERPASS_MOTION_VECTORS (7) +#define SHADERPASS_DISTORTION (8) +#define SHADERPASS_LIGHT_TRANSPORT (9) +#define SHADERPASS_SHADOWS (10) +#define SHADERPASS_SUBSURFACE_SCATTERING (11) +#define SHADERPASS_VOLUMETRIC_LIGHTING (12) +#define SHADERPASS_DBUFFER_PROJECTOR (13) +#define SHADERPASS_DBUFFER_MESH (14) +#define SHADERPASS_FORWARD_EMISSIVE_PROJECTOR (15) +#define SHADERPASS_FORWARD_EMISSIVE_MESH (16) +#define SHADERPASS_RAYTRACING (17) +#define SHADERPASS_RAYTRACING_INDIRECT (18) +#define SHADERPASS_RAYTRACING_VISIBILITY (19) +#define SHADERPASS_RAYTRACING_FORWARD (20) +#define SHADERPASS_RAYTRACING_GBUFFER (21) +#define SHADERPASS_RAYTRACING_SUB_SURFACE (22) +#define SHADERPASS_PATH_TRACING (23) +#define SHADERPASS_CONSTANT (24) #endif diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl index dc1efab57c5..f2423ba37a0 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl @@ -1,4 +1,4 @@ -#if (SHADERPASS != SHADERPASS_DEPTH_ONLY && SHADERPASS != SHADERPASS_SHADOWS) +#if (SHADERPASS != SHADERPASS_DEPTH_ONLY && SHADERPASS != SHADERPASS_SHADOWS && SHADERPASS != SHADERPASS_TRANSPARENT_DEPTH_PREPASS && SHADERPASS != SHADERPASS_TRANSPARENT_DEPTH_POSTPASS) #error SHADERPASS_is_not_correctly_define #endif diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Material/DefaultHDDecalMaterial.mat b/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Material/DefaultHDDecalMaterial.mat index 3b93a609424..ee970644b81 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Material/DefaultHDDecalMaterial.mat +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Material/DefaultHDDecalMaterial.mat @@ -315,4 +315,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 4 + version: 5 diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Material/DefaultHDMaterial.mat b/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Material/DefaultHDMaterial.mat index 863b0d54012..2ed5298b469 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Material/DefaultHDMaterial.mat +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Material/DefaultHDMaterial.mat @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 4 + version: 5 --- !u!21 &2100000 Material: serializedVersion: 6 @@ -262,6 +262,7 @@ Material: - _NormalMapSpace: 0 - _NormalScale: 1 - _OcclusionStrength: 1 + - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Material/DefaultHDMirrorMaterial.mat b/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Material/DefaultHDMirrorMaterial.mat index a5fa5de3909..dd6beba57c7 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Material/DefaultHDMirrorMaterial.mat +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Material/DefaultHDMirrorMaterial.mat @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 4 + version: 5 --- !u!21 &2100000 Material: serializedVersion: 6 @@ -261,6 +261,7 @@ Material: - _NormalMapSpace: 0 - _NormalScale: 1 - _OcclusionStrength: 1 + - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Material/DefaultHDParticleMaterial.mat b/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Material/DefaultHDParticleMaterial.mat index 17b27b474e6..0a16b8eaa95 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Material/DefaultHDParticleMaterial.mat +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Material/DefaultHDParticleMaterial.mat @@ -184,6 +184,7 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 + - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 @@ -265,4 +266,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 4 + version: 5 diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Material/DefaultHDTerrainMaterial.mat b/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Material/DefaultHDTerrainMaterial.mat index fd8bbc78087..c2b78a1eb82 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Material/DefaultHDTerrainMaterial.mat +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/Material/DefaultHDTerrainMaterial.mat @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 4 + version: 5 --- !u!21 &2100000 Material: serializedVersion: 6