From 4bccdef746d8c7e3246772650ce022c35e493db0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Wed, 14 Oct 2020 17:23:43 +0200 Subject: [PATCH 01/19] Fixed pre-refraction shader with refraction enabled --- .../Eye/ShaderGraph/EyeSubTarget.Migration.cs | 2 +- .../ShaderGraph/FabricSubTarget.Migration.cs | 2 +- .../ShaderGraph/HairSubTarget.Migration.cs | 2 +- .../ShaderGraph/HDLitSubTarget.Migration.cs | 10 ++++---- .../Lit/ShaderGraph/HDLitSubTarget.cs | 24 ++++++++++++++++--- .../LitSurfaceOptionPropertyBlock.cs | 5 +++- .../ShaderGraph/HDSubShaderUtilities.cs | 5 ++-- .../Material/ShaderGraph/LightingSubTarget.cs | 2 +- .../ShaderGraph/SurfaceOptionPropertyBlock.cs | 16 +++++++++---- .../Material/ShaderGraph/SurfaceSubTarget.cs | 6 ++--- .../ShaderGraph/TargetData/SystemData.cs | 6 ++--- .../StackLitSubTarget.Migration.cs | 2 +- .../Material/UIBlocks/SurfaceOptionUIBlock.cs | 1 - .../ShaderGraph/HDUnlitSubTarget.Migration.cs | 8 +++---- .../DiffusionProfileSettings.cs | 2 +- .../RenderPipeline/HDStringConstants.cs | 2 ++ 16 files changed, 62 insertions(+), 33 deletions(-) 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 8e983ddb3b2..d9cc4c52f4b 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,7 +27,7 @@ public bool TryUpgradeFromMasterNode(IMasterNode1 masterNode, out Dictionary true; protected override bool requireSplitLighting => litData.materialType == HDLitData.MaterialType.SubsurfaceScattering; + public override void Setup(ref TargetSetupContext ctx) + { + // before we fixed the pre-refraction options, it was possible to enable both refraction and pre-refraction option, so we patch this here. + if (systemData.renderQueueType == HDRenderQueue.RenderQueueType.PreRefraction && litData.refractionModel != ScreenSpaceRefraction.RefractionModel.None) + systemData.renderQueueType = HDRenderQueue.RenderQueueType.Transparent; + + base.Setup(ref ctx); + } + protected override SubShaderDescriptor GetSubShaderDescriptor() { var descriptor = base.GetSubShaderDescriptor(); @@ -94,7 +103,7 @@ public override void GetFields(ref TargetFieldContext context) AddDistortionFields(ref context); var descs = context.blocks.Select(x => x.descriptor); - bool hasRefraction = (systemData.surfaceType == SurfaceType.Transparent && systemData.renderingPass != HDRenderQueue.RenderQueueType.PreRefraction && litData.refractionModel != ScreenSpaceRefraction.RefractionModel.None); + bool hasRefraction = (systemData.surfaceType == SurfaceType.Transparent && litData.refractionModel != ScreenSpaceRefraction.RefractionModel.None); // Lit specific properties context.AddField(DotsProperties, context.hasDotsProperties); @@ -129,7 +138,7 @@ public override void GetFields(ref TargetFieldContext context) public override void GetActiveBlocks(ref TargetActiveBlockContext context) { - bool hasRefraction = (systemData.surfaceType == SurfaceType.Transparent && systemData.renderingPass != HDRenderQueue.RenderQueueType.PreRefraction && litData.refractionModel != ScreenSpaceRefraction.RefractionModel.None); + bool hasRefraction = (systemData.surfaceType == SurfaceType.Transparent && systemData.renderQueueType != HDRenderQueue.RenderQueueType.PreRefraction && litData.refractionModel != ScreenSpaceRefraction.RefractionModel.None); bool hasDistortion = (systemData.surfaceType == SurfaceType.Transparent && builtinData.distortion); // Vertex @@ -163,11 +172,20 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera base.CollectShaderProperties(collector, generationMode); HDSubShaderUtilities.AddRayTracingProperty(collector, litData.rayTracing); + + // Refraction model property allow the material inspector to check if refraction is enabled in the shader. + collector.AddShaderProperty(new Vector1ShaderProperty{ + floatType = FloatType.Default, + hidden = true, + value = (int)litData.refractionModel, + overrideReferenceName = kRefractionModel, + }); } protected override void AddInspectorPropertyBlocks(SubTargetPropertiesGUI blockList) { - blockList.AddPropertyBlock(new LitSurfaceOptionPropertyBlock(SurfaceOptionPropertyBlock.Features.Lit, litData)); + var features = SurfaceOptionPropertyBlock.Features.Lit | (litData.refractionModel != ScreenSpaceRefraction.RefractionModel.None ? SurfaceOptionPropertyBlock.Features.HasRefraction : 0); + blockList.AddPropertyBlock(new LitSurfaceOptionPropertyBlock(features, litData)); if (systemData.surfaceType == SurfaceType.Transparent) blockList.AddPropertyBlock(new DistortionPropertyBlock()); blockList.AddPropertyBlock(new AdvancedOptionsPropertyBlock()); diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/LitSurfaceOptionPropertyBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/LitSurfaceOptionPropertyBlock.cs index 5092ef668ed..3e6ac6879cb 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/LitSurfaceOptionPropertyBlock.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/LitSurfaceOptionPropertyBlock.cs @@ -39,7 +39,10 @@ protected override void CreatePropertyGUI() { AddProperty(transmissionEnableText, () => litData.sssTransmission, (newValue) => litData.sssTransmission = newValue); } - AddProperty(refractionModelText, () => litData.refractionModel, (newValue) => litData.refractionModel = newValue); + if (systemData.surfaceType == SurfaceType.Transparent) + { + AddProperty(refractionModelText, () => litData.refractionModel, (newValue) => litData.refractionModel = newValue); + } if (litData.materialType == HDLitData.MaterialType.SpecularColor) { AddProperty(energyConservingSpecularColorText, () => litData.energyConservingSpecular, (newValue) => litData.energyConservingSpecular = newValue); 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 df775acb64d..a6d45199cda 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 @@ -221,7 +221,7 @@ public static string RenderQueueName(HDRenderQueue.RenderQueueType value) } } - public static System.Collections.Generic.List GetRenderingPassList(bool opaque, bool needAfterPostProcess) + public static System.Collections.Generic.List GetRenderingPassList(bool opaque, bool needAfterPostProcess, bool hasRefraction) { // We can't use RenderPipelineManager.currentPipeline here because this is called before HDRP is created by SG window var result = new System.Collections.Generic.List(); @@ -233,7 +233,8 @@ public static string RenderQueueName(HDRenderQueue.RenderQueueType value) } else { - result.Add(HDRenderQueue.RenderQueueType.PreRefraction); + if (!hasRefraction) + result.Add(HDRenderQueue.RenderQueueType.PreRefraction); result.Add(HDRenderQueue.RenderQueueType.Transparent); result.Add(HDRenderQueue.RenderQueueType.LowTransparent); if (needAfterPostProcess) 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 375f4124b02..e4a071549b3 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 @@ -32,7 +32,7 @@ public LightingData lightingData protected override string renderQueue { - get => HDRenderQueue.GetShaderTagValue(HDRenderQueue.ChangeType(systemData.renderingPass, systemData.sortPriority, systemData.alphaTest, lightingData.receiveDecals)); + get => HDRenderQueue.GetShaderTagValue(HDRenderQueue.ChangeType(systemData.renderQueueType, systemData.sortPriority, systemData.alphaTest, lightingData.receiveDecals)); } protected override string renderType => HDRenderTypeTags.HDLitShader.ToString(); 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 08a8167d89c..4bd6961127a 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 @@ -19,10 +19,11 @@ public enum Features { None = 0, ShowDoubleSidedNormal = 1 << 0, + HasRefraction = 1 << 1, All = ~0, - Unlit = All ^ ShowDoubleSidedNormal, // hide double sided normal for unlit - Lit = All, + Unlit = Lit ^ ShowDoubleSidedNormal, // hide double sided normal for unlit + Lit = All ^ HasRefraction, // Refraction is not enabled by default } class Styles @@ -42,13 +43,18 @@ protected override void CreatePropertyGUI() { AddProperty(surfaceTypeText, () => systemData.surfaceType, (newValue) => { systemData.surfaceType = newValue; - systemData.TryChangeRenderingPass(systemData.renderingPass); + systemData.TryChangeRenderingPass(systemData.renderQueueType); }); + // TODO: if HasRefraction, convert render queue before refraction to default (transparent only) + // + remove before refraction from the list + + bool hasRefraction = (enabledFeatures & Features.HasRefraction) != 0; context.globalIndentLevel++; - var renderingPassList = HDSubShaderUtilities.GetRenderingPassList(systemData.surfaceType == SurfaceType.Opaque, enabledFeatures == Features.Unlit); // Show after post process for unlit shaders - var renderingPassValue = systemData.surfaceType == SurfaceType.Opaque ? HDRenderQueue.GetOpaqueEquivalent(systemData.renderingPass) : HDRenderQueue.GetTransparentEquivalent(systemData.renderingPass); + var renderingPassList = HDSubShaderUtilities.GetRenderingPassList(systemData.surfaceType == SurfaceType.Opaque, enabledFeatures == Features.Unlit, hasRefraction); // Show after post process for unlit shaders + var renderingPassValue = systemData.surfaceType == SurfaceType.Opaque ? HDRenderQueue.GetOpaqueEquivalent(systemData.renderQueueType) : HDRenderQueue.GetTransparentEquivalent(systemData.renderQueueType); var renderQueueType = systemData.surfaceType == SurfaceType.Opaque ? HDRenderQueue.RenderQueueType.Opaque : HDRenderQueue.RenderQueueType.Transparent; + context.AddProperty(renderingPassText, new PopupField(renderingPassList, renderQueueType, HDSubShaderUtilities.RenderQueueName, HDSubShaderUtilities.RenderQueueName) { value = renderingPassValue }, (evt) => { registerUndo(renderingPassText); 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 0faba91cd3c..352d913b9be 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 @@ -32,7 +32,7 @@ public BuiltinData builtinData protected override string renderQueue { - get => HDRenderQueue.GetShaderTagValue(HDRenderQueue.ChangeType(systemData.renderingPass, systemData.sortPriority, systemData.alphaTest, false)); + get => HDRenderQueue.GetShaderTagValue(HDRenderQueue.ChangeType(systemData.renderQueueType, systemData.sortPriority, systemData.alphaTest, false)); } protected override string templatePath => $"{HDUtils.GetHDRenderPipelinePath()}Editor/Material/ShaderGraph/Templates/ShaderPass.template"; @@ -289,7 +289,7 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera { overrideReferenceName = "_RenderQueueType", hidden = true, - value = (int)systemData.renderingPass, + value = (int)systemData.renderQueueType, }); //See SG-ADDITIONALVELOCITY-NOTE @@ -350,7 +350,7 @@ public override void ProcessPreviewMaterial(Material material) material.SetFloat(kTransparentZWrite, systemData.transparentZWrite ? 1.0f : 0.0f); // No sorting priority for shader graph preview - material.renderQueue = (int)HDRenderQueue.ChangeType(systemData.renderingPass, offset: 0, alphaTest: systemData.alphaTest, false); + material.renderQueue = (int)HDRenderQueue.ChangeType(systemData.renderQueueType, offset: 0, alphaTest: systemData.alphaTest, false); 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 6df41be68da..6068898f463 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 @@ -28,7 +28,7 @@ public SurfaceType surfaceType [SerializeField] RenderQueueType m_RenderingPass = RenderQueueType.Opaque; - public RenderQueueType renderingPass + public RenderQueueType renderQueueType { get => m_RenderingPass; set => m_RenderingPass = value; @@ -165,10 +165,10 @@ public static bool TryChangeRenderingPass(this SystemData systemData, HDRenderQu throw new ArgumentException("Unknown SurfaceType"); } - if (Equals(systemData.renderingPass, value)) + if (Equals(systemData.renderQueueType, value)) return false; - systemData.renderingPass = value; + systemData.renderQueueType = value; return true; } } diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitSubTarget.Migration.cs b/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitSubTarget.Migration.cs index 8a2a368a977..1a433fc948e 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitSubTarget.Migration.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitSubTarget.Migration.cs @@ -27,7 +27,7 @@ public bool TryUpgradeFromMasterNode(IMasterNode1 masterNode, out Dictionary Date: Wed, 14 Oct 2020 17:26:07 +0200 Subject: [PATCH 02/19] Updated changelog --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index dc5b9538800..c3c514a83fd 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -164,6 +164,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed a migration issue with the rendering queue in ShaderGraph when upgrading to 10.x; - Fixed null reference in the Undo callback of the graphics compositor - Fixed cullmode for SceneSelectionPass. +- Fixed the possibility to have a shader with a pre-refraction render queue and refraction enabled at the same time. ### Changed - Preparation pass for RTSSShadows to be supported by render graph. From 915909b1f5887fbdbecde408a9c8d25a123c134e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Wed, 14 Oct 2020 17:28:23 +0200 Subject: [PATCH 03/19] revert change --- .../Material/DiffusionProfile/DiffusionProfileSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/DiffusionProfile/DiffusionProfileSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/Material/DiffusionProfile/DiffusionProfileSettings.cs index 73d76786719..a4583e5a608 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/DiffusionProfile/DiffusionProfileSettings.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/DiffusionProfile/DiffusionProfileSettings.cs @@ -232,7 +232,7 @@ void OnEnable() #if UNITY_EDITOR internal void Reset() { - if (profile != null && profile.hash == 0) + if (profile.hash == 0) { profile.ResetToDefault(); profile.hash = DiffusionProfileHashTable.GenerateUniqueHash(this); From 6c9e11b00edef278328d93cf51bca298a397410f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Wed, 14 Oct 2020 17:46:09 +0200 Subject: [PATCH 04/19] Fixed render queue in the SG UI --- .../Editor/Material/ShaderGraph/SurfaceOptionPropertyBlock.cs | 3 +++ 1 file changed, 3 insertions(+) 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 4bd6961127a..f543fd0b1cd 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 @@ -55,6 +55,9 @@ protected override void CreatePropertyGUI() var renderingPassValue = systemData.surfaceType == SurfaceType.Opaque ? HDRenderQueue.GetOpaqueEquivalent(systemData.renderQueueType) : HDRenderQueue.GetTransparentEquivalent(systemData.renderQueueType); var renderQueueType = systemData.surfaceType == SurfaceType.Opaque ? HDRenderQueue.RenderQueueType.Opaque : HDRenderQueue.RenderQueueType.Transparent; + if (renderingPassValue == HDRenderQueue.RenderQueueType.PreRefraction && hasRefraction) + renderingPassValue = HDRenderQueue.RenderQueueType.Transparent; + context.AddProperty(renderingPassText, new PopupField(renderingPassList, renderQueueType, HDSubShaderUtilities.RenderQueueName, HDSubShaderUtilities.RenderQueueName) { value = renderingPassValue }, (evt) => { registerUndo(renderingPassText); From 4b4f9e05edaa9869c92b6e3b5f86892990028152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Tue, 13 Oct 2020 12:45:59 +0200 Subject: [PATCH 05/19] Fixed render queue migration issue when moving from 8.x to 10.x # Conflicts: # com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitSubTarget.Migration.cs # com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitSubTarget.Migration.cs --- .../ShaderGraph/HDLitSubTarget.Migration.cs | 2 +- .../ShaderGraph/HDUnlitSubTarget.Migration.cs | 2 +- .../Runtime/RenderPipeline/HDRenderQueue.cs | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) 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 5f4a9048e79..8867e5caffa 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 @@ -106,7 +106,7 @@ void UpgradeHDLitMasterNode(HDLitMasterNode1 hdLitMasterNode, out Dictionary Date: Tue, 13 Oct 2020 12:46:43 +0200 Subject: [PATCH 06/19] Updated changelog # Conflicts: # com.unity.render-pipelines.high-definition/CHANGELOG.md --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index c3c514a83fd..9b8bd0907b5 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -161,10 +161,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed the denoising and multi-sample not being used for smooth multibounce RTReflections. - Fixed issue where multiple cameras would cause GC each frame. - Fixed after post process rendering pass options not showing for unlit ShaderGraphs. -- Fixed a migration issue with the rendering queue in ShaderGraph when upgrading to 10.x; - Fixed null reference in the Undo callback of the graphics compositor - Fixed cullmode for SceneSelectionPass. - Fixed the possibility to have a shader with a pre-refraction render queue and refraction enabled at the same time. +- Fixed a migration issue with the rendering queue in ShaderGraph when upgrading to 10.x; ### Changed - Preparation pass for RTSSShadows to be supported by render graph. From b445e6929080ff426d6fdb5a6305c735f25aec54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Wed, 14 Oct 2020 18:41:08 +0200 Subject: [PATCH 07/19] Fix compilation --- .../Editor/Material/Lit/ShaderGraph/HDLitSubTarget.Migration.cs | 2 +- .../Material/Unlit/ShaderGraph/HDUnlitSubTarget.Migration.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 8867e5caffa..0a78e402ab2 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 @@ -106,7 +106,7 @@ void UpgradeHDLitMasterNode(HDLitMasterNode1 hdLitMasterNode, out Dictionary Date: Thu, 15 Oct 2020 11:55:23 +0200 Subject: [PATCH 08/19] Fixed render queue migration from 9.0.0 preview 13 and 33 --- .../Material/Lit/ShaderGraph/HDLitSubTarget.Migration.cs | 2 ++ .../Editor/Material/Lit/ShaderGraph/HDLitSubTarget.cs | 9 --------- .../Material/ShaderGraph/Legacy/HDLitMasterNode1.cs | 1 + 3 files changed, 3 insertions(+), 9 deletions(-) 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 0a78e402ab2..dc6cd33b283 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 @@ -107,6 +107,8 @@ void UpgradeHDLitMasterNode(HDLitMasterNode1 hdLitMasterNode, out Dictionary true; protected override bool requireSplitLighting => litData.materialType == HDLitData.MaterialType.SubsurfaceScattering; - public override void Setup(ref TargetSetupContext ctx) - { - // before we fixed the pre-refraction options, it was possible to enable both refraction and pre-refraction option, so we patch this here. - if (systemData.renderQueueType == HDRenderQueue.RenderQueueType.PreRefraction && litData.refractionModel != ScreenSpaceRefraction.RefractionModel.None) - systemData.renderQueueType = HDRenderQueue.RenderQueueType.Transparent; - - base.Setup(ref ctx); - } - protected override SubShaderDescriptor GetSubShaderDescriptor() { var descriptor = base.GetSubShaderDescriptor(); diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Legacy/HDLitMasterNode1.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Legacy/HDLitMasterNode1.cs index 1bda6d3a24f..15eae5d6dee 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Legacy/HDLitMasterNode1.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Legacy/HDLitMasterNode1.cs @@ -187,5 +187,6 @@ public bool MaterialTypeUsesSlotMask(SlotMask mask) public int m_MaterialNeedsUpdateHash; public string m_ShaderGUIOverride; public bool m_OverrideEnabled; + public bool m_DrawBeforeRefraction; } } From f0d45be9c5ed32f36ee1b4775df64655e0f37328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Thu, 15 Oct 2020 15:06:56 +0200 Subject: [PATCH 09/19] Fixed blend mode not updated whern changing refraction model in SG --- .../Editor/Material/UIBlocks/HDShaderGUI.cs | 2 +- .../Editor/Material/UIBlocks/SurfaceOptionUIBlock.cs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/HDShaderGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/HDShaderGUI.cs index 166412d8318..4720f661732 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/HDShaderGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/HDShaderGUI.cs @@ -88,7 +88,7 @@ public sealed override void OnGUI(MaterialEditor materialEditor, MaterialPropert protected abstract void OnMaterialGUI(MaterialEditor materialEditor, MaterialProperty[] props); readonly static string[] floatPropertiesToSynchronize = { - kUseSplitLighting + kUseSplitLighting, kRefractionModel, }; /// 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 1f513f08406..e0a63400733 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 @@ -481,9 +481,15 @@ void DrawDoubleSidedGUI() void DrawSurfaceGUI() { + float refractionModelValue = refractionModel != null ? refractionModel.floatValue : 0; + + var shader = materials[0].shader; + if (refractionModel != null && shader.IsShaderGraph()) + refractionModelValue = shader.GetPropertyDefaultFloatValue(shader.FindPropertyIndex(kRefractionModel)); + // TODO: does not work with multi-selection bool showBlendModePopup = refractionModel == null - || refractionModel.floatValue == 0 + || refractionModelValue == 0 || materials.All(m => HDRenderQueue.k_RenderQueue_PreRefraction.Contains(m.renderQueue)); SurfaceTypePopup(); From 45d54c2587a13f38550b21f6ca8a39dc4de5553c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Thu, 15 Oct 2020 18:53:31 +0200 Subject: [PATCH 10/19] Updated doc --- .../Documentation~/Lit-Shader.md | 2 ++ .../Lit/ShaderGraph/HDLitSubTarget.cs | 34 ++++++++++++++----- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Lit-Shader.md b/com.unity.render-pipelines.high-definition/Documentation~/Lit-Shader.md index ad5fd4dbb03..9cf75f0c85e 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Lit-Shader.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Lit-Shader.md @@ -69,6 +69,8 @@ To create a new Lit Material, navigate to your Project's Asset window, right-cli Unity exposes this section if you select **Transparent** from the **Surface Type** drop-down. For information on the properties in this section, see the [Surface Type documentation](Surface-Type.md#TransparencyInputs). +:warning: When you enabled the **Refraction**, make sure to use the **Blend Mode** **Alpha**, otherwise the effect will not work as expected. A similar warning will be displayed in the material inspector if you enabled refraction with a **Blend Mode** different than **Alpha**. + ### Emission inputs diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitSubTarget.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitSubTarget.cs index b6375488308..6f77d068c5b 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitSubTarget.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitSubTarget.cs @@ -41,7 +41,7 @@ public HDLitData litData }; protected override string[] templateMaterialDirectories => passTemplateMaterialDirectories; - protected override string customInspector => "Rendering.HighDefinition.LightingShaderGraphGUI"; + protected override string customInspector => "Rendering.HighDefinition.LitShaderGraphGUI"; protected override GUID subTargetAssetGuid => kSubTargetSourceCodeGuid; protected override string postDecalsInclude => "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDecalData.hlsl"; protected override ShaderID shaderID => HDShaderUtils.ShaderID.SG_Lit; @@ -83,10 +83,22 @@ protected override SubShaderDescriptor GetRaytracingSubShaderDescriptor() public static FieldDescriptor SpecularColor = new FieldDescriptor(kMaterial, "SpecularColor", "_MATERIAL_FEATURE_TRANSMISSION 1"); // Refraction - public static FieldDescriptor Refraction = new FieldDescriptor(string.Empty, "Refraction", "_HAS_REFRACTION 1"); - public static FieldDescriptor RefractionBox = new FieldDescriptor(string.Empty, "RefractionBox", "_REFRACTION_PLANE 1"); - public static FieldDescriptor RefractionSphere = new FieldDescriptor(string.Empty, "RefractionSphere", "_REFRACTION_SPHERE 1"); - public static FieldDescriptor RefractionThin = new FieldDescriptor(string.Empty, "RefractionThin", "_REFRACTION_THIN 1"); + public static FieldDescriptor Refraction = new FieldDescriptor(string.Empty, "Refraction", ""); + public static KeywordDescriptor RefractionKeyword = new KeywordDescriptor() + { + displayName = "Refraction Model", + referenceName = "_REFRACTION", + type = KeywordType.Enum, + definition = KeywordDefinition.ShaderFeature, + scope = KeywordScope.Local, + entries = new KeywordEntry[] + { + new KeywordEntry() { displayName = "Off", referenceName = "OFF" }, + new KeywordEntry() { displayName = "Plane", referenceName = "PLANE" }, + new KeywordEntry() { displayName = "Sphere", referenceName = "SPHERE" }, + new KeywordEntry() { displayName = "Thin", referenceName = "THIN" }, + } + }; public override void GetFields(ref TargetFieldContext context) { @@ -111,9 +123,6 @@ public override void GetFields(ref TargetFieldContext context) // Refraction context.AddField(Refraction, hasRefraction); - context.AddField(RefractionBox, hasRefraction && litData.refractionModel == ScreenSpaceRefraction.RefractionModel.Box); - context.AddField(RefractionSphere, hasRefraction && litData.refractionModel == ScreenSpaceRefraction.RefractionModel.Sphere); - context.AddField(RefractionThin, hasRefraction && litData.refractionModel == ScreenSpaceRefraction.RefractionModel.Thin); // Misc context.AddField(EnergyConservingSpecular, litData.energyConservingSpecular); @@ -166,13 +175,20 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera // Refraction model property allow the material inspector to check if refraction is enabled in the shader. collector.AddShaderProperty(new Vector1ShaderProperty{ - floatType = FloatType.Default, + floatType = FloatType.Enum, hidden = true, value = (int)litData.refractionModel, + enumNames = Enum.GetNames(typeof(ScreenSpaceRefraction.RefractionModel)).ToList(), overrideReferenceName = kRefractionModel, }); } + protected override void CollectPassKeywords(ref PassDescriptor pass) + { + base.CollectPassKeywords(ref pass); + pass.keywords.Add(RefractionKeyword); + } + protected override void AddInspectorPropertyBlocks(SubTargetPropertiesGUI blockList) { var features = SurfaceOptionPropertyBlock.Features.Lit | (litData.refractionModel != ScreenSpaceRefraction.RefractionModel.None ? SurfaceOptionPropertyBlock.Features.HasRefraction : 0); From 7848287d0a6ca4a254bb23229f21fb743d118d4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Thu, 15 Oct 2020 18:54:26 +0200 Subject: [PATCH 11/19] Exposed refraction model in the material (only available when refraction is enabled in SG) --- .../Lit/ShaderGraph/ShaderPass.template.hlsl | 2 +- .../ShaderPassDefine.template.hlsl | 1 - .../Editor/Material/UIBlocks/HDShaderGUI.cs | 2 +- .../UIBlocks/LightingShaderGraphGUI.cs | 8 ++- .../Material/UIBlocks/LitShaderGraphGUI.cs | 44 ++++++++++++ .../UIBlocks/LitShaderGraphGUI.cs.meta | 11 +++ .../Material/UIBlocks/RefractionUIBlock.cs | 68 ++++++++++--------- .../Material/UIBlocks/SurfaceOptionUIBlock.cs | 15 +--- .../Material/UIBlocks/TransparencyUIBlock.cs | 10 +++ .../Editor/RenderPipeline/HDShaderUtils.cs | 2 +- 10 files changed, 112 insertions(+), 51 deletions(-) create mode 100644 com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LitShaderGraphGUI.cs create mode 100644 com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LitShaderGraphGUI.cs.meta diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/ShaderPass.template.hlsl b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/ShaderPass.template.hlsl index c5083be338f..a845c0a3a31 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/ShaderPass.template.hlsl +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/ShaderPass.template.hlsl @@ -20,7 +20,7 @@ void BuildSurfaceData(FragInputs fragInputs, inout SurfaceDescription surfaceDes $SurfaceDescription.IridescenceMask: surfaceData.iridescenceMask = surfaceDescription.IridescenceMask; $SurfaceDescription.IridescenceThickness: surfaceData.iridescenceThickness = surfaceDescription.IridescenceThickness; - #ifdef _HAS_REFRACTION + #if defined(_REFRACTION_PLANE) || defined(_REFRACTION_SPHERE) || defined(_REFRACTION_THIN) if (_EnableSSRefraction) { $SurfaceDescription.RefractionIndex: surfaceData.ior = surfaceDescription.RefractionIndex; diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/ShaderPassDefine.template.hlsl b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/ShaderPassDefine.template.hlsl index 4669984154c..9b0f6eaad96 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/ShaderPassDefine.template.hlsl +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/ShaderPassDefine.template.hlsl @@ -10,7 +10,6 @@ $SpecularOcclusionFromAOBentNormal: #define _SPECULAR_OCCLUSION_FROM_AO_BENT_NOR $SpecularOcclusionCustom: #define _SPECULAR_OCCLUSION_CUSTOM 1 $Specular.EnergyConserving: #define _ENERGY_CONSERVING_SPECULAR 1 $Specular.AA: #define _ENABLE_GEOMETRIC_SPECULAR_AA 1 -$Refraction: #define _HAS_REFRACTION 1 $RefractionBox: #define _REFRACTION_PLANE 1 $RefractionSphere: #define _REFRACTION_SPHERE 1 $RefractionThin: #define _REFRACTION_THIN 1 diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/HDShaderGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/HDShaderGUI.cs index 4720f661732..6e52ad39e48 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/HDShaderGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/HDShaderGUI.cs @@ -88,7 +88,7 @@ public sealed override void OnGUI(MaterialEditor materialEditor, MaterialPropert protected abstract void OnMaterialGUI(MaterialEditor materialEditor, MaterialProperty[] props); readonly static string[] floatPropertiesToSynchronize = { - kUseSplitLighting, kRefractionModel, + kUseSplitLighting, }; /// diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LightingShaderGraphGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LightingShaderGraphGUI.cs index 96a23f8c2ec..9e8eb3d643b 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LightingShaderGraphGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LightingShaderGraphGUI.cs @@ -15,13 +15,15 @@ internal class LightingShaderGraphGUI : HDShaderGUI const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Lit | SurfaceOptionUIBlock.Features.ShowDepthOffsetOnly; - MaterialUIBlockList uiBlocks = new MaterialUIBlockList + MaterialUIBlockList m_UIBlocks = new MaterialUIBlockList { new SurfaceOptionUIBlock(MaterialUIBlock.Expandable.Base, features: surfaceOptionFeatures), new ShaderGraphUIBlock(MaterialUIBlock.Expandable.ShaderGraph), new AdvancedOptionsUIBlock(MaterialUIBlock.Expandable.Advance, ~AdvancedOptionsUIBlock.Features.SpecularOcclusion) }; + protected MaterialUIBlockList uiBlocks => m_UIBlocks; + /// /// Implement your custom GUI in this function. To display a UI similar to HDRP shaders, use a MaterialUIBlock. /// @@ -31,8 +33,8 @@ protected override void OnMaterialGUI(MaterialEditor materialEditor, MaterialPro { using (var changed = new EditorGUI.ChangeCheckScope()) { - uiBlocks.OnGUI(materialEditor, props); - ApplyKeywordsAndPassesIfNeeded(changed.changed, uiBlocks.materials); + m_UIBlocks.OnGUI(materialEditor, props); + ApplyKeywordsAndPassesIfNeeded(changed.changed, m_UIBlocks.materials); } } diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LitShaderGraphGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LitShaderGraphGUI.cs new file mode 100644 index 00000000000..9dd85f195ab --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LitShaderGraphGUI.cs @@ -0,0 +1,44 @@ +using UnityEngine; +using UnityEngine.Rendering; + +// Include material common properties names +using static UnityEngine.Rendering.HighDefinition.HDMaterialProperties; + +namespace UnityEditor.Rendering.HighDefinition +{ + /// + /// Material GUI for Lit ShaderGraph + /// + internal class LitShaderGraphGUI : LightingShaderGraphGUI + { + public LitShaderGraphGUI() + { + // Lit SG have refraction block + uiBlocks.Insert(1, new TransparencyUIBlock(MaterialUIBlock.Expandable.Transparency, TransparencyUIBlock.Features.Refraction)); + } + + /// + /// Sets up the keywords and passes for a Lit Shader Graph material. + /// + /// The target material. + public static void SetupMaterialKeywordsAndPass(Material material) + { + SynchronizeShaderGraphProperties(material); + + LitGUI.SetupMaterialKeywordsAndPass(material); + + bool receiveSSR = false; + if (material.GetSurfaceType() == SurfaceType.Transparent) + 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; + 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/UIBlocks/LitShaderGraphGUI.cs.meta b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LitShaderGraphGUI.cs.meta new file mode 100644 index 00000000000..223f2f3c9a6 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LitShaderGraphGUI.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 17883c55a4d63b147afb769cdcfd80d7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/RefractionUIBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/RefractionUIBlock.cs index 4fc93e041e9..07c7e12e56d 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/RefractionUIBlock.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/RefractionUIBlock.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using UnityEngine; +using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; using System.Linq; @@ -25,8 +26,6 @@ internal static class Styles protected MaterialProperty refractionModel = null; protected const string kRefractionModel = "_RefractionModel"; - protected MaterialProperty ssrefractionProjectionModel = null; - protected const string kSSRefractionProjectionModel = "_SSRefractionProjectionModel"; protected MaterialProperty atDistance = null; protected const string kATDistance = "_ATDistance"; protected MaterialProperty[] thickness = null; @@ -41,6 +40,7 @@ internal static class Styles protected const string kTransmittanceColorMap = "_TransmittanceColorMap"; protected MaterialProperty transmittanceColor = null; protected const string kTransmittanceColor = "_TransmittanceColor"; + protected MaterialProperty blendMode = null; int m_LayerCount; @@ -52,13 +52,13 @@ public RefractionUIBlock(int layerCount) public override void LoadMaterialProperties() { refractionModel = FindProperty(kRefractionModel, false); - ssrefractionProjectionModel = FindProperty(kSSRefractionProjectionModel, false); atDistance = FindProperty(kATDistance, false); transmittanceColorMap = FindProperty(kTransmittanceColorMap, false); transmittanceColor = FindProperty(kTransmittanceColor, false); thicknessMap = FindPropertyLayered(kThicknessMap, m_LayerCount, false); thickness = FindPropertyLayered(kThickness, m_LayerCount, false); thicknessRemap = FindPropertyLayered(kThicknessRemap, m_LayerCount, false); + blendMode = FindProperty(kBlendMode, false); ior = FindProperty(kIor, false); } @@ -77,49 +77,55 @@ public override void OnGUI() case ScreenSpaceRefraction.RefractionModel.Box: case ScreenSpaceRefraction.RefractionModel.Sphere: { - materialEditor.ShaderProperty(ior, Styles.refractionIorText); - // TODO: change check - foreach (var material in materials) - { - // TODO - // material.SetBlendMode(BlendMode.Alpha); - // blendMode.floatValue = (float)BlendMode.Alpha; - } + if (ior != null) + materialEditor.ShaderProperty(ior, Styles.refractionIorText); - if (thicknessMap[0].textureValue == null) - { - materialEditor.TexturePropertySingleLine(Styles.refractionThicknessText, thicknessMap[0], thickness[0]); - } - else + if (thicknessMap[0] != null) { - materialEditor.TexturePropertySingleLine(Styles.refractionThicknessMapText, thicknessMap[0]); - // Display the remap of texture values. - Vector2 remap = thicknessRemap[0].vectorValue; - EditorGUI.BeginChangeCheck(); - EditorGUILayout.MinMaxSlider(Styles.refractionThicknessRemappingText, ref remap.x, ref remap.y, 0.0f, 1.0f); - if (EditorGUI.EndChangeCheck()) + if (thicknessMap[0].textureValue == null) + { + materialEditor.TexturePropertySingleLine(Styles.refractionThicknessText, thicknessMap[0], thickness[0]); + } + else { - thicknessRemap[0].vectorValue = remap; + materialEditor.TexturePropertySingleLine(Styles.refractionThicknessMapText, thicknessMap[0]); + // Display the remap of texture values. + Vector2 remap = thicknessRemap[0].vectorValue; + EditorGUI.BeginChangeCheck(); + EditorGUILayout.MinMaxSlider(Styles.refractionThicknessRemappingText, ref remap.x, ref remap.y, 0.0f, 1.0f); + if (EditorGUI.EndChangeCheck()) + { + thicknessRemap[0].vectorValue = remap; + } } } - - materialEditor.TexturePropertySingleLine(Styles.transmittanceColorText, transmittanceColorMap, transmittanceColor); - ++EditorGUI.indentLevel; - materialEditor.ShaderProperty(atDistance, Styles.atDistanceText); - atDistance.floatValue = Mathf.Max(atDistance.floatValue, 0); - --EditorGUI.indentLevel; + if (transmittanceColorMap != null) + { + materialEditor.TexturePropertySingleLine(Styles.transmittanceColorText, transmittanceColorMap, transmittanceColor); + ++EditorGUI.indentLevel; + materialEditor.ShaderProperty(atDistance, Styles.atDistanceText); + atDistance.floatValue = Mathf.Max(atDistance.floatValue, 0); + --EditorGUI.indentLevel; + } } break; case ScreenSpaceRefraction.RefractionModel.Thin: { - materialEditor.ShaderProperty(ior, Styles.refractionIorText); - materialEditor.TexturePropertySingleLine(Styles.transmittanceColorText, transmittanceColorMap, transmittanceColor); + if (ior != null) + materialEditor.ShaderProperty(ior, Styles.refractionIorText); + if (transmittanceColorMap != null) + materialEditor.TexturePropertySingleLine(Styles.transmittanceColorText, transmittanceColorMap, transmittanceColor); } break; default: break; } + + if (refractionModel.floatValue != 0 && blendMode != null && blendMode.floatValue != (int)BlendMode.Alpha) + { + EditorGUILayout.HelpBox("Refraction is only support with the Blend Mode value Alpha. Please set the Blend Mode to Alpha in the Surface Options to remove this mesage.", MessageType.Warning); + } } } } 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 e0a63400733..92ba9532f08 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 @@ -481,17 +481,6 @@ void DrawDoubleSidedGUI() void DrawSurfaceGUI() { - float refractionModelValue = refractionModel != null ? refractionModel.floatValue : 0; - - var shader = materials[0].shader; - if (refractionModel != null && shader.IsShaderGraph()) - refractionModelValue = shader.GetPropertyDefaultFloatValue(shader.FindPropertyIndex(kRefractionModel)); - - // TODO: does not work with multi-selection - bool showBlendModePopup = refractionModel == null - || refractionModelValue == 0 - || materials.All(m => HDRenderQueue.k_RenderQueue_PreRefraction.Contains(m.renderQueue)); - SurfaceTypePopup(); if (surfaceTypeValue == SurfaceType.Transparent) @@ -511,7 +500,7 @@ void DrawSurfaceGUI() using (new EditorGUI.DisabledScope(true)) EditorGUILayout.LabelField(Styles.blendModeText, Styles.notSupportedInMultiEdition); } - else if (blendMode != null && showBlendModePopup) + else if (blendMode != null) BlendModePopup(); if ((m_Features & Features.PreserveSpecularLighting) != 0) @@ -521,7 +510,7 @@ void DrawSurfaceGUI() using (new EditorGUI.DisabledScope(true)) EditorGUILayout.LabelField(Styles.enableBlendModePreserveSpecularLightingText, Styles.notSupportedInMultiEdition); } - else if (enableBlendModePreserveSpecularLighting != null && blendMode != null && showBlendModePopup) + else if (enableBlendModePreserveSpecularLighting != null && blendMode != null) materialEditor.ShaderProperty(enableBlendModePreserveSpecularLighting, Styles.enableBlendModePreserveSpecularLightingText); EditorGUI.indentLevel--; } diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/TransparencyUIBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/TransparencyUIBlock.cs index 7161c860cc0..134d69f6140 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/TransparencyUIBlock.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/TransparencyUIBlock.cs @@ -3,6 +3,7 @@ using UnityEngine; using UnityEngine.Rendering.HighDefinition; using System.Linq; +using UnityEditor.ShaderGraph; // Include material common properties names using static UnityEngine.Rendering.HighDefinition.HDMaterialProperties; @@ -49,6 +50,15 @@ public override void OnGUI() if (materials.Any(material => material.GetSurfaceType() != SurfaceType.Transparent)) return ; + // If refraction model is not enabled in SG, we don't show the section + var shader = materials[0].shader; + if (shader.IsShaderGraph()) + { + var defaultRefractionModel = shader.GetPropertyDefaultFloatValue(shader.FindPropertyIndex(kRefractionModel)); + if (defaultRefractionModel == 0) + return; + } + using (var header = new MaterialHeaderScope(Styles.header, (uint)m_ExpandableBit, materialEditor)) { if (header.expanded) 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 16857c1db3c..0512cc5718a 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDShaderUtils.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDShaderUtils.cs @@ -64,7 +64,7 @@ internal enum ShaderID { ShaderID.TerrainLit, TerrainLitGUI.SetupMaterialKeywordsAndPass }, { ShaderID.AxF, AxFGUI.SetupMaterialKeywordsAndPass }, { ShaderID.SG_Unlit, HDUnlitGUI.SetupMaterialKeywordsAndPass }, - { ShaderID.SG_Lit, LightingShaderGraphGUI.SetupMaterialKeywordsAndPass }, + { ShaderID.SG_Lit, LitShaderGraphGUI.SetupMaterialKeywordsAndPass }, { ShaderID.SG_Hair, LightingShaderGraphGUI.SetupMaterialKeywordsAndPass }, { ShaderID.SG_Fabric, LightingShaderGraphGUI.SetupMaterialKeywordsAndPass }, { ShaderID.SG_StackLit, LightingShaderGraphGUI.SetupMaterialKeywordsAndPass }, From 90d8a101246b3bff3ad9df4cb515b4d84ef323c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Thu, 15 Oct 2020 18:54:39 +0200 Subject: [PATCH 12/19] Cleanup --- .../Runtime/Material/Lit/Lit.shader | 1 - .../Runtime/Material/Lit/LitTessellation.shader | 1 - 2 files changed, 2 deletions(-) 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 dca1e9f2cd8..89876ecb300 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 @@ -118,7 +118,6 @@ Shader "HDRP/Lit" // Transparency [Enum(None, 0, Box, 1, Sphere, 2, Thin, 3)]_RefractionModel("Refraction Model", Int) = 0 - [Enum(Proxy, 1, HiZ, 2)]_SSRefractionProjectionModel("Refraction Projection Model", Int) = 0 _Ior("Index Of Refraction", Range(1.0, 2.5)) = 1.5 _TransmittanceColor("Transmittance Color", Color) = (1.0, 1.0, 1.0) _TransmittanceColorMap("TransmittanceColorMap", 2D) = "white" {} 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 ae72203e1ca..12a50247bdc 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 @@ -120,7 +120,6 @@ Shader "HDRP/LitTessellation" // Transparency [Enum(None, 0, Box, 1, Sphere, 2, Thin, 3)]_RefractionModel("Refraction Model", Int) = 0 - [Enum(Proxy, 1, HiZ, 2)]_SSRefractionProjectionModel("Refraction Projection Model", Int) = 0 _Ior("Index Of Refraction", Range(1.0, 2.5)) = 1.0 _ThicknessMultiplier("Thickness Multiplier", Float) = 1.0 _TransmittanceColor("Transmittance Color", Color) = (1.0, 1.0, 1.0) From b9aad02bfc532d5a920657ffc4f2390c4351ac95 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Thu, 15 Oct 2020 21:21:38 +0200 Subject: [PATCH 13/19] Update LitShaderGraphGUI.cs --- .../Editor/Material/UIBlocks/LitShaderGraphGUI.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LitShaderGraphGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LitShaderGraphGUI.cs index 9dd85f195ab..1f4f41331ca 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LitShaderGraphGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LitShaderGraphGUI.cs @@ -21,7 +21,7 @@ public LitShaderGraphGUI() /// Sets up the keywords and passes for a Lit Shader Graph material. /// /// The target material. - public static void SetupMaterialKeywordsAndPass(Material material) + new public static void SetupMaterialKeywordsAndPass(Material material) { SynchronizeShaderGraphProperties(material); From 33f254095f734d7ca8091ca4a340b40b49224fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Fri, 16 Oct 2020 11:22:45 +0200 Subject: [PATCH 14/19] Added warning in the SG inspector + fixed nullref --- .../Editor/Material/Lit/BaseLitGUI.cs | 10 ++++++++ .../Editor/Material/Lit/LitGUI.cs | 5 ---- .../LitSurfaceOptionPropertyBlock.cs | 2 ++ .../ShaderGraph/SubTargetPropertyBlock.cs | 16 +++++++++++++ .../Material/UIBlocks/LitShaderGraphGUI.cs | 24 ------------------- .../Material/UIBlocks/RefractionUIBlock.cs | 3 ++- 6 files changed, 30 insertions(+), 30 deletions(-) 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 6dd24d1203d..fa7e6603464 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 @@ -93,6 +93,16 @@ static public void SetupBaseLitKeywords(Material material) CoreUtils.SetKeyword(material, "_DISABLE_SSR", material.HasProperty(kReceivesSSR) && material.GetFloat(kReceivesSSR) == 0.0); CoreUtils.SetKeyword(material, "_DISABLE_SSR_TRANSPARENT", material.HasProperty(kReceivesSSRTransparent) && material.GetFloat(kReceivesSSRTransparent) == 0.0); CoreUtils.SetKeyword(material, "_ENABLE_GEOMETRIC_SPECULAR_AA", material.HasProperty(kEnableGeometricSpecularAA) && material.GetFloat(kEnableGeometricSpecularAA) == 1.0); + + if (material.HasProperty(kRefractionModel)) + { + var refractionModelValue = (ScreenSpaceRefraction.RefractionModel)material.GetFloat(kRefractionModel); + // We can't have refraction in pre-refraction queue and the material needs to be transparent + var canHaveRefraction = material.GetSurfaceType() == SurfaceType.Transparent && !HDRenderQueue.k_RenderQueue_PreRefraction.Contains(material.renderQueue); + CoreUtils.SetKeyword(material, "_REFRACTION_PLANE", (refractionModelValue == ScreenSpaceRefraction.RefractionModel.Box) && canHaveRefraction); + CoreUtils.SetKeyword(material, "_REFRACTION_SPHERE", (refractionModelValue == ScreenSpaceRefraction.RefractionModel.Sphere) && canHaveRefraction); + CoreUtils.SetKeyword(material, "_REFRACTION_THIN", (refractionModelValue == ScreenSpaceRefraction.RefractionModel.Thin) && canHaveRefraction); + } } static public void SetupStencil(Material material, bool receivesSSR, bool useSplitLighting) 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 4fb6f12bd29..46782df6360 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 @@ -187,12 +187,7 @@ static public void SetupMaterialKeywordsAndPass(Material material) if (material.HasProperty(kRefractionModel)) { - var refractionModelValue = (ScreenSpaceRefraction.RefractionModel)material.GetFloat(kRefractionModel); - // We can't have refraction in pre-refraction queue and the material needs to be transparent var canHaveRefraction = material.GetSurfaceType() == SurfaceType.Transparent && !HDRenderQueue.k_RenderQueue_PreRefraction.Contains(material.renderQueue); - CoreUtils.SetKeyword(material, "_REFRACTION_PLANE", (refractionModelValue == ScreenSpaceRefraction.RefractionModel.Box) && canHaveRefraction); - CoreUtils.SetKeyword(material, "_REFRACTION_SPHERE", (refractionModelValue == ScreenSpaceRefraction.RefractionModel.Sphere) && canHaveRefraction); - CoreUtils.SetKeyword(material, "_REFRACTION_THIN", (refractionModelValue == ScreenSpaceRefraction.RefractionModel.Thin) && canHaveRefraction); CoreUtils.SetKeyword(material, "_TRANSMITTANCECOLORMAP", material.GetTexture(kTransmittanceColorMap) && canHaveRefraction); } diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/LitSurfaceOptionPropertyBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/LitSurfaceOptionPropertyBlock.cs index 3e6ac6879cb..429f9633f3b 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/LitSurfaceOptionPropertyBlock.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/LitSurfaceOptionPropertyBlock.cs @@ -42,6 +42,8 @@ protected override void CreatePropertyGUI() if (systemData.surfaceType == SurfaceType.Transparent) { AddProperty(refractionModelText, () => litData.refractionModel, (newValue) => litData.refractionModel = newValue); + if (litData.refractionModel != ScreenSpaceRefraction.RefractionModel.None && systemData.blendMode != BlendMode.Alpha) + AddHelpBox(RefractionUIBlock.Styles.refractionBlendModeWarning, MessageType.Warning); } if (litData.materialType == HDLitData.MaterialType.SpecularColor) { diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SubTargetPropertyBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SubTargetPropertyBlock.cs index 65991f1ff68..db21527273a 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SubTargetPropertyBlock.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SubTargetPropertyBlock.cs @@ -113,6 +113,22 @@ protected void AddFoldout(GUIContent content, Func getter, Action se context.Add(foldout); } + protected void AddHelpBox(string message, MessageType type) + { + // We don't use UIElement HelpBox because it's width is not dynamic. + int indentLevel = context.globalIndentLevel; + var imgui = new IMGUIContainer(() => + { + float indentPadding = indentLevel * 15; + var rect = EditorGUILayout.GetControlRect(false, 42); + rect.x += indentPadding; + rect.width -= indentPadding; + EditorGUI.HelpBox(rect, message, type); + }); + + context.Add(imgui); + } + public void CreatePropertyGUIWithHeader() { if (!String.IsNullOrEmpty(title)) diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LitShaderGraphGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LitShaderGraphGUI.cs index 9dd85f195ab..467d4358de9 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LitShaderGraphGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LitShaderGraphGUI.cs @@ -16,29 +16,5 @@ public LitShaderGraphGUI() // Lit SG have refraction block uiBlocks.Insert(1, new TransparencyUIBlock(MaterialUIBlock.Expandable.Transparency, TransparencyUIBlock.Features.Refraction)); } - - /// - /// Sets up the keywords and passes for a Lit Shader Graph material. - /// - /// The target material. - public static void SetupMaterialKeywordsAndPass(Material material) - { - SynchronizeShaderGraphProperties(material); - - LitGUI.SetupMaterialKeywordsAndPass(material); - - bool receiveSSR = false; - if (material.GetSurfaceType() == SurfaceType.Transparent) - 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; - 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/UIBlocks/RefractionUIBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/RefractionUIBlock.cs index 07c7e12e56d..5955e908524 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/RefractionUIBlock.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/RefractionUIBlock.cs @@ -22,6 +22,7 @@ internal static class Styles public static GUIContent thicknessMapText = new GUIContent("Thickness Map", "Specifies the Thickness Map (R) for this Material - This map describes the thickness of the object. When subsurface scattering is enabled, low values allow some light to transmit through the object."); public static GUIContent transmittanceColorText = new GUIContent("Transmittance Color", "Specifies the Transmittance Color (RGB) for this Material."); public static GUIContent atDistanceText = new GUIContent("Transmittance Absorption Distance", "Sets the absorption distance reference in meters."); + public static string refractionBlendModeWarning = "Refraction is only supported with the Blend Mode value Alpha. Please, set the Blend Mode to Alpha in the Surface Options to hide this mesage."; } protected MaterialProperty refractionModel = null; @@ -124,7 +125,7 @@ public override void OnGUI() if (refractionModel.floatValue != 0 && blendMode != null && blendMode.floatValue != (int)BlendMode.Alpha) { - EditorGUILayout.HelpBox("Refraction is only support with the Blend Mode value Alpha. Please set the Blend Mode to Alpha in the Surface Options to remove this mesage.", MessageType.Warning); + EditorGUILayout.HelpBox(Styles.refractionBlendModeWarning, MessageType.Warning); } } } From 8549991b16b656fc2b7fb96d34545684d93fcf99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Fri, 16 Oct 2020 12:56:02 +0200 Subject: [PATCH 15/19] Added material migration function and bumped last material version in project settings --- .../ProjectSettings/HDRPProjectSettings.asset | 2 +- .../ProjectSettings/HDRPProjectSettings.asset | 2 +- .../ProjectSettings/HDRPProjectSettings.asset | 2 +- .../ProjectSettings/HDRPProjectSettings.asset | 2 +- .../HDRP_Tests/ProjectSettings/HDRPProjectSettings.asset | 2 +- .../ProjectSettings/HDRPProjectSettings.asset | 2 +- .../ProjectSettings/HDRPProjectSettings.asset | 2 +- .../Editor/AssetProcessors/MaterialPostProcessor.cs | 8 ++++++++ .../ProjectSettings/HDRPProjectSettings.asset | 2 +- 9 files changed, 16 insertions(+), 8 deletions(-) diff --git a/TestProjects/HDRP_DXR_Tests/ProjectSettings/HDRPProjectSettings.asset b/TestProjects/HDRP_DXR_Tests/ProjectSettings/HDRPProjectSettings.asset index e73d726d944..ac213ba68ad 100644 --- a/TestProjects/HDRP_DXR_Tests/ProjectSettings/HDRPProjectSettings.asset +++ b/TestProjects/HDRP_DXR_Tests/ProjectSettings/HDRPProjectSettings.asset @@ -19,4 +19,4 @@ MonoBehaviour: m_WizardActiveTab: 0 m_WizardNeedRestartAfterChangingToDX12: 0 m_WizardNeedToRunFixAllAgainAfterDomainReload: 0 - m_LastMaterialVersion: 9 + m_LastMaterialVersion: 10 diff --git a/TestProjects/HDRP_HybridTests/ProjectSettings/HDRPProjectSettings.asset b/TestProjects/HDRP_HybridTests/ProjectSettings/HDRPProjectSettings.asset index 5d3fef2b636..652258d83b0 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: 9 + m_LastMaterialVersion: 10 diff --git a/TestProjects/HDRP_PerformanceTests/ProjectSettings/HDRPProjectSettings.asset b/TestProjects/HDRP_PerformanceTests/ProjectSettings/HDRPProjectSettings.asset index e73d726d944..ac213ba68ad 100644 --- a/TestProjects/HDRP_PerformanceTests/ProjectSettings/HDRPProjectSettings.asset +++ b/TestProjects/HDRP_PerformanceTests/ProjectSettings/HDRPProjectSettings.asset @@ -19,4 +19,4 @@ MonoBehaviour: m_WizardActiveTab: 0 m_WizardNeedRestartAfterChangingToDX12: 0 m_WizardNeedToRunFixAllAgainAfterDomainReload: 0 - m_LastMaterialVersion: 9 + m_LastMaterialVersion: 10 diff --git a/TestProjects/HDRP_RuntimeTests/ProjectSettings/HDRPProjectSettings.asset b/TestProjects/HDRP_RuntimeTests/ProjectSettings/HDRPProjectSettings.asset index 3ea8dc4cf74..0355a620489 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: 9 + m_LastMaterialVersion: 10 diff --git a/TestProjects/HDRP_Tests/ProjectSettings/HDRPProjectSettings.asset b/TestProjects/HDRP_Tests/ProjectSettings/HDRPProjectSettings.asset index 2c7a9051eac..40a40448d38 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: 9 + m_LastMaterialVersion: 10 diff --git a/TestProjects/SRP_SmokeTest/ProjectSettings/HDRPProjectSettings.asset b/TestProjects/SRP_SmokeTest/ProjectSettings/HDRPProjectSettings.asset index c479d53f6b3..3f61d8b8e10 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: 9 + m_LastMaterialVersion: 10 diff --git a/TestProjects/VisualEffectGraph_HDRP/ProjectSettings/HDRPProjectSettings.asset b/TestProjects/VisualEffectGraph_HDRP/ProjectSettings/HDRPProjectSettings.asset index e73d726d944..ac213ba68ad 100644 --- a/TestProjects/VisualEffectGraph_HDRP/ProjectSettings/HDRPProjectSettings.asset +++ b/TestProjects/VisualEffectGraph_HDRP/ProjectSettings/HDRPProjectSettings.asset @@ -19,4 +19,4 @@ MonoBehaviour: m_WizardActiveTab: 0 m_WizardNeedRestartAfterChangingToDX12: 0 m_WizardNeedToRunFixAllAgainAfterDomainReload: 0 - m_LastMaterialVersion: 9 + m_LastMaterialVersion: 10 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 e2d795010fa..b7c08f9f645 100644 --- a/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/MaterialPostProcessor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/MaterialPostProcessor.cs @@ -201,6 +201,7 @@ static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAsse MigrateDecalRenderQueue, ExposedDecalInputsFromShaderGraph, FixIncorrectEmissiveColorSpace, + ExposeRefraction, }; #region Migrations @@ -590,6 +591,13 @@ static void FixIncorrectEmissiveColorSpace(Material material, HDShaderUtils.Shad } } + static void ExposeRefraction(Material material, HDShaderUtils.ShaderID id) + { + // Lit SG now have a shader feature for refraction instead of an hardcoded material + if (id == HDShaderUtils.ShaderID.SG_Lit) + 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.template-hd/ProjectSettings/HDRPProjectSettings.asset b/com.unity.template-hd/ProjectSettings/HDRPProjectSettings.asset index e73d726d944..ac213ba68ad 100644 --- a/com.unity.template-hd/ProjectSettings/HDRPProjectSettings.asset +++ b/com.unity.template-hd/ProjectSettings/HDRPProjectSettings.asset @@ -19,4 +19,4 @@ MonoBehaviour: m_WizardActiveTab: 0 m_WizardNeedRestartAfterChangingToDX12: 0 m_WizardNeedToRunFixAllAgainAfterDomainReload: 0 - m_LastMaterialVersion: 9 + m_LastMaterialVersion: 10 From b6762136ff3285e8347259ad9307fee7485bbf08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Fri, 16 Oct 2020 14:23:27 +0200 Subject: [PATCH 16/19] Fix refraction model in material upgrade --- .../Editor/AssetProcessors/MaterialPostProcessor.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 b7c08f9f645..3434746521b 100644 --- a/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/MaterialPostProcessor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/MaterialPostProcessor.cs @@ -595,7 +595,17 @@ static void ExposeRefraction(Material material, HDShaderUtils.ShaderID id) { // Lit SG now have a shader feature for refraction instead of an hardcoded material if (id == HDShaderUtils.ShaderID.SG_Lit) + { + // Sync the default refraction model from the shader graph to the shader + // We need to do this because the material may already have a refraction model information (from the Lit) + // In order to not break the rendering of the material, we patch the refraction model: + if (material.HasProperty(kRefractionModel)) + { + var refractionModel = material.shader.GetPropertyDefaultFloatValue(material.shader.FindPropertyIndex(kRefractionModel)); + material.SetFloat(kRefractionModel, refractionModel); + } HDShaderUtils.ResetMaterialKeywords(material); + } } #region Serialization_API From 42210ff6287ffa9c321ac8474a9714f13e9ff40d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Tue, 20 Oct 2020 16:22:15 +0200 Subject: [PATCH 17/19] Added a warning when refraction is enabled with pre-refraciton rendering pass --- .../Documentation~/Lit-Shader.md | 2 ++ .../Lit/ShaderGraph/HDLitSubTarget.cs | 3 +- .../Lit/ShaderGraph/LitPropertyBlock.cs | 32 ------------------- .../Lit/ShaderGraph/LitPropertyBlock.cs.meta | 11 ------- .../LitSurfaceOptionPropertyBlock.cs | 9 ++++-- .../ShaderGraph/HDSubShaderUtilities.cs | 5 ++- .../ShaderGraph/SurfaceOptionPropertyBlock.cs | 12 ++----- .../Material/UIBlocks/RefractionUIBlock.cs | 21 ++++++++---- .../Material/UIBlocks/SurfaceOptionUIBlock.cs | 2 +- 9 files changed, 29 insertions(+), 68 deletions(-) delete mode 100644 com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/LitPropertyBlock.cs delete mode 100644 com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/LitPropertyBlock.cs.meta diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Lit-Shader.md b/com.unity.render-pipelines.high-definition/Documentation~/Lit-Shader.md index 9cf75f0c85e..76b6cf5dcae 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Lit-Shader.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Lit-Shader.md @@ -71,6 +71,8 @@ Unity exposes this section if you select **Transparent** from the **Surface Type :warning: When you enabled the **Refraction**, make sure to use the **Blend Mode** **Alpha**, otherwise the effect will not work as expected. A similar warning will be displayed in the material inspector if you enabled refraction with a **Blend Mode** different than **Alpha**. +You can also note that Refraction is not supported when using the rendering pass **Pre-Refraction**, a warning about it will show up in the material inspector and shader graph inspector in case your setup is incorrect. + ### Emission inputs diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitSubTarget.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitSubTarget.cs index 6f77d068c5b..4c57c1b55b7 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitSubTarget.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitSubTarget.cs @@ -191,8 +191,7 @@ protected override void CollectPassKeywords(ref PassDescriptor pass) protected override void AddInspectorPropertyBlocks(SubTargetPropertiesGUI blockList) { - var features = SurfaceOptionPropertyBlock.Features.Lit | (litData.refractionModel != ScreenSpaceRefraction.RefractionModel.None ? SurfaceOptionPropertyBlock.Features.HasRefraction : 0); - blockList.AddPropertyBlock(new LitSurfaceOptionPropertyBlock(features, litData)); + blockList.AddPropertyBlock(new LitSurfaceOptionPropertyBlock(SurfaceOptionPropertyBlock.Features.Lit, litData)); if (systemData.surfaceType == SurfaceType.Transparent) blockList.AddPropertyBlock(new DistortionPropertyBlock()); blockList.AddPropertyBlock(new AdvancedOptionsPropertyBlock()); diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/LitPropertyBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/LitPropertyBlock.cs deleted file mode 100644 index 8267f78039f..00000000000 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/LitPropertyBlock.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using UnityEngine.Rendering; -using UnityEngine.Rendering.HighDefinition; -using UnityEditor.ShaderGraph; -using UnityEngine.UIElements; -using UnityEditor.UIElements; -using UnityEngine; - -// We share the name of the properties in the UI to avoid duplication -using static UnityEditor.Rendering.HighDefinition.DistortionUIBlock.Styles; - -namespace UnityEditor.Rendering.HighDefinition.ShaderGraph -{ - class LitPropertyBlock : SubTargetPropertyBlock - { - protected override string title => "Lit Properties"; - protected override int foldoutIndex => 2; - - HDLitData litData; - - public LitPropertyBlock(HDLitData litData) - { - this.litData = litData; - } - - protected override void CreatePropertyGUI() - { - - } - } -} \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/LitPropertyBlock.cs.meta b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/LitPropertyBlock.cs.meta deleted file mode 100644 index 08db573feab..00000000000 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/LitPropertyBlock.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c3d42a05c18dfbd47af8937648d6ec0d -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/LitSurfaceOptionPropertyBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/LitSurfaceOptionPropertyBlock.cs index 429f9633f3b..1412a2e0984 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/LitSurfaceOptionPropertyBlock.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/LitSurfaceOptionPropertyBlock.cs @@ -42,8 +42,13 @@ protected override void CreatePropertyGUI() if (systemData.surfaceType == SurfaceType.Transparent) { AddProperty(refractionModelText, () => litData.refractionModel, (newValue) => litData.refractionModel = newValue); - if (litData.refractionModel != ScreenSpaceRefraction.RefractionModel.None && systemData.blendMode != BlendMode.Alpha) - AddHelpBox(RefractionUIBlock.Styles.refractionBlendModeWarning, MessageType.Warning); + if (litData.refractionModel != ScreenSpaceRefraction.RefractionModel.None) + { + if (systemData.blendMode != BlendMode.Alpha) + AddHelpBox(RefractionUIBlock.Styles.refractionBlendModeWarning, MessageType.Warning); + if (systemData.renderQueueType == HDRenderQueue.RenderQueueType.PreRefraction) + AddHelpBox(RefractionUIBlock.Styles.refractionRenderingPassWarning, MessageType.Warning); + } } if (litData.materialType == HDLitData.MaterialType.SpecularColor) { 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 a6d45199cda..df775acb64d 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 @@ -221,7 +221,7 @@ public static string RenderQueueName(HDRenderQueue.RenderQueueType value) } } - public static System.Collections.Generic.List GetRenderingPassList(bool opaque, bool needAfterPostProcess, bool hasRefraction) + public static System.Collections.Generic.List GetRenderingPassList(bool opaque, bool needAfterPostProcess) { // We can't use RenderPipelineManager.currentPipeline here because this is called before HDRP is created by SG window var result = new System.Collections.Generic.List(); @@ -233,8 +233,7 @@ public static string RenderQueueName(HDRenderQueue.RenderQueueType value) } else { - if (!hasRefraction) - result.Add(HDRenderQueue.RenderQueueType.PreRefraction); + result.Add(HDRenderQueue.RenderQueueType.PreRefraction); result.Add(HDRenderQueue.RenderQueueType.Transparent); result.Add(HDRenderQueue.RenderQueueType.LowTransparent); if (needAfterPostProcess) 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 a0c9d4b3841..dc3290a3f0e 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 @@ -19,11 +19,10 @@ public enum Features { None = 0, ShowDoubleSidedNormal = 1 << 0, - HasRefraction = 1 << 1, All = ~0, Unlit = Lit ^ ShowDoubleSidedNormal, // hide double sided normal for unlit - Lit = All ^ HasRefraction, // Refraction is not enabled by default + Lit = All, } class Styles @@ -46,18 +45,11 @@ protected override void CreatePropertyGUI() systemData.TryChangeRenderingPass(systemData.renderQueueType); }); - // TODO: if HasRefraction, convert render queue before refraction to default (transparent only) - // + remove before refraction from the list - - bool hasRefraction = (enabledFeatures & Features.HasRefraction) != 0; context.globalIndentLevel++; - var renderingPassList = HDSubShaderUtilities.GetRenderingPassList(systemData.surfaceType == SurfaceType.Opaque, enabledFeatures == Features.Unlit, hasRefraction); // Show after post process for unlit shaders + var renderingPassList = HDSubShaderUtilities.GetRenderingPassList(systemData.surfaceType == SurfaceType.Opaque, enabledFeatures == Features.Unlit); // Show after post process for unlit shaders var renderingPassValue = systemData.surfaceType == SurfaceType.Opaque ? HDRenderQueue.GetOpaqueEquivalent(systemData.renderQueueType) : HDRenderQueue.GetTransparentEquivalent(systemData.renderQueueType); var renderQueueType = systemData.surfaceType == SurfaceType.Opaque ? HDRenderQueue.RenderQueueType.Opaque : HDRenderQueue.RenderQueueType.Transparent; - if (renderingPassValue == HDRenderQueue.RenderQueueType.PreRefraction && hasRefraction) - renderingPassValue = HDRenderQueue.RenderQueueType.Transparent; - context.AddProperty(renderingPassText, new PopupField(renderingPassList, renderQueueType, HDSubShaderUtilities.RenderQueueName, HDSubShaderUtilities.RenderQueueName) { value = renderingPassValue }, (evt) => { registerUndo(renderingPassText); diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/RefractionUIBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/RefractionUIBlock.cs index 5955e908524..83568222420 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/RefractionUIBlock.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/RefractionUIBlock.cs @@ -23,6 +23,7 @@ internal static class Styles public static GUIContent transmittanceColorText = new GUIContent("Transmittance Color", "Specifies the Transmittance Color (RGB) for this Material."); public static GUIContent atDistanceText = new GUIContent("Transmittance Absorption Distance", "Sets the absorption distance reference in meters."); public static string refractionBlendModeWarning = "Refraction is only supported with the Blend Mode value Alpha. Please, set the Blend Mode to Alpha in the Surface Options to hide this mesage."; + public static string refractionRenderingPassWarning = "Refraction is not supported with the rendering pass Pre-Refraction. Please, use a different rendering pass."; } protected MaterialProperty refractionModel = null; @@ -65,11 +66,7 @@ public override void LoadMaterialProperties() public override void OnGUI() { - var isPrepass = materials.All(m => HDRenderQueue.k_RenderQueue_PreRefraction.Contains(m.renderQueue)); - - if (refractionModel != null - // Refraction is not available for pre-refraction objects - && !isPrepass) + if (refractionModel != null) { materialEditor.ShaderProperty(refractionModel, Styles.refractionModelText); var mode = (ScreenSpaceRefraction.RefractionModel)refractionModel.floatValue; @@ -123,9 +120,19 @@ public override void OnGUI() break; } - if (refractionModel.floatValue != 0 && blendMode != null && blendMode.floatValue != (int)BlendMode.Alpha) + if (refractionModel.floatValue != 0 && blendMode != null) { - EditorGUILayout.HelpBox(Styles.refractionBlendModeWarning, MessageType.Warning); + if (blendMode.floatValue != (int)BlendMode.Alpha) + EditorGUILayout.HelpBox(Styles.refractionBlendModeWarning, MessageType.Warning); + + // Check for multi-selection render queue different values + if (materials.Length == 1 || materials.All(m => m.renderQueue == materials[0].renderQueue)) + { + var renderQueueType = HDRenderQueue.GetTypeByRenderQueueValue(materials[0].renderQueue); + + if (renderQueueType == HDRenderQueue.RenderQueueType.PreRefraction) + EditorGUILayout.HelpBox(Styles.refractionRenderingPassWarning, MessageType.Warning); + } } } } 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 92ba9532f08..39ea7e6284f 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 @@ -640,7 +640,7 @@ void SurfaceTypePopup() case SurfaceType.Transparent: //GetTransparentEquivalent: prevent issue when switching surface type HDRenderQueue.TransparentRenderQueue renderQueueTransparentType = HDRenderQueue.ConvertToTransparentRenderQueue(HDRenderQueue.GetTransparentEquivalent(renderQueueType)); - var newRenderQueueTransparentType = (HDRenderQueue.TransparentRenderQueue)DoTransparentRenderingPassPopup(Styles.renderingPassText, (int)renderQueueTransparentType, showPreRefractionPass, showLowResolutionPass, showAfterPostProcessPass); + var newRenderQueueTransparentType = (HDRenderQueue.TransparentRenderQueue)DoTransparentRenderingPassPopup(Styles.renderingPassText, (int)renderQueueTransparentType, true, showLowResolutionPass, showAfterPostProcessPass); if (newRenderQueueTransparentType != renderQueueTransparentType || renderQueueTypeMismatchRenderQueue) //EditorGUI.EndChangeCheck is called even if value remain the same after the popup. Prefer not to use it here { materialEditor.RegisterPropertyChangeUndo("Rendering Pass"); From d2a9b90739ba98d8db004f72aaa928db505f4299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Tue, 20 Oct 2020 16:22:51 +0200 Subject: [PATCH 18/19] Updated changelog --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 6a65b238311..a9d9da562fa 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added a new ray tracing only function that samples the specular part of the materials. - Adding missing marker for ray tracing profiling (RaytracingDeferredLighting) - Added the support of eye shader for ray tracing. +- Exposed Refraction Model to the material UI when using a Lit ShaderGraph. ### Fixed - Fixed several issues with physically-based DoF (TAA ghosting of the CoC buffer, smooth layer transitions, etc) From 5dc18617cfeab9d6a428acce3ccf7fe00ee9e669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Tue, 20 Oct 2020 18:05:18 +0200 Subject: [PATCH 19/19] Updated doc --- .../Documentation~/Lit-Shader.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Lit-Shader.md b/com.unity.render-pipelines.high-definition/Documentation~/Lit-Shader.md index 76b6cf5dcae..981e6398ac1 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Lit-Shader.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Lit-Shader.md @@ -69,9 +69,9 @@ To create a new Lit Material, navigate to your Project's Asset window, right-cli Unity exposes this section if you select **Transparent** from the **Surface Type** drop-down. For information on the properties in this section, see the [Surface Type documentation](Surface-Type.md#TransparencyInputs). -:warning: When you enabled the **Refraction**, make sure to use the **Blend Mode** **Alpha**, otherwise the effect will not work as expected. A similar warning will be displayed in the material inspector if you enabled refraction with a **Blend Mode** different than **Alpha**. +Be aware that when you enable **Refraction**, make sure to set **Blend Mode** to **Alpha**, otherwise the effect does not work as expected. If you enable **Refraction** and use a **Blend Mode** other than **Alpha**, a warning displays in the material Inspector. -You can also note that Refraction is not supported when using the rendering pass **Pre-Refraction**, a warning about it will show up in the material inspector and shader graph inspector in case your setup is incorrect. +Also, be aware that HDRP does not support **Refraction** in the **Pre-Refraction** render pass. If you enable **Refraction** and use the **Pre-Refraction** render pass, a warning displays in the material and Shader Graph Inspector.