From 3d7922041a4f86e2114c681e0bf8ff58de3729ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Wed, 17 Jun 2020 17:08:05 +0200 Subject: [PATCH 01/27] Exposed DisableDecals, DisableSSR, DisableSSRTransparent, PreserveSpecular, AddPrecomputedVelocity, TransparentWriteMotionvector and DepthOffset --- .../Editor/Material/Eye/ShaderGraph/EyeGUI.cs | 6 +- .../Material/Fabric/ShaderGraph/FabricGUI.cs | 7 +- .../Material/Hair/ShaderGraph/HairGUI.cs | 7 +- .../Editor/Material/Lit/BaseLitGUI.cs | 7 +- .../Material/Lit/ShaderGraph/HDLitGUI.cs | 5 +- .../Editor/Material/ShaderGraph/HDFields.cs | 8 -- .../Material/ShaderGraph/HDShaderPasses.cs | 2 +- .../ShaderGraph/HDSubShaderUtilities.cs | 6 + .../Editor/Material/ShaderGraph/HDTarget.cs | 105 ++++++++++++++---- .../Material/ShaderGraph/LightingSubTarget.cs | 13 ++- .../Material/ShaderGraph/SurfaceSubTarget.cs | 46 ++++---- .../ShaderGraph/Templates/ShaderPass.template | 19 +--- .../StackLit/ShaderGraph/StackLitGUI.cs | 7 +- .../UIBlocks/AdvancedOptionsUIBlock.cs | 3 +- .../Material/UIBlocks/SurfaceOptionUIBlock.cs | 8 +- .../Editor/Material/Unlit/HDShaderGUI.cs | 2 +- .../Material/Unlit/ShaderGraph/HDUnlitGUI.cs | 4 +- .../RenderPipeline/HDStringConstants.cs | 1 + 18 files changed, 162 insertions(+), 94 deletions(-) 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 index 083a42d386d..dfa1b9a615c 100644 --- 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 @@ -12,14 +12,16 @@ namespace UnityEditor.Rendering.HighDefinition 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 + const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Lit ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold - ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass; + ^ 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) 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 index 5f6a6d7df02..be845bf1d36 100644 --- 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 @@ -12,15 +12,16 @@ namespace UnityEditor.Rendering.HighDefinition 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 + const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Lit ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold - ^ SurfaceOptionUIBlock.Features.BackThenFrontRendering - ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass; + ^ 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) 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 index 5aae48b1a33..98fc71dd39f 100644 --- 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 @@ -12,15 +12,16 @@ namespace UnityEditor.Rendering.HighDefinition 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 + const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Lit ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold - ^ SurfaceOptionUIBlock.Features.BackThenFrontRendering - ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass; + ^ 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) 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/ShaderGraph/HDLitGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitGUI.cs index e74586f523c..fa9b11c221f 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitGUI.cs @@ -12,14 +12,15 @@ namespace UnityEditor.Rendering.HighDefinition class HDLitGUI : 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 + const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Lit ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold - ^ SurfaceOptionUIBlock.Features.BackThenFrontRendering; + | 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) 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..47b32791bbd 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 @@ -53,21 +53,13 @@ static class HDFields 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"); public static FieldDescriptor Tangent = new FieldDescriptor(string.Empty, "Tangent", "_TANGENT 1"); 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); public static FieldDescriptor RayTracing = new FieldDescriptor(string.Empty, "RayTracing", string.Empty); public static FieldDescriptor Unlit = new FieldDescriptor(string.Empty, "Unlit", 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..040a134eba9 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 @@ -520,7 +520,7 @@ DefineCollection GenerateDefines() var defines = new DefineCollection{ { RayTracingNode.GetRayTracingKeyword(), 0 } }; if (supportLighting) - defines.Add(CoreKeywordDescriptors.WriteNormalBufferDefine, 1, new FieldCondition(HDFields.DisableSSRTransparent, false)); + defines.Add( new DefineCollection{ { CoreKeywordDescriptors.WriteNormalBuffer, 0 } }); return defines; } 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..a331e20c9a7 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 @@ -72,12 +72,16 @@ public static void AddStencilShaderProperties(PropertyCollector collector, Syste bool ssrStencil = false; bool receiveSSROpaque = false; bool receiveSSRTransparent = false; + bool receiveDecals = false; + bool blendPreserveSpecular = false; if (lightingData != null) { ssrStencil = systemData.surfaceType == SurfaceType.Opaque ? lightingData.receiveSSR : lightingData.receiveSSRTransparent; receiveSSROpaque = lightingData.receiveSSR; receiveSSRTransparent = lightingData.receiveSSRTransparent; + receiveDecals = lightingData.receiveDecals; + blendPreserveSpecular = lightingData.blendPreserveSpecular; } BaseLitGUI.ComputeStencilProperties(ssrStencil, splitLighting, out int stencilRef, out int stencilWriteMask, @@ -105,6 +109,8 @@ public static void AddStencilShaderProperties(PropertyCollector collector, Syste collector.AddToggleProperty(kUseSplitLighting, splitLighting); collector.AddToggleProperty(kReceivesSSR, receiveSSROpaque); collector.AddToggleProperty(kReceivesSSRTransparent, receiveSSRTransparent); + collector.AddToggleProperty(kSupportDecals, receiveDecals); + collector.AddToggleProperty(kEnableBlendModePreserveSpecularLighting, blendPreserveSpecular); } public static void AddBlendingStatesShaderProperties( 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 b3cea2344a4..a80ebab0825 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 @@ -820,23 +818,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 }, { 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 @@ -917,7 +919,7 @@ static class CoreDefines public static DefineCollection TransparentDepthPrepass = new DefineCollection { { RayTracingNode.GetRayTracingKeyword(), 0 }, - { CoreKeywordDescriptors.WriteNormalBufferDefine, 1, new FieldCondition(HDFields.DisableSSRTransparent, false) }, + { CoreKeywordDescriptors.WriteNormalBuffer, 1 }, }; public static DefineCollection Forward = new DefineCollection @@ -1042,15 +1044,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", @@ -1290,6 +1283,78 @@ static class CoreKeywordDescriptors 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/SurfaceSubTarget.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceSubTarget.cs index 6dfffa84e9b..46103840e89 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,24 +79,18 @@ 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) }, }; 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) }); + passes.Add(HDShaderPasses.GenerateTransparentDepthPrepass(supportLighting)); + passes.Add(HDShaderPasses.GenerateTransparentDepthPrepass(supportLighting)); + passes.Add(HDShaderPasses.GenerateTransparentDepthPrepass(supportLighting)); } else { - passes.Add(HDShaderPasses.GenerateTransparentDepthPrepass(supportLighting), new FieldCondition(HDFields.TransparentDepthPrePass, true)); + passes.Add(HDShaderPasses.GenerateTransparentDepthPrepass(supportLighting)); } if (supportForward) @@ -248,18 +242,14 @@ public override void GetFields(ref TargetFieldContext context) context.AddField(HDFields.DoAlphaTestPostpass, systemData.alphaTest && systemData.alphaTestDepthPostpass && isTransparentDepthPostpass && context.pass.validPixelBlocks.Contains(HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPostpass)); - - context.AddField(HDFields.TransparentDepthPrePass, systemData.surfaceType != SurfaceType.Opaque && systemData.alphaTestDepthPrepass); - context.AddField(HDFields.TransparentDepthPostPass, systemData.surfaceType != SurfaceType.Opaque && systemData.alphaTestDepthPostpass); - // 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 + context.AddField(HDStructFields.FragInputs.positionRWS); } protected void AddDistortionFields(ref TargetFieldContext context) @@ -336,15 +326,19 @@ 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 + }); // Common properties for all "surface" master nodes HDSubShaderUtilities.AddAlphaCutoffShaderProperties(collector, systemData.alphaTest, builtinData.alphaTestShadow); 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..4f3df7269c2 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 @@ -166,8 +155,8 @@ Pass $DoAlphaTestShadow: GENERIC_ALPHA_TEST(surfaceDescription.Alpha, surfaceDescription.AlphaClipThresholdShadow); #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 @@ -212,7 +201,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/StackLit/ShaderGraph/StackLitGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitGUI.cs index 1af452e47e6..bc8d22ccb2b 100644 --- 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 @@ -12,15 +12,16 @@ namespace UnityEditor.Rendering.HighDefinition 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 + const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Lit ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold - ^ SurfaceOptionUIBlock.Features.BackThenFrontRendering - ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass; + ^ 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) 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/UIBlocks/SurfaceOptionUIBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/SurfaceOptionUIBlock.cs index 8478ce8d074..b3968ea65ad 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 @@ -27,8 +27,9 @@ public enum Features ShowAfterPostProcessPass = 1 << 9, AlphaToMask = 1 << 10, ShowPrePassAndPostPass = 1 << 11, + ShowDepthOffsetOnly = 1 << 12, Unlit = Surface | BlendMode | DoubleSided | DoubleSidedNormalMode | AlphaCutoff | AlphaCutoffShadowThreshold | AlphaCutoffThreshold | BackThenFrontRendering | ShowAfterPostProcessPass | AlphaToMask, - Lit = All, + Lit = All ^ ShowDepthOffsetOnly, All = ~0, } @@ -185,7 +186,6 @@ internal static class Styles const string kDisplacementLockTilingScale = "_DisplacementLockTilingScale"; MaterialProperty depthOffsetEnable = null; - const string kDepthOffsetEnable = "_DepthOffsetEnable"; MaterialProperty tessellationMode = null; const string kTessellationMode = "_TessellationMode"; @@ -769,7 +769,9 @@ void DrawLitSurfaceOptions() } } - if (displacementMode != null) + if ((m_Features & Features.ShowDepthOffsetOnly) != 0) + materialEditor.ShaderProperty(depthOffsetEnable, Styles.depthOffsetEnableText); + else if (displacementMode != null) { EditorGUI.BeginChangeCheck(); FilterDisplacementMode(); diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/HDShaderGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/HDShaderGUI.cs index bfdc596a810..d0c45b15c4f 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/HDShaderGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/HDShaderGUI.cs @@ -90,7 +90,7 @@ protected static void ResetMaterialCustomRenderQueue(Material material) } readonly static string[] floatPropertiesToSynchronize = { - "_UseShadowThreshold", kReceivesSSR, kReceivesSSRTransparent, kUseSplitLighting, + "_UseShadowThreshold", kUseSplitLighting, kTransparentDepthPrepassEnable, kTransparentDepthPostpassEnable }; 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..33c99cd3d68 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 @@ -16,12 +16,14 @@ class HDUnlitGUI : HDShaderGUI const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold ^ SurfaceOptionUIBlock.Features.DoubleSidedNormalMode - ^ SurfaceOptionUIBlock.Features.BackThenFrontRendering; + ^ SurfaceOptionUIBlock.Features.BackThenFrontRendering + | SurfaceOptionUIBlock.Features.ShowDepthOffsetOnly; 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/Runtime/RenderPipeline/HDStringConstants.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs index 416b9d06d01..6a12e91c48f 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs @@ -928,6 +928,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 = { From 8428cbf8975505c0212af3140f2e7360be7eb646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Wed, 17 Jun 2020 17:49:01 +0200 Subject: [PATCH 02/27] Added transparent write MV --- .../Editor/Material/ShaderGraph/SurfaceSubTarget.cs | 7 +++++++ .../Editor/Material/UIBlocks/SurfaceOptionUIBlock.cs | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) 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 46103840e89..1627be626d3 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 @@ -340,6 +340,13 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera 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); 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 b3968ea65ad..6188b4740cf 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 @@ -134,7 +134,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; From 4d53ddb7717e7a29183ea70c431fac6b4a194591 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Wed, 17 Jun 2020 21:49:00 +0200 Subject: [PATCH 03/27] always generate transparent Depth Prepass --- .../Editor/Material/ShaderGraph/SurfaceSubTarget.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) 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 1627be626d3..9927ed984ec 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 @@ -82,16 +82,7 @@ PassCollection GetPasses() { HDShaderPasses.GenerateTransparentDepthPostpass(supportLighting) }, }; - if (supportLighting) - { - passes.Add(HDShaderPasses.GenerateTransparentDepthPrepass(supportLighting)); - passes.Add(HDShaderPasses.GenerateTransparentDepthPrepass(supportLighting)); - passes.Add(HDShaderPasses.GenerateTransparentDepthPrepass(supportLighting)); - } - else - { - passes.Add(HDShaderPasses.GenerateTransparentDepthPrepass(supportLighting)); - } + passes.Add(HDShaderPasses.GenerateTransparentDepthPrepass(supportLighting)); if (supportForward) { From 11d81af0b4020c71476cfda66e7ec10dda620952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Thu, 18 Jun 2020 18:43:27 +0200 Subject: [PATCH 04/27] Added material migration step --- .../AssetProcessors/MaterialPostProcessor.cs | 27 +++++++++ .../Editor/Material/Eye/ShaderGraph/EyeGUI.cs | 55 ------------------- .../Material/Eye/ShaderGraph/EyeGUI.cs.meta | 11 ---- .../Material/Eye/ShaderGraph/EyeSubTarget.cs | 2 +- .../Material/Fabric/ShaderGraph/FabricGUI.cs | 54 ------------------ .../Fabric/ShaderGraph/FabricGUI.cs.meta | 11 ---- .../Fabric/ShaderGraph/FabricSubTarget.cs | 2 +- .../Material/Hair/ShaderGraph/HairGUI.cs | 55 ------------------- .../Hair/ShaderGraph/HairSubTarget.cs | 2 +- .../Material/Lit/ShaderGraph/HDLitGUI.cs.meta | 11 ---- .../Lit/ShaderGraph/HDLitSubTarget.cs | 2 +- .../Material/ShaderGraph/HDShaderPasses.cs | 15 ++++- .../Editor/Material/ShaderGraph/HDTarget.cs | 21 ++++++- .../Material/ShaderGraph/SurfaceSubTarget.cs | 2 +- .../ShaderGraph/Templates/ShaderPass.template | 21 ++++--- .../StackLit/ShaderGraph/StackLitGUI.cs | 54 ------------------ .../StackLit/ShaderGraph/StackLitGUI.cs.meta | 11 ---- .../StackLit/ShaderGraph/StackLitSubTarget.cs | 2 +- .../{Unlit => UIBlocks}/HDShaderGUI.cs | 3 +- .../{Unlit => UIBlocks}/HDShaderGUI.cs.meta | 0 .../LightingShaderGraphGUI.cs} | 13 ++--- .../LightingShaderGraphGUI.cs.meta} | 2 +- .../Material/UIBlocks/SurfaceOptionUIBlock.cs | 19 +++++-- .../Editor/RenderPipeline/HDShaderUtils.cs | 8 +-- 24 files changed, 105 insertions(+), 298 deletions(-) delete mode 100644 com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeGUI.cs delete mode 100644 com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeGUI.cs.meta delete mode 100644 com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricGUI.cs delete mode 100644 com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricGUI.cs.meta delete mode 100644 com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairGUI.cs delete mode 100644 com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitGUI.cs.meta delete mode 100644 com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitGUI.cs delete mode 100644 com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitGUI.cs.meta rename com.unity.render-pipelines.high-definition/Editor/Material/{Unlit => UIBlocks}/HDShaderGUI.cs (97%) rename com.unity.render-pipelines.high-definition/Editor/Material/{Unlit => UIBlocks}/HDShaderGUI.cs.meta (100%) rename com.unity.render-pipelines.high-definition/Editor/Material/{Lit/ShaderGraph/HDLitGUI.cs => UIBlocks/LightingShaderGraphGUI.cs} (91%) rename com.unity.render-pipelines.high-definition/Editor/Material/{Hair/ShaderGraph/HairGUI.cs.meta => UIBlocks/LightingShaderGraphGUI.cs.meta} (83%) 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 dfa1b9a615c..00000000000 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeGUI.cs +++ /dev/null @@ -1,55 +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.Lit - ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold - ^ 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) - { - 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.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeSubTarget.cs index 38ae87472ed..74fb4ad68af 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeSubTarget.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeSubTarget.cs @@ -25,7 +25,7 @@ sealed partial class EyeSubTarget : LightingSubTarget, ILegacyTarget, IRequiresD }; protected override string[] templateMaterialDirectories => 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 be845bf1d36..00000000000 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricGUI.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 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.Lit - ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold - ^ 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) - { - 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 98fc71dd39f..00000000000 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairGUI.cs +++ /dev/null @@ -1,55 +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.Lit - ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold - ^ 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) - { - 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.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairSubTarget.cs index 85826fa0a43..f7d00bd6919 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairSubTarget.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairSubTarget.cs @@ -25,7 +25,7 @@ sealed partial class HairSubTarget : LightingSubTarget, ILegacyTarget, IRequires }; protected override string[] templateMaterialDirectories => 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/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.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitSubTarget.cs index 21c8e958318..2f17dd7c09f 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 @@ -39,7 +39,7 @@ public HDLitData litData }; protected override string[] templateMaterialDirectories => 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/HDShaderPasses.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDShaderPasses.cs index 040a134eba9..64f0f10fd2b 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 @@ -499,6 +499,9 @@ public static PassDescriptor GenerateTransparentDepthPrepass(bool supportLightin { BlockFields.SurfaceDescription.Alpha, HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPrepass, + BlockFields.SurfaceDescription.AlphaClipThreshold, + HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPostpass, + HDBlockFields.SurfaceDescription.AlphaClipThresholdShadow, HDBlockFields.SurfaceDescription.DepthOffset, BlockFields.SurfaceDescription.NormalTS, BlockFields.SurfaceDescription.NormalWS, @@ -519,6 +522,8 @@ DefineCollection GenerateDefines() { var defines = new DefineCollection{ { RayTracingNode.GetRayTracingKeyword(), 0 } }; + defines.Add( CoreKeywordDescriptors.DepthPrepassCutoff,0); + if (supportLighting) defines.Add( new DefineCollection{ { CoreKeywordDescriptors.WriteNormalBuffer, 0 } }); @@ -607,16 +612,24 @@ 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 = GenerateDefines(), keywords = CoreKeywords.HDBase, includes = GenerateIncludes(), }; + DefineCollection GenerateDefines() + { + var defines = new DefineCollection{ CoreDefines.ShaderGraphRaytracingHigh }; + defines.Add(CoreKeywordDescriptors.DepthPostpassCutoff, 0); + return defines; + } + IncludeCollection GenerateIncludes() { var includes = new IncludeCollection(); 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 a80ebab0825..339f392d3ad 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 @@ -873,7 +873,7 @@ static class CoreKeywords { CoreKeywordDescriptors.ShadowsShadowmask }, { CoreKeywordDescriptors.Shadow }, { CoreKeywordDescriptors.Decals }, - { CoreKeywordDescriptors.LightList, new FieldCondition(Fields.SurfaceOpaque, true) }, + { CoreKeywordDescriptors.LightList }, }; public static KeywordCollection RaytracingIndirect = new KeywordCollection @@ -925,7 +925,6 @@ static class CoreDefines 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) }, }; } @@ -1355,6 +1354,24 @@ static class CoreKeywordDescriptors definition = KeywordDefinition.ShaderFeature, scope = KeywordScope.Local, }; + + public static KeywordDescriptor DepthPrepassCutoff = new KeywordDescriptor() + { + displayName = "Depth Prepass Cutoff", + referenceName = "CUTOFF_TRANSPARENT_DEPTH_PREPASS", + type = KeywordType.Boolean, + definition = KeywordDefinition.Predefined, + scope = KeywordScope.Global, + }; + + public static KeywordDescriptor DepthPostpassCutoff = new KeywordDescriptor() + { + displayName = "Depth Postpass Cutoff", + referenceName = "CUTOFF_TRANSPARENT_DEPTH_POSTPASS", + type = KeywordType.Boolean, + definition = KeywordDefinition.Predefined, + scope = KeywordScope.Global, + }; } #endregion } 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 9927ed984ec..e91a276cc69 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 @@ -376,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/Templates/ShaderPass.template b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Templates/ShaderPass.template index 4f3df7269c2..509036f12ba 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 @@ -149,10 +149,17 @@ 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; + $DoAlphaTestPrepass: alphaCutoff = surfaceDescription.AlphaClipThresholdDepthPrepass; + $DoAlphaTestPostpass: alphaCutoff = surfaceDescription.AlphaClipThresholdDepthPostpass; + + #if SHADERPASS == SHADERPASS_SHADOWS + float alphaTestShadow = alphaCutoff; + $DoAlphaTestShadow: alphaTestShadow = _UseShadowThreshold ? surfaceDescription.AlphaClipThresholdShadow : alphaCutoff; + GENERIC_ALPHA_TEST(surfaceDescription.Alpha, alphaTestShadow); + #else + GENERIC_ALPHA_TEST(surfaceDescription.Alpha, alphaCutoff); + #endif #endif #if !defined(SHADER_STAGE_RAY_TRACING) && _DEPTHOFFSET_ON @@ -184,10 +191,8 @@ Pass #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; + builtinData.alphaClipTreshold = alphaCutoff; + $DoAlphaTestShadow: builtinData.alphaClipTreshold = _UseShadowThreshold ? surfaceDescription.AlphaClipThresholdShadow : alphaCutoff; #endif // override sampleBakedGI - not used by Unlit 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 bc8d22ccb2b..00000000000 --- a/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitGUI.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 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.Lit - ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold - ^ 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) - { - 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/Unlit/HDShaderGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/HDShaderGUI.cs similarity index 97% 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 d0c45b15c4f..c3ad656bd62 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", kUseSplitLighting, - kTransparentDepthPrepassEnable, kTransparentDepthPostpassEnable + kUseSplitLighting, kTransparentBackfaceEnable }; protected static void SynchronizeShaderGraphProperties(Material material) 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 91% 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 fa9b11c221f..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,13 +7,13 @@ 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.Lit - ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold + ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass | SurfaceOptionUIBlock.Features.ShowDepthOffsetOnly; MaterialUIBlockList uiBlocks = new MaterialUIBlockList @@ -44,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/SurfaceOptionUIBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/SurfaceOptionUIBlock.cs index 6188b4740cf..eef6494b5bb 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; @@ -402,7 +403,13 @@ void DrawAlphaCutoffGUI() if ((m_Features & Features.AlphaCutoffThreshold) != 0) { - if (useShadowThreshold != null) + // For shadergraphs we show this slider only if the feature is enabled in the shader settings. + bool showUseShadowThreshold = useShadowThreshold != null; + var shader = materials[0].shader; + if (showUseShadowThreshold && shader.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) @@ -423,6 +430,7 @@ void DrawAlphaCutoffGUI() // This allow to get a better sorting (with prepass), better shadow (better silhouettes fidelity) etc... if (surfaceTypeValue == SurfaceType.Transparent) { + // TODO: check if passes exists if (transparentDepthPrepassEnable != null && transparentDepthPrepassEnable.floatValue == 1.0f) { if (alphaCutoffPrepass != null) @@ -512,15 +520,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); } 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 }; From 6786384b932665e867b9cdb6d9c667624045758f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Thu, 18 Jun 2020 20:07:16 +0200 Subject: [PATCH 05/27] Trying to fix transparent SSR bug --- .../Editor/Material/ShaderGraph/HDFields.cs | 1 - .../Material/ShaderGraph/HDShaderPasses.cs | 17 ++++++++++++----- .../Material/ShaderGraph/SurfaceSubTarget.cs | 3 --- .../Editor/Material/UIBlocks/HDShaderGUI.cs | 8 ++++++++ 4 files changed, 20 insertions(+), 9 deletions(-) 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 47b32791bbd..f90c7b470d2 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,7 +48,6 @@ 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"); 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 64f0f10fd2b..4e667fcaf6e 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 @@ -514,7 +514,7 @@ public static PassDescriptor GenerateTransparentDepthPrepass(bool supportLightin renderStates = GenerateRenderState(), pragmas = CorePragmas.DotsInstancedInV1AndV2, defines = GenerateDefines(), - keywords = CoreKeywords.HDBase, + keywords = GenerateKeywords(), includes = GenerateIncludes(), }; @@ -522,14 +522,21 @@ DefineCollection GenerateDefines() { var defines = new DefineCollection{ { RayTracingNode.GetRayTracingKeyword(), 0 } }; - defines.Add( CoreKeywordDescriptors.DepthPrepassCutoff,0); - - if (supportLighting) - defines.Add( new DefineCollection{ { CoreKeywordDescriptors.WriteNormalBuffer, 0 } }); + defines.Add(CoreKeywordDescriptors.DepthPrepassCutoff, 0); return defines; } + KeywordCollection GenerateKeywords() + { + KeywordCollection keywords = new KeywordCollection { CoreKeywords.HDBase }; + + if (supportLighting) + keywords.Add(CoreKeywordDescriptors.WriteNormalBuffer); + + return keywords; + } + RenderStateCollection GenerateRenderState() { var renderState = new RenderStateCollection 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 e91a276cc69..2c9329126ad 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 @@ -220,9 +220,6 @@ public override void GetFields(ref TargetFieldContext context) 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 && 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 c3ad656bd62..dd39cb40d5b 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 @@ -99,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; } } From 5e9f2909ef060b2e2eb558590b58d4bb731daff3 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Sun, 21 Jun 2020 17:57:24 +0200 Subject: [PATCH 06/27] Bump HDRP project settings version to 5 so yamato can run --- .../HDRP_HybridTests/ProjectSettings/HDRPProjectSettings.asset | 2 +- .../ProjectSettings/HDRPProjectSettings.asset | 2 +- .../HDRP_RuntimeTests/ProjectSettings/HDRPProjectSettings.asset | 2 +- .../HDRP_Tests/ProjectSettings/HDRPProjectSettings.asset | 2 +- .../SRP_SmokeTest/ProjectSettings/HDRPProjectSettings.asset | 2 +- .../ProjectSettings/HDRPProjectSettings.asset | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) 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 From 3dea6187dd813c3745185c0c400a3624e1b8b730 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Sun, 21 Jun 2020 18:57:58 +0200 Subject: [PATCH 07/27] Cleanup of alpha test + alpha mask + fix shader warning --- .../ShaderGraph/Templates/ShaderPass.template | 11 ++++------- .../Runtime/Material/AxF/AxFData.hlsl | 6 +++--- .../Runtime/Material/Decal/DecalData.hlsl | 4 ++-- .../Runtime/Material/Lit/LitData.hlsl | 6 +++--- 4 files changed, 12 insertions(+), 15 deletions(-) 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 509036f12ba..d39399c194b 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 @@ -154,12 +154,10 @@ Pass $DoAlphaTestPostpass: alphaCutoff = surfaceDescription.AlphaClipThresholdDepthPostpass; #if SHADERPASS == SHADERPASS_SHADOWS - float alphaTestShadow = alphaCutoff; - $DoAlphaTestShadow: alphaTestShadow = _UseShadowThreshold ? surfaceDescription.AlphaClipThresholdShadow : alphaCutoff; - GENERIC_ALPHA_TEST(surfaceDescription.Alpha, alphaTestShadow); - #else - GENERIC_ALPHA_TEST(surfaceDescription.Alpha, alphaCutoff); + alphaCutoff = _UseShadowThreshold ? surfaceDescription.AlphaClipThresholdShadow : alphaCutoff; #endif + + GENERIC_ALPHA_TEST(surfaceDescription.Alpha, alphaCutoff); #endif #if !defined(SHADER_STAGE_RAY_TRACING) && _DEPTHOFFSET_ON @@ -190,9 +188,8 @@ Pass #endif // SHADER_UNLIT #ifdef _ALPHATEST_ON - // Used for sharpening by alpha to mask + // 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; - $DoAlphaTestShadow: builtinData.alphaClipTreshold = _UseShadowThreshold ? surfaceDescription.AlphaClipThresholdShadow : alphaCutoff; #endif // override sampleBakedGI - not used by Unlit 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..8236fea5d4b 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 ? surfaceDescription.AlphaClipThresholdShadow : 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/LitData.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl index 5d1d048151e..7cceb990e85 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 @@ -226,10 +226,10 @@ void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs p #endif #if SHADERPASS == SHADERPASS_SHADOWS - GENERIC_ALPHA_TEST(alphaValue, _UseShadowThreshold ? _AlphaCutoffShadow : alphaCutoff); - #else - GENERIC_ALPHA_TEST(alphaValue, alphaCutoff); + alphaCutoff = _UseShadowThreshold ? _AlphaCutoffShadow : alphaCutoff; #endif + + GENERIC_ALPHA_TEST(alphaValue, alphaCutoff); #endif // We perform the conversion to world of the normalTS outside of the GetSurfaceData From c680ccd1e99d46eb67e1f63f94949c161a4d4493 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Sun, 21 Jun 2020 19:58:09 +0200 Subject: [PATCH 08/27] Fix AlphaTestShadow: issue --- .../Editor/Material/ShaderGraph/Templates/ShaderPass.template | 2 +- .../Runtime/Material/AxF/AxFData.hlsl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 d39399c194b..0ceaa95825b 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 @@ -154,7 +154,7 @@ Pass $DoAlphaTestPostpass: alphaCutoff = surfaceDescription.AlphaClipThresholdDepthPostpass; #if SHADERPASS == SHADERPASS_SHADOWS - alphaCutoff = _UseShadowThreshold ? surfaceDescription.AlphaClipThresholdShadow : alphaCutoff; + $DoAlphaTestShadow: alphaCutoff = _UseShadowThreshold ? surfaceDescription.AlphaClipThresholdShadow : alphaCutoff; #endif GENERIC_ALPHA_TEST(surfaceDescription.Alpha, alphaCutoff); 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 8236fea5d4b..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,7 +509,7 @@ void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs p float alphaCutoff = _AlphaCutoff; #if SHADERPASS == SHADERPASS_SHADOWS - alphaCutoff = _UseShadowThreshold ? surfaceDescription.AlphaClipThresholdShadow : alphaCutoff; + alphaCutoff = _UseShadowThreshold ? _AlphaCutoffShadow : alphaCutoff; #endif GENERIC_ALPHA_TEST(alpha, alphaCutoff); From 1ec48d8ff069a34f8806c4e31efd1db216bf6eb4 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Sat, 27 Jun 2020 16:16:36 +0200 Subject: [PATCH 09/27] Fix various code (PS4 - >playstation) + Hidde colorPyramid --- .../Editor/Material/ShaderGraph/HDShaderPasses.cs | 1 - .../Runtime/Compositor/Shaders/AlphaInjection.shader | 4 ++-- .../Runtime/Compositor/Shaders/ChromaKeying.shader | 4 ++-- .../Runtime/Compositor/Shaders/CustomClear.shader | 2 +- .../Runtime/RenderPipeline/RenderPass/ColorPyramidPS.shader | 2 +- .../RenderPass/CustomPass/CustomPassUtils.shader | 2 +- .../Material/DefaultHDDecalMaterial.mat | 2 +- .../RenderPipelineResources/Material/DefaultHDMaterial.mat | 3 ++- .../Material/DefaultHDMirrorMaterial.mat | 3 ++- .../Material/DefaultHDParticleMaterial.mat | 3 ++- .../Material/DefaultHDTerrainMaterial.mat | 2 +- 11 files changed, 15 insertions(+), 13 deletions(-) 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 4e667fcaf6e..d5e57daa05d 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 @@ -500,7 +500,6 @@ public static PassDescriptor GenerateTransparentDepthPrepass(bool supportLightin BlockFields.SurfaceDescription.Alpha, HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPrepass, BlockFields.SurfaceDescription.AlphaClipThreshold, - HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPostpass, HDBlockFields.SurfaceDescription.AlphaClipThresholdShadow, HDBlockFields.SurfaceDescription.DepthOffset, BlockFields.SurfaceDescription.NormalTS, 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/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/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 From d3fc1c8f2de79d6d0dbb9ea8bfa388a4f780055f Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Sat, 27 Jun 2020 16:48:21 +0200 Subject: [PATCH 10/27] switch HDRP DXR MaterialVersion to 5 --- .../HDRP_DXR_Tests/ProjectSettings/HDRPProjectSettings.asset | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 43a62adcb422da09482ac2b71c295f8564dbd45b Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Sat, 27 Jun 2020 20:01:03 +0200 Subject: [PATCH 11/27] Introduce concept of SHADERPASS_TRANSPARENT_DEPTH_PREPASS / SHADERPASS_TRANSPARENT_DEPTH_POSTPASS --- .../Upgrading-from-2020.1-to-2020.2.md | 2 + .../Material/ShaderGraph/HDShaderPasses.cs | 13 ++++--- .../ShaderGraph/Templates/ShaderPass.template | 16 ++++++++ .../Runtime/Debug/LightingDebug.cs.hlsl | 3 +- .../Runtime/Material/Lit/Lit.hlsl | 2 +- .../Runtime/Material/Lit/Lit.shader | 6 +-- .../Runtime/Material/Lit/LitData.hlsl | 4 +- .../Material/Lit/LitTessellation.shader | 6 +-- .../RenderPipeline/ShaderPass/ShaderPass.cs | 2 + .../ShaderPass/ShaderPass.cs.hlsl | 38 ++++++++++--------- .../ShaderPass/ShaderPassDepthOnly.hlsl | 2 +- 11 files changed, 58 insertions(+), 36 deletions(-) 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/Material/ShaderGraph/HDShaderPasses.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDShaderPasses.cs index d5e57daa05d..7bd75eb60ce 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 @@ -491,7 +491,7 @@ public static PassDescriptor GenerateTransparentDepthPrepass(bool supportLightin { // Definition displayName = "TransparentDepthPrepass", - referenceName = "SHADERPASS_DEPTH_ONLY", + referenceName = "SHADERPASS_TRANSPARENT_DEPTH_PREPASS", lightMode = "TransparentDepthPrepass", useInPreview = true, @@ -530,9 +530,12 @@ KeywordCollection GenerateKeywords() { KeywordCollection keywords = new KeywordCollection { CoreKeywords.HDBase }; - if (supportLighting) - keywords.Add(CoreKeywordDescriptors.WriteNormalBuffer); - + // 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 keywords; } @@ -609,7 +612,7 @@ public static PassDescriptor GenerateTransparentDepthPostpass(bool supportLighti { // Definition displayName = "TransparentDepthPostpass", - referenceName = "SHADERPASS_DEPTH_ONLY", + referenceName = "SHADERPASS_TRANSPARENT_DEPTH_POSTPASS", lightMode = "TransparentDepthPostpass", useInPreview = true, 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 0ceaa95825b..4659f8185d8 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 @@ -50,6 +50,22 @@ Pass $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) + #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 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/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 7cceb990e85..da7f6cf4925 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 @@ -219,9 +219,9 @@ void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs p // Perform alha test very early to save performance (a killed pixel will not sample textures) float alphaCutoff = _AlphaCutoff; - #ifdef CUTOFF_TRANSPARENT_DEPTH_PREPASS + #if SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_PREPASS alphaCutoff = _AlphaCutoffPrepass; - #elif defined(CUTOFF_TRANSPARENT_DEPTH_POSTPASS) + #elif SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_POSTPASS alphaCutoff = _AlphaCutoffPostpass; #endif 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/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 From 26c0d9fa1d1163910011a74db47dd62e63742c68 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Sun, 28 Jun 2020 02:36:57 +0200 Subject: [PATCH 12/27] Fix problem with Double sided, transparent and depth offset. --- .../Editor/Material/ShaderGraph/HDFields.cs | 3 +- .../Material/ShaderGraph/HDShaderPasses.cs | 4 +- .../Material/ShaderGraph/HDSubTarget.cs | 4 -- .../Editor/Material/ShaderGraph/HDTarget.cs | 46 ++----------------- .../Material/ShaderGraph/SurfaceSubTarget.cs | 38 ++++++--------- .../ShaderGraph/Templates/ShaderPass.template | 29 +++++++----- .../Templates/SharedCode.template.hlsl | 9 ++-- .../Runtime/Material/Lit/LitData.hlsl | 13 +++--- .../Generation/TargetResources/Fields.cs | 3 +- 9 files changed, 50 insertions(+), 99 deletions(-) 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 f90c7b470d2..f00ed4f01fc 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 @@ -50,8 +50,6 @@ static class HDFields // Misc 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 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"); @@ -59,6 +57,7 @@ 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 TransparentBackFace = new FieldDescriptor(string.Empty, "TransparentBackFace", string.Empty); + public static FieldDescriptor TransparentDepthPostPass = new FieldDescriptor(string.Empty, "TransparentDepthPostPass", string.Empty); public static FieldDescriptor RayTracing = new FieldDescriptor(string.Empty, "RayTracing", string.Empty); public static FieldDescriptor Unlit = new FieldDescriptor(string.Empty, "Unlit", 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 7bd75eb60ce..cfc251e5b64 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 @@ -521,8 +521,6 @@ DefineCollection GenerateDefines() { var defines = new DefineCollection{ { RayTracingNode.GetRayTracingKeyword(), 0 } }; - defines.Add(CoreKeywordDescriptors.DepthPrepassCutoff, 0); - return defines; } @@ -635,7 +633,7 @@ public static PassDescriptor GenerateTransparentDepthPostpass(bool supportLighti DefineCollection GenerateDefines() { var defines = new DefineCollection{ CoreDefines.ShaderGraphRaytracingHigh }; - defines.Add(CoreKeywordDescriptors.DepthPostpassCutoff, 0); + return defines; } 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 2f360561954..7d165c3035c 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 @@ -664,17 +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.ZTest(Uniforms.zTestDepthEqualForOpaque) }, { RenderState.Stencil(new StencilDescriptor() { WriteMask = Uniforms.stencilWriteMask, @@ -689,17 +679,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.ZTest(Uniforms.zTestDepthEqualForOpaque) }, { RenderState.ColorMask("ColorMask [_ColorMaskTransparentVel] 1") }, { RenderState.Stencil(new StencilDescriptor() { @@ -830,7 +810,7 @@ static class CoreKeywords { CoreKeywordDescriptors.BlendModePreserveSpecularLighting, new FieldCondition(HDFields.Unlit, false) }, { CoreKeywordDescriptors.AddPrecomputedVelocity }, { CoreKeywordDescriptors.TransparentWritesMotionVector }, - { CoreKeywordDescriptors.DepthOffset }, + { CoreKeywordDescriptors.DepthOffset, new FieldCondition(Fields.DepthOffset, true) }, { CoreKeywordDescriptors.FogOnTransparent }, { CoreKeywordDescriptors.AlphaTest, new FieldCondition(Fields.AlphaTest, true) }, }; @@ -926,7 +906,7 @@ static class CoreDefines public static DefineCollection Forward = new DefineCollection { { CoreKeywordDescriptors.HasLightloop, 1 }, - { RayTracingNode.GetRayTracingKeyword(), 0, new FieldCondition(Fields.SurfaceTransparent, true) }, + { RayTracingNode.GetRayTracingKeyword(), 0 }, }; } #endregion @@ -1369,24 +1349,6 @@ static class CoreKeywordDescriptors definition = KeywordDefinition.ShaderFeature, scope = KeywordScope.Local, }; - - public static KeywordDescriptor DepthPrepassCutoff = new KeywordDescriptor() - { - displayName = "Depth Prepass Cutoff", - referenceName = "CUTOFF_TRANSPARENT_DEPTH_PREPASS", - type = KeywordType.Boolean, - definition = KeywordDefinition.Predefined, - scope = KeywordScope.Global, - }; - - public static KeywordDescriptor DepthPostpassCutoff = new KeywordDescriptor() - { - displayName = "Depth Postpass Cutoff", - referenceName = "CUTOFF_TRANSPARENT_DEPTH_POSTPASS", - type = KeywordType.Boolean, - definition = KeywordDefinition.Predefined, - scope = KeywordScope.Global, - }; } #endregion } 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 2c9329126ad..64ef91d730b 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,16 +79,17 @@ PassCollection GetPasses() HDShaderPasses.GenerateSceneSelection(supportLighting), HDShaderPasses.GenerateMotionVectors(supportLighting, supportForward), { HDShaderPasses.GenerateBackThenFront(supportLighting), new FieldCondition(HDFields.TransparentBackFace, true)}, - { HDShaderPasses.GenerateTransparentDepthPostpass(supportLighting) }, + // We always generate the TransparentDepthPrepass as it can be use with SSR transparent + HDShaderPasses.GenerateTransparentDepthPrepass(supportLighting), + { HDShaderPasses.GenerateTransparentDepthPostpass(supportLighting), new FieldCondition(HDFields.TransparentDepthPostPass, true)} }; - passes.Add(HDShaderPasses.GenerateTransparentDepthPrepass(supportLighting)); - if (supportForward) { passes.Add(HDShaderPasses.GenerateDepthForwardOnlyPass(supportLighting)); passes.Add(HDShaderPasses.GenereateForwardOnlyPass(supportLighting)); } + if (supportDistortion) passes.Add(HDShaderPasses.GenerateDistortionPass(supportLighting), new FieldCondition(HDFields.TransparentDistortion, true)); @@ -198,12 +199,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); @@ -219,7 +215,6 @@ 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"; // Shadow use the specific alpha test only if user have ask to override it context.AddField(HDFields.DoAlphaTestShadow, systemData.alphaTest && builtinData.alphaTestShadow && isShadowPass && @@ -227,17 +222,17 @@ public override void GetFields(ref TargetFieldContext context) // Pre/post pass always use the specific alpha test provided for those pass context.AddField(HDFields.DoAlphaTestPrepass, systemData.alphaTest && systemData.alphaTestDepthPrepass && 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.pass.validPixelBlocks.Contains(BlockFields.SurfaceDescription.AlphaClipThreshold) && builtinData.alphaToMask); - context.AddField(HDFields.AlphaFog, systemData.surfaceType != SurfaceType.Opaque && builtinData.transparencyFog); - context.AddField(HDFields.TransparentBackFace, systemData.surfaceType != SurfaceType.Opaque && builtinData.backThenFrontRendering); + context.AddField(Fields.AlphaToMask, systemData.alphaTest); + context.AddField(HDFields.TransparentBackFace, builtinData.backThenFrontRendering); + + context.AddField(Fields.DepthOffset, builtinData.depthOffset && context.pass.validPixelBlocks.Contains(HDBlockFields.SurfaceDescription.DepthOffset)); // Depth offset needs positionRWS and is now a multi_compile - context.AddField(HDStructFields.FragInputs.positionRWS); + if (builtinData.depthOffset) + context.AddField(HDStructFields.FragInputs.positionRWS); } protected void AddDistortionFields(ref TargetFieldContext context) @@ -268,15 +263,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.alphaTestDepthPrepass); + context.AddBlock(HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPostpass, systemData.alphaTest && systemData.alphaTestDepthPostpass); + 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) 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 4659f8185d8..1cb5cc3de5b 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 @@ -42,10 +42,16 @@ 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 @@ -78,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 @@ -166,11 +165,17 @@ Pass // TODO: split graph evaluation to grab just alpha dependencies first? tricky.. #ifdef _ALPHATEST_ON 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; - $DoAlphaTestPostpass: alphaCutoff = surfaceDescription.AlphaClipThresholdDepthPostpass; - - #if SHADERPASS == SHADERPASS_SHADOWS - $DoAlphaTestShadow: alphaCutoff = _UseShadowThreshold ? surfaceDescription.AlphaClipThresholdShadow : alphaCutoff; + #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); 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/Runtime/Material/Lit/LitData.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl index da7f6cf4925..6b1f899717a 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,15 +218,14 @@ 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) - float alphaCutoff = _AlphaCutoff; #if SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_PREPASS - alphaCutoff = _AlphaCutoffPrepass; + float alphaCutoff = _AlphaCutoffPrepass; #elif SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_POSTPASS - alphaCutoff = _AlphaCutoffPostpass; - #endif - - #if SHADERPASS == SHADERPASS_SHADOWS - alphaCutoff = _UseShadowThreshold ? _AlphaCutoffShadow : alphaCutoff; + float alphaCutoff = _AlphaCutoffPostpass; + #elif SHADERPASS == SHADERPASS_SHADOWS + float alphaCutoff = _UseShadowThreshold ? _AlphaCutoffShadow : alphaCutoff; + #else + float alphaCutoff = _AlphaCutoff; #endif GENERIC_ALPHA_TEST(alphaValue, alphaCutoff); diff --git a/com.unity.shadergraph/Editor/Generation/TargetResources/Fields.cs b/com.unity.shadergraph/Editor/Generation/TargetResources/Fields.cs index bc7cf4e0104..a7bcb486c6a 100644 --- a/com.unity.shadergraph/Editor/Generation/TargetResources/Fields.cs +++ b/com.unity.shadergraph/Editor/Generation/TargetResources/Fields.cs @@ -1,4 +1,4 @@ -namespace UnityEditor.ShaderGraph +namespace UnityEditor.ShaderGraph { [GenerationAPI] internal static class Fields @@ -30,6 +30,7 @@ internal static class Fields public static FieldDescriptor IsPreview = new FieldDescriptor(string.Empty, "isPreview", "SHADERGRAPH_PREVIEW"); public static FieldDescriptor LodCrossFade = new FieldDescriptor(string.Empty, "LodCrossFade", "_LODCROSSFADE 1"); public static FieldDescriptor AlphaToMask = new FieldDescriptor(string.Empty, "AlphaToMask", "_ALPHATOMASK_ON 1"); + public static FieldDescriptor DepthOffset = new FieldDescriptor(string.Empty, "DepthOffset", "_DEPTH_OFFSET 1"); #endregion } } From d5fa1a33a9f03ba19deef8cdb67440c699e1007f Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Sun, 28 Jun 2020 02:42:40 +0200 Subject: [PATCH 13/27] Move Depth offset from Field to HDField --- .../Editor/Material/ShaderGraph/HDFields.cs | 1 + .../Editor/Material/ShaderGraph/HDTarget.cs | 2 +- .../Editor/Material/ShaderGraph/SurfaceSubTarget.cs | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) 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 f00ed4f01fc..29aa3ddf7c8 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 @@ -56,6 +56,7 @@ static class HDFields public static FieldDescriptor Tangent = new FieldDescriptor(string.Empty, "Tangent", "_TANGENT 1"); 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 TransparentBackFace = new FieldDescriptor(string.Empty, "TransparentBackFace", string.Empty); public static FieldDescriptor TransparentDepthPostPass = new FieldDescriptor(string.Empty, "TransparentDepthPostPass", string.Empty); public static FieldDescriptor RayTracing = new FieldDescriptor(string.Empty, "RayTracing", string.Empty); 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 7d165c3035c..9f543738cd8 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 @@ -810,7 +810,7 @@ static class CoreKeywords { CoreKeywordDescriptors.BlendModePreserveSpecularLighting, new FieldCondition(HDFields.Unlit, false) }, { CoreKeywordDescriptors.AddPrecomputedVelocity }, { CoreKeywordDescriptors.TransparentWritesMotionVector }, - { CoreKeywordDescriptors.DepthOffset, new FieldCondition(Fields.DepthOffset, true) }, + { CoreKeywordDescriptors.DepthOffset, new FieldCondition(HDFields.DepthOffset, true) }, { CoreKeywordDescriptors.FogOnTransparent }, { CoreKeywordDescriptors.AlphaTest, new FieldCondition(Fields.AlphaTest, true) }, }; 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 64ef91d730b..ac4ee729e46 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 @@ -228,7 +228,7 @@ public override void GetFields(ref TargetFieldContext context) context.AddField(Fields.AlphaToMask, systemData.alphaTest); context.AddField(HDFields.TransparentBackFace, builtinData.backThenFrontRendering); - context.AddField(Fields.DepthOffset, builtinData.depthOffset && context.pass.validPixelBlocks.Contains(HDBlockFields.SurfaceDescription.DepthOffset)); + context.AddField(HDFields.DepthOffset, builtinData.depthOffset && context.pass.validPixelBlocks.Contains(HDBlockFields.SurfaceDescription.DepthOffset)); // Depth offset needs positionRWS and is now a multi_compile if (builtinData.depthOffset) From fef87dc476231b1e9c3d0af5898909da4fd62135 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Sun, 28 Jun 2020 02:43:53 +0200 Subject: [PATCH 14/27] Update Fields.cs --- .../Editor/Generation/TargetResources/Fields.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/com.unity.shadergraph/Editor/Generation/TargetResources/Fields.cs b/com.unity.shadergraph/Editor/Generation/TargetResources/Fields.cs index a7bcb486c6a..bc7cf4e0104 100644 --- a/com.unity.shadergraph/Editor/Generation/TargetResources/Fields.cs +++ b/com.unity.shadergraph/Editor/Generation/TargetResources/Fields.cs @@ -1,4 +1,4 @@ -namespace UnityEditor.ShaderGraph +namespace UnityEditor.ShaderGraph { [GenerationAPI] internal static class Fields @@ -30,7 +30,6 @@ internal static class Fields public static FieldDescriptor IsPreview = new FieldDescriptor(string.Empty, "isPreview", "SHADERGRAPH_PREVIEW"); public static FieldDescriptor LodCrossFade = new FieldDescriptor(string.Empty, "LodCrossFade", "_LODCROSSFADE 1"); public static FieldDescriptor AlphaToMask = new FieldDescriptor(string.Empty, "AlphaToMask", "_ALPHATOMASK_ON 1"); - public static FieldDescriptor DepthOffset = new FieldDescriptor(string.Empty, "DepthOffset", "_DEPTH_OFFSET 1"); #endregion } } From 1c35ee2214cbd6b68d203830fdd82d3886cf1009 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Sun, 28 Jun 2020 03:12:47 +0200 Subject: [PATCH 15/27] Fix define for BackThenFront --- .../Material/ShaderGraph/HDShaderPasses.cs | 22 +++------------- .../Editor/Material/ShaderGraph/HDTarget.cs | 25 +++++++++++++++++-- 2 files changed, 27 insertions(+), 20 deletions(-) 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 cfc251e5b64..7b75850d9f0 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 @@ -446,8 +446,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(), }; @@ -512,18 +512,11 @@ public static PassDescriptor GenerateTransparentDepthPrepass(bool supportLightin requiredFields = TransparentDepthPrepassFields, renderStates = GenerateRenderState(), pragmas = CorePragmas.DotsInstancedInV1AndV2, - defines = GenerateDefines(), + defines = CoreDefines.TransparentDepthPrepass, keywords = GenerateKeywords(), includes = GenerateIncludes(), }; - DefineCollection GenerateDefines() - { - var defines = new DefineCollection{ { RayTracingNode.GetRayTracingKeyword(), 0 } }; - - return defines; - } - KeywordCollection GenerateKeywords() { KeywordCollection keywords = new KeywordCollection { CoreKeywords.HDBase }; @@ -625,18 +618,11 @@ public static PassDescriptor GenerateTransparentDepthPostpass(bool supportLighti // Collections renderStates = GenerateRenderState(), pragmas = CorePragmas.DotsInstancedInV1AndV2, - defines = GenerateDefines(), + defines = CoreDefines.TransparentDepthPostpass, keywords = CoreKeywords.HDBase, includes = GenerateIncludes(), }; - DefineCollection GenerateDefines() - { - var defines = new DefineCollection{ CoreDefines.ShaderGraphRaytracingHigh }; - - return defines; - } - IncludeCollection GenerateIncludes() { var includes = new IncludeCollection(); 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 9f543738cd8..9ba64fe1510 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 @@ -845,7 +845,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 }, @@ -854,9 +854,19 @@ static class CoreKeywords { CoreKeywordDescriptors.Shadow }, { CoreKeywordDescriptors.ScreenSpaceShadow }, { CoreKeywordDescriptors.Decals }, + }; + + public static KeywordCollection Forward = new KeywordCollection + { + { ForwardBase }, { CoreKeywordDescriptors.LightList }, }; + public static KeywordCollection BackThenFrontTransparent = new KeywordCollection + { + { ForwardBase }, + }; + public static KeywordCollection RaytracingIndirect = new KeywordCollection { { HDBaseNoCrossFade }, @@ -900,7 +910,11 @@ static class CoreDefines public static DefineCollection TransparentDepthPrepass = new DefineCollection { { RayTracingNode.GetRayTracingKeyword(), 0 }, - { CoreKeywordDescriptors.WriteNormalBuffer, 1 }, + }; + + public static DefineCollection TransparentDepthPostpass = new DefineCollection + { + { RayTracingNode.GetRayTracingKeyword(), 0 }, }; public static DefineCollection Forward = new DefineCollection @@ -908,6 +922,13 @@ static class CoreDefines { CoreKeywordDescriptors.HasLightloop, 1 }, { 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 From c99a5910a73c57de29631d0c0da560075e8aaba9 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Sun, 28 Jun 2020 03:32:56 +0200 Subject: [PATCH 16/27] fix MINIMAL_GBUFFER for DXR pass --- .../Material/ShaderGraph/HDShaderPasses.cs | 6 ++-- .../Editor/Material/ShaderGraph/HDTarget.cs | 31 +++++++++++++++++-- 2 files changed, 31 insertions(+), 6 deletions(-) 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 7b75850d9f0..719fc2f5ce6 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 @@ -986,7 +986,7 @@ public static PassDescriptor GenerateRaytracingForward(bool supportLighting) // Collections pragmas = CorePragmas.RaytracingBasic, defines = supportLighting ? RaytracingForwardDefines : null, - keywords = CoreKeywords.RaytracingGBufferForward, + keywords = CoreKeywords.RaytracingForward, includes = GenerateIncludes(), }; @@ -1053,7 +1053,7 @@ public static PassDescriptor GenerateRaytracingGBuffer(bool supportLighting) // Collections pragmas = CorePragmas.RaytracingBasic, defines = supportLighting ? RaytracingGBufferDefines : null, - keywords = CoreKeywords.RaytracingGBufferForward, + keywords = CoreKeywords.RaytracingGBuffer, includes = GenerateIncludes(), }; @@ -1180,7 +1180,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/HDTarget.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDTarget.cs index 9ba64fe1510..a85ecfd6945 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 @@ -828,6 +828,12 @@ static class CoreKeywords { CoreKeywordDescriptors.DynamicLightmap }, }; + public static KeywordCollection LightmapsRaytracing = new KeywordCollection + { + { CoreKeywordDescriptors.Lightmap }, + { CoreKeywordDescriptors.DirectionalLightmapCombined }, + }; + public static KeywordCollection WriteMsaaDepth = new KeywordCollection { { CoreKeywordDescriptors.WriteMsaaDepth }, @@ -870,13 +876,23 @@ static class CoreKeywords public static KeywordCollection RaytracingIndirect = new KeywordCollection { { HDBaseNoCrossFade }, - { Lightmaps }, + { CoreKeywordDescriptors.DebugDisplay }, + { LightmapsRaytracing }, }; - public static KeywordCollection RaytracingGBufferForward = new KeywordCollection + public static KeywordCollection RaytracingForward = new KeywordCollection { { HDBaseNoCrossFade }, - { Lightmaps }, + { CoreKeywordDescriptors.DebugDisplay }, + { LightmapsRaytracing }, + }; + + public static KeywordCollection RaytracingGBuffer = new KeywordCollection + { + { HDBaseNoCrossFade }, + { CoreKeywordDescriptors.DebugDisplay }, + { LightmapsRaytracing }, + { CoreKeywordDescriptors.RaytraceMinimalGBuffer }, }; public static KeywordCollection RaytracingVisiblity = new KeywordCollection @@ -1299,6 +1315,15 @@ static class CoreKeywordDescriptors 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", From dcb7330140c737242bc6ee3db50d9f1783959fb5 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Sun, 28 Jun 2020 03:44:04 +0200 Subject: [PATCH 17/27] Fix typo + fix VT for unlit --- .../Editor/Material/ShaderGraph/HDShaderPasses.cs | 4 ++-- .../Editor/Material/ShaderGraph/SurfaceSubTarget.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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 719fc2f5ce6..02506681993 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 @@ -370,7 +370,7 @@ IncludeCollection GenerateIncludes() #region Forward Only - public static PassDescriptor GenereateForwardOnlyPass(bool supportLighting) + public static PassDescriptor GenerateForwardOnlyPass(bool supportLighting) { return new PassDescriptor { @@ -388,7 +388,7 @@ public static PassDescriptor GenereateForwardOnlyPass(bool supportLighting) keywords = supportLighting ? CoreKeywords.Forward : UnlitForwardKeywords, includes = GenerateIncludes(), - virtualTextureFeedback = supportLighting ? false : true, + virtualTextureFeedback = true, }; IncludeCollection GenerateIncludes() 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 ac4ee729e46..315c1030e35 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 @@ -87,7 +87,7 @@ PassCollection GetPasses() if (supportForward) { passes.Add(HDShaderPasses.GenerateDepthForwardOnlyPass(supportLighting)); - passes.Add(HDShaderPasses.GenereateForwardOnlyPass(supportLighting)); + passes.Add(HDShaderPasses.GenerateForwardOnlyPass(supportLighting)); } if (supportDistortion) From 62f608bdac7662acd9100ffb72894371d62f3299 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Sun, 28 Jun 2020 03:47:03 +0200 Subject: [PATCH 18/27] Fix motion vector for transparent on forward material --- .../Editor/Material/ShaderGraph/HDTarget.cs | 15 --------------- 1 file changed, 15 deletions(-) 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 a85ecfd6945..a213b8b7f64 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 @@ -660,21 +660,6 @@ public static class Uniforms }; public static RenderStateCollection Forward = new RenderStateCollection - { - { RenderState.Blend(Uniforms.srcBlend, Uniforms.dstBlend, Uniforms.alphaSrcBlend, Uniforms.alphaDstBlend) }, - { RenderState.Cull(Uniforms.cullModeForward) }, - { RenderState.ZWrite(Uniforms.zWrite) }, - { RenderState.ZTest(Uniforms.zTestDepthEqualForOpaque) }, - { 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) }, From f0dd78bd991b1d0b8215845e3e6cd9a07e4ecd7e Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Sun, 28 Jun 2020 03:56:33 +0200 Subject: [PATCH 19/27] Fix compile issue --- .../Editor/Material/ShaderGraph/HDShaderPasses.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 02506681993..e7488b29a87 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 @@ -777,7 +777,7 @@ public static PassDescriptor GenerateLitForward() // Collections requiredFields = CoreRequiredFields.LitMinimal, - renderStates = CoreRenderStates.ForwardColorMask, + renderStates = CoreRenderStates.Forward, pragmas = CorePragmas.DotsInstancedInV1AndV2, defines = CoreDefines.Forward, keywords = CoreKeywords.Forward, From c1ba69a37a796fb5232ab92df8ca0f5836650ebe Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Sun, 28 Jun 2020 05:18:43 +0200 Subject: [PATCH 20/27] Lot of fix on unlit shader --- .../Eye/ShaderGraph/EyeSubTarget.Migration.cs | 4 +- .../ShaderGraph/HairSubTarget.Migration.cs | 8 +-- .../ShaderGraph/HDLitSubTarget.Migration.cs | 8 +-- .../Editor/Material/ShaderGraph/HDFields.cs | 1 + .../Material/ShaderGraph/HDShaderPasses.cs | 67 ++++++++++++++----- .../Editor/Material/ShaderGraph/HDTarget.cs | 18 +++++ .../ShaderGraph/SurfaceOptionPropertyBlock.cs | 4 +- .../Material/ShaderGraph/SurfaceSubTarget.cs | 31 ++++++--- .../ShaderGraph/TargetData/SystemData.cs | 23 ++++--- .../ShaderGraph/Templates/ShaderPass.template | 2 +- .../Runtime/Material/Unlit/Unlit.shader | 8 +-- 11 files changed, 120 insertions(+), 54 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 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 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 315c1030e35..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,11 +79,20 @@ PassCollection GetPasses() HDShaderPasses.GenerateSceneSelection(supportLighting), HDShaderPasses.GenerateMotionVectors(supportLighting, supportForward), { HDShaderPasses.GenerateBackThenFront(supportLighting), new FieldCondition(HDFields.TransparentBackFace, true)}, - // We always generate the TransparentDepthPrepass as it can be use with SSR transparent - HDShaderPasses.GenerateTransparentDepthPrepass(supportLighting), { HDShaderPasses.GenerateTransparentDepthPostpass(supportLighting), new FieldCondition(HDFields.TransparentDepthPostPass, true)} }; + if (supportLighting) + { + // We always generate the TransparentDepthPrepass as it can be use with SSR transparent + passes.Add(HDShaderPasses.GenerateTransparentDepthPrepass(true)); + } + else + { + // We only generate the pass if requested + passes.Add(HDShaderPasses.GenerateTransparentDepthPrepass(false), new FieldCondition(HDFields.TransparentDepthPrePass, true)); + } + if (supportForward) { passes.Add(HDShaderPasses.GenerateDepthForwardOnlyPass(supportLighting)); @@ -215,18 +224,20 @@ 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"; - + // 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)); // Features & Misc - context.AddField(Fields.LodCrossFade, systemData.supportLodCrossFade); - context.AddField(Fields.AlphaToMask, systemData.alphaTest); - context.AddField(HDFields.TransparentBackFace, builtinData.backThenFrontRendering); + 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.DepthOffset, builtinData.depthOffset && context.pass.validPixelBlocks.Contains(HDBlockFields.SurfaceDescription.DepthOffset)); @@ -263,8 +274,8 @@ public override void GetActiveBlocks(ref TargetActiveBlockContext context) context.AddBlock(BlockFields.SurfaceDescription.AlphaClipThreshold, systemData.alphaTest); // Alpha Test - context.AddBlock(HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPrepass, systemData.alphaTest && systemData.alphaTestDepthPrepass); - context.AddBlock(HDBlockFields.SurfaceDescription.AlphaClipThresholdDepthPostpass, systemData.alphaTest && systemData.alphaTestDepthPostpass); + 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 @@ -330,7 +341,7 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera // 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( 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 1cb5cc3de5b..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 @@ -67,7 +67,7 @@ Pass // 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) + #if !defined(_DISABLE_SSR_TRANSPARENT) && !defined(SHADER_UNLIT) #define WRITE_NORMAL_BUFFER #endif #endif 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" From 317b45cbc476084c823e94c1077664e6ff0b8805 Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Sun, 28 Jun 2020 05:35:27 +0200 Subject: [PATCH 21/27] fix compile issue --- .../Runtime/Material/Lit/LitData.hlsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6b1f899717a..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 @@ -223,7 +223,7 @@ void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs p #elif SHADERPASS == SHADERPASS_TRANSPARENT_DEPTH_POSTPASS float alphaCutoff = _AlphaCutoffPostpass; #elif SHADERPASS == SHADERPASS_SHADOWS - float alphaCutoff = _UseShadowThreshold ? _AlphaCutoffShadow : alphaCutoff; + float alphaCutoff = _UseShadowThreshold ? _AlphaCutoffShadow : _AlphaCutoff; #else float alphaCutoff = _AlphaCutoff; #endif From 526c8cbe64e819e25a78a5e227dc3cbf561eb885 Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Sun, 28 Jun 2020 05:57:36 +0200 Subject: [PATCH 22/27] Fix Material for test stacklit DXR SG --- .../Shader Graphs_StackLit_Transparent.mat | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) 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 From 614c0d77d8c450d2277164a71dba0aa1c444a3b9 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Sun, 28 Jun 2020 12:11:48 +0200 Subject: [PATCH 23/27] Fix the Material surfaceOption --- .../Material/LayeredLit/LayeredLitGUI.cs | 2 +- .../Editor/Material/Lit/LitGUI.cs | 2 +- .../Material/UIBlocks/SurfaceOptionUIBlock.cs | 63 ++++++++++++------- .../Material/Unlit/ShaderGraph/HDUnlitGUI.cs | 7 +-- 4 files changed, 43 insertions(+), 31 deletions(-) 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/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/UIBlocks/SurfaceOptionUIBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/SurfaceOptionUIBlock.cs index 0d7220d5d10..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 @@ -25,12 +25,14 @@ public enum Features DoubleSidedNormalMode = 1 << 6, BackThenFrontRendering = 1 << 7, ReceiveSSR = 1 << 8, - ShowAfterPostProcessPass = 1 << 9, - AlphaToMask = 1 << 10, - ShowPrePassAndPostPass = 1 << 11, - ShowDepthOffsetOnly = 1 << 12, - Unlit = Surface | BlendMode | DoubleSided | DoubleSidedNormalMode | AlphaCutoff | AlphaCutoffShadowThreshold | AlphaCutoffThreshold | BackThenFrontRendering | ShowAfterPostProcessPass | AlphaToMask, - Lit = All ^ ShowDepthOffsetOnly, + 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, } @@ -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,22 +398,29 @@ 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) { // For shadergraphs we show this slider only if the feature is enabled in the shader settings. bool showUseShadowThreshold = useShadowThreshold != null; - var shader = materials[0].shader; - if (showUseShadowThreshold && shader.IsShaderGraph()) + if (isShaderGraph) showUseShadowThreshold = shader.GetPropertyDefaultFloatValue(shader.FindPropertyIndex(kUseShadowThreshold)) > 0.0f; if (showUseShadowThreshold) @@ -420,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); @@ -428,7 +442,7 @@ 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) @@ -497,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) { @@ -779,7 +796,7 @@ void DrawLitSurfaceOptions() } } - if ((m_Features & Features.ShowDepthOffsetOnly) != 0) + if ((m_Features & Features.ShowDepthOffsetOnly) != 0 && depthOffsetEnable != null) materialEditor.ShaderProperty(depthOffsetEnable, Styles.depthOffsetEnableText); else if (displacementMode != null) { 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 33c99cd3d68..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,12 +12,7 @@ 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 - | SurfaceOptionUIBlock.Features.ShowDepthOffsetOnly; + const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit; MaterialUIBlockList uiBlocks = new MaterialUIBlockList { From 3397fac41dff3aa959aecd4356ed83f864cf1ca3 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Sun, 28 Jun 2020 18:46:57 +0200 Subject: [PATCH 24/27] Update HDSubShaderUtilities.cs --- .../ShaderGraph/HDSubShaderUtilities.cs | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) 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 a331e20c9a7..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,20 +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; - bool receiveDecals = false; - bool blendPreserveSpecular = false; if (lightingData != null) { ssrStencil = systemData.surfaceType == SurfaceType.Opaque ? lightingData.receiveSSR : lightingData.receiveSSRTransparent; - receiveSSROpaque = lightingData.receiveSSR; - receiveSSRTransparent = lightingData.receiveSSRTransparent; - receiveDecals = lightingData.receiveDecals; - blendPreserveSpecular = lightingData.blendPreserveSpecular; + 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 @@ -105,12 +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); - collector.AddToggleProperty(kSupportDecals, receiveDecals); - collector.AddToggleProperty(kEnableBlendModePreserveSpecularLighting, blendPreserveSpecular); } public static void AddBlendingStatesShaderProperties( From f8a59ee43a79ce4ea3774d1cf7485c125ff1fe04 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Sun, 28 Jun 2020 19:54:44 +0200 Subject: [PATCH 25/27] Fix Motion Vector for animatoin UX --- .../Material/UIBlocks/ShaderGraphUIBlock.cs | 54 +++++++++---------- .../Editor/Material/Unlit/BaseUnlitGUI.cs | 5 +- 2 files changed, 26 insertions(+), 33 deletions(-) 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/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); - } - } } From 06507f69d67d6281bafb125478f2912002d948f8 Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Sun, 28 Jun 2020 20:07:09 +0200 Subject: [PATCH 26/27] Update Material for VFX project --- .../VFXTests/GraphicsTests/Materials/BlackMaterial.mat | 3 ++- .../VFXTests/GraphicsTests/Materials/Unlit_Black.mat | 3 ++- .../VFXTests/GraphicsTests/Materials/Unlit_White.mat | 3 ++- .../VFXTests/GraphicsTests/Materials/WhiteMaterial.mat | 3 ++- .../VFXTests/GraphicsTests/PositionDepthOperator/Blue.mat | 3 ++- .../VFXTests/GraphicsTests/PositionDepthOperator/Green.mat | 3 ++- .../VFXTests/GraphicsTests/PositionDepthOperator/Red.mat | 3 ++- .../GraphicsTests/Shadergraph/SampleScene/EmissiveRed.mat | 3 ++- .../Shadergraph/SampleScene/ReferenceSampleColor.mat | 3 ++- .../Shadergraph/SampleScene/ReferenceSampleDepth.mat | 3 ++- .../Shadergraph/SampleScene/ReferenceSampleGI.mat | 3 ++- .../Assets/Tests/TransparencyOverdraw/OpaqueUnlit.mat | 3 ++- .../Assets/Tests/TransparencyOverdraw/TransparentLit.mat | 3 ++- .../Assets/Tests/TransparencyOverdraw/TransparentLowRes.mat | 3 ++- .../Assets/Tests/TransparencyOverdraw/TransparentUnlit.mat | 3 ++- .../Scenes/007_SimpleMaterial.mat | 6 +++++- .../Scenes/009_MultiCamera.mat | 6 +++++- 17 files changed, 40 insertions(+), 17 deletions(-) diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/BlackMaterial.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/BlackMaterial.mat index 5249b8183b8..5e0263ce132 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/BlackMaterial.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/BlackMaterial.mat @@ -226,6 +226,7 @@ Material: - _NormalMapSpace: 0 - _NormalScale: 1 - _OcclusionStrength: 1 + - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 @@ -318,4 +319,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 4 + version: 5 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/Unlit_Black.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/Unlit_Black.mat index 4194ce729ba..2bdfdc0b6c8 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/Unlit_Black.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/Unlit_Black.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 @@ -200,6 +200,7 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 + - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/Unlit_White.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/Unlit_White.mat index ee84b9c19e2..f9e9444beaa 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/Unlit_White.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/Unlit_White.mat @@ -187,6 +187,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/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/WhiteMaterial.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/WhiteMaterial.mat index 3b61485426d..ad623eda68c 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/WhiteMaterial.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/WhiteMaterial.mat @@ -187,6 +187,7 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1.088 + - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 @@ -273,4 +274,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 4 + version: 5 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/PositionDepthOperator/Blue.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/PositionDepthOperator/Blue.mat index f67087aaa0d..33043d9bb71 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/PositionDepthOperator/Blue.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/PositionDepthOperator/Blue.mat @@ -194,6 +194,7 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 + - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 @@ -280,4 +281,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 4 + version: 5 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/PositionDepthOperator/Green.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/PositionDepthOperator/Green.mat index a607fc81211..a6c6ca03240 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/PositionDepthOperator/Green.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/PositionDepthOperator/Green.mat @@ -194,6 +194,7 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 + - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 @@ -280,4 +281,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 4 + version: 5 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/PositionDepthOperator/Red.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/PositionDepthOperator/Red.mat index 38d7a3034bd..fdabb46b637 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/PositionDepthOperator/Red.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/PositionDepthOperator/Red.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 @@ -207,6 +207,7 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 + - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/EmissiveRed.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/EmissiveRed.mat index 7dc2f5c5f99..8410aaa67e9 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/EmissiveRed.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/EmissiveRed.mat @@ -184,6 +184,7 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 + - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 @@ -266,4 +267,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 4 + version: 5 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ReferenceSampleColor.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ReferenceSampleColor.mat index 13cd194f154..3293c96a651 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ReferenceSampleColor.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ReferenceSampleColor.mat @@ -184,6 +184,7 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 + - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 @@ -266,4 +267,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 4 + version: 5 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ReferenceSampleDepth.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ReferenceSampleDepth.mat index 1b47f685309..eb250d4a584 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ReferenceSampleDepth.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ReferenceSampleDepth.mat @@ -184,6 +184,7 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 + - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 @@ -266,4 +267,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 4 + version: 5 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ReferenceSampleGI.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ReferenceSampleGI.mat index 20403719430..86560012779 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ReferenceSampleGI.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ReferenceSampleGI.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 @@ -197,6 +197,7 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 + - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/OpaqueUnlit.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/OpaqueUnlit.mat index 9d05d3de312..e4216834439 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/OpaqueUnlit.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/OpaqueUnlit.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 @@ -198,6 +198,7 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 + - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/TransparentLit.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/TransparentLit.mat index fc792686435..1d9ee3ad77e 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/TransparentLit.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/TransparentLit.mat @@ -185,6 +185,7 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 + - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 @@ -267,4 +268,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 4 + version: 5 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/TransparentLowRes.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/TransparentLowRes.mat index 09d09f85a93..c38ada4f643 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/TransparentLowRes.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/TransparentLowRes.mat @@ -186,6 +186,7 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 + - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 @@ -267,4 +268,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 4 + version: 5 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/TransparentUnlit.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/TransparentUnlit.mat index 356d2603f41..0ba4bd4b636 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/TransparentUnlit.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/TransparentUnlit.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 @@ -199,6 +199,7 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 + - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 diff --git a/com.unity.testing.visualeffectgraph/Scenes/007_SimpleMaterial.mat b/com.unity.testing.visualeffectgraph/Scenes/007_SimpleMaterial.mat index 94be27a2d60..bbbd2385b68 100644 --- a/com.unity.testing.visualeffectgraph/Scenes/007_SimpleMaterial.mat +++ b/com.unity.testing.visualeffectgraph/Scenes/007_SimpleMaterial.mat @@ -24,6 +24,7 @@ Material: serializedVersion: 3 m_TexEnvs: [] m_Floats: + - _AddPrecomputedVelocity: 0 - _AlphaCutoffEnable: 0 - _AlphaDstBlend: 0 - _AlphaSrcBlend: 1 @@ -31,10 +32,12 @@ Material: - _BlendMode: 0 - _CullMode: 2 - _CullModeForward: 2 + - _DepthOffsetEnable: 0 - _DoubleSidedEnable: 0 - _DoubleSidedNormalMode: 2 - _DstBlend: 0 - _EnableFogOnTransparent: 1 + - _OpaqueCullMode: 2 - _ReceivesSSR: 0 - _ReceivesSSRTransparent: 0 - _RenderQueueType: 1 @@ -56,6 +59,7 @@ Material: - _TransparentDepthPostpassEnable: 0 - _TransparentDepthPrepassEnable: 0 - _TransparentSortPriority: 0 + - _TransparentWritingMotionVec: 0 - _TransparentZWrite: 0 - _UseShadowThreshold: 0 - _ZTestDepthEqualForOpaque: 3 @@ -79,4 +83,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 4 + version: 5 diff --git a/com.unity.testing.visualeffectgraph/Scenes/009_MultiCamera.mat b/com.unity.testing.visualeffectgraph/Scenes/009_MultiCamera.mat index 69ffd5fe378..48cb7c699a3 100644 --- a/com.unity.testing.visualeffectgraph/Scenes/009_MultiCamera.mat +++ b/com.unity.testing.visualeffectgraph/Scenes/009_MultiCamera.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 @@ -75,6 +75,7 @@ Material: m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} m_Floats: + - _AddPrecomputedVelocity: 0 - _AlphaClip: 0 - _AlphaCutoffEnable: 0 - _AlphaDstBlend: 0 @@ -87,6 +88,7 @@ Material: - _CullMode: 2 - _CullModeForward: 2 - _Cutoff: 0.5 + - _DepthOffsetEnable: 0 - _DoubleSidedEnable: 0 - _DoubleSidedNormalMode: 2 - _DstBlend: 0 @@ -97,6 +99,7 @@ Material: - _GlossyReflections: 0 - _Metallic: 0 - _OcclusionStrength: 1 + - _OpaqueCullMode: 2 - _QueueOffset: 0 - _ReceiveShadows: 1 - _ReceivesSSR: 0 @@ -124,6 +127,7 @@ Material: - _TransparentDepthPostpassEnable: 0 - _TransparentDepthPrepassEnable: 0 - _TransparentSortPriority: 0 + - _TransparentWritingMotionVec: 0 - _TransparentZWrite: 0 - _UseShadowThreshold: 0 - _WorkflowMode: 1 From 83b53507135da522b402a573fb82a14d40990812 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Sun, 28 Jun 2020 20:16:15 +0200 Subject: [PATCH 27/27] Revert "Update Material for VFX project" This reverts commit 06507f69d67d6281bafb125478f2912002d948f8. --- .../VFXTests/GraphicsTests/Materials/BlackMaterial.mat | 3 +-- .../VFXTests/GraphicsTests/Materials/Unlit_Black.mat | 3 +-- .../VFXTests/GraphicsTests/Materials/Unlit_White.mat | 3 +-- .../VFXTests/GraphicsTests/Materials/WhiteMaterial.mat | 3 +-- .../VFXTests/GraphicsTests/PositionDepthOperator/Blue.mat | 3 +-- .../VFXTests/GraphicsTests/PositionDepthOperator/Green.mat | 3 +-- .../VFXTests/GraphicsTests/PositionDepthOperator/Red.mat | 3 +-- .../GraphicsTests/Shadergraph/SampleScene/EmissiveRed.mat | 3 +-- .../Shadergraph/SampleScene/ReferenceSampleColor.mat | 3 +-- .../Shadergraph/SampleScene/ReferenceSampleDepth.mat | 3 +-- .../Shadergraph/SampleScene/ReferenceSampleGI.mat | 3 +-- .../Assets/Tests/TransparencyOverdraw/OpaqueUnlit.mat | 3 +-- .../Assets/Tests/TransparencyOverdraw/TransparentLit.mat | 3 +-- .../Assets/Tests/TransparencyOverdraw/TransparentLowRes.mat | 3 +-- .../Assets/Tests/TransparencyOverdraw/TransparentUnlit.mat | 3 +-- .../Scenes/007_SimpleMaterial.mat | 6 +----- .../Scenes/009_MultiCamera.mat | 6 +----- 17 files changed, 17 insertions(+), 40 deletions(-) diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/BlackMaterial.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/BlackMaterial.mat index 5e0263ce132..5249b8183b8 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/BlackMaterial.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/BlackMaterial.mat @@ -226,7 +226,6 @@ Material: - _NormalMapSpace: 0 - _NormalScale: 1 - _OcclusionStrength: 1 - - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 @@ -319,4 +318,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 5 + version: 4 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/Unlit_Black.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/Unlit_Black.mat index 2bdfdc0b6c8..4194ce729ba 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/Unlit_Black.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/Unlit_Black.mat @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 5 + version: 4 --- !u!21 &2100000 Material: serializedVersion: 6 @@ -200,7 +200,6 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 - - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/Unlit_White.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/Unlit_White.mat index f9e9444beaa..ee84b9c19e2 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/Unlit_White.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/Unlit_White.mat @@ -187,7 +187,6 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 - - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 @@ -266,4 +265,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 5 + version: 4 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/WhiteMaterial.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/WhiteMaterial.mat index ad623eda68c..3b61485426d 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/WhiteMaterial.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Materials/WhiteMaterial.mat @@ -187,7 +187,6 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1.088 - - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 @@ -274,4 +273,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 5 + version: 4 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/PositionDepthOperator/Blue.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/PositionDepthOperator/Blue.mat index 33043d9bb71..f67087aaa0d 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/PositionDepthOperator/Blue.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/PositionDepthOperator/Blue.mat @@ -194,7 +194,6 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 - - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 @@ -281,4 +280,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 5 + version: 4 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/PositionDepthOperator/Green.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/PositionDepthOperator/Green.mat index a6c6ca03240..a607fc81211 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/PositionDepthOperator/Green.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/PositionDepthOperator/Green.mat @@ -194,7 +194,6 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 - - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 @@ -281,4 +280,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 5 + version: 4 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/PositionDepthOperator/Red.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/PositionDepthOperator/Red.mat index fdabb46b637..38d7a3034bd 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/PositionDepthOperator/Red.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/PositionDepthOperator/Red.mat @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 5 + version: 4 --- !u!21 &2100000 Material: serializedVersion: 6 @@ -207,7 +207,6 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 - - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/EmissiveRed.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/EmissiveRed.mat index 8410aaa67e9..7dc2f5c5f99 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/EmissiveRed.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/EmissiveRed.mat @@ -184,7 +184,6 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 - - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 @@ -267,4 +266,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 5 + version: 4 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ReferenceSampleColor.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ReferenceSampleColor.mat index 3293c96a651..13cd194f154 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ReferenceSampleColor.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ReferenceSampleColor.mat @@ -184,7 +184,6 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 - - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 @@ -267,4 +266,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 5 + version: 4 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ReferenceSampleDepth.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ReferenceSampleDepth.mat index eb250d4a584..1b47f685309 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ReferenceSampleDepth.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ReferenceSampleDepth.mat @@ -184,7 +184,6 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 - - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 @@ -267,4 +266,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 5 + version: 4 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ReferenceSampleGI.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ReferenceSampleGI.mat index 86560012779..20403719430 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ReferenceSampleGI.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/VFXTests/GraphicsTests/Shadergraph/SampleScene/ReferenceSampleGI.mat @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 5 + version: 4 --- !u!21 &2100000 Material: serializedVersion: 6 @@ -197,7 +197,6 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 - - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/OpaqueUnlit.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/OpaqueUnlit.mat index e4216834439..9d05d3de312 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/OpaqueUnlit.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/OpaqueUnlit.mat @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 5 + version: 4 --- !u!21 &2100000 Material: serializedVersion: 6 @@ -198,7 +198,6 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 - - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/TransparentLit.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/TransparentLit.mat index 1d9ee3ad77e..fc792686435 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/TransparentLit.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/TransparentLit.mat @@ -185,7 +185,6 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 - - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 @@ -268,4 +267,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 5 + version: 4 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/TransparentLowRes.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/TransparentLowRes.mat index c38ada4f643..09d09f85a93 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/TransparentLowRes.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/TransparentLowRes.mat @@ -186,7 +186,6 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 - - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 @@ -268,4 +267,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 5 + version: 4 diff --git a/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/TransparentUnlit.mat b/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/TransparentUnlit.mat index 0ba4bd4b636..356d2603f41 100644 --- a/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/TransparentUnlit.mat +++ b/TestProjects/VisualEffectGraph_HDRP/Assets/Tests/TransparencyOverdraw/TransparentUnlit.mat @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 5 + version: 4 --- !u!21 &2100000 Material: serializedVersion: 6 @@ -199,7 +199,6 @@ Material: - _Metallic: 0 - _NormalMapSpace: 0 - _NormalScale: 1 - - _OpaqueCullMode: 2 - _PPDLodThreshold: 5 - _PPDMaxSamples: 15 - _PPDMinSamples: 5 diff --git a/com.unity.testing.visualeffectgraph/Scenes/007_SimpleMaterial.mat b/com.unity.testing.visualeffectgraph/Scenes/007_SimpleMaterial.mat index bbbd2385b68..94be27a2d60 100644 --- a/com.unity.testing.visualeffectgraph/Scenes/007_SimpleMaterial.mat +++ b/com.unity.testing.visualeffectgraph/Scenes/007_SimpleMaterial.mat @@ -24,7 +24,6 @@ Material: serializedVersion: 3 m_TexEnvs: [] m_Floats: - - _AddPrecomputedVelocity: 0 - _AlphaCutoffEnable: 0 - _AlphaDstBlend: 0 - _AlphaSrcBlend: 1 @@ -32,12 +31,10 @@ Material: - _BlendMode: 0 - _CullMode: 2 - _CullModeForward: 2 - - _DepthOffsetEnable: 0 - _DoubleSidedEnable: 0 - _DoubleSidedNormalMode: 2 - _DstBlend: 0 - _EnableFogOnTransparent: 1 - - _OpaqueCullMode: 2 - _ReceivesSSR: 0 - _ReceivesSSRTransparent: 0 - _RenderQueueType: 1 @@ -59,7 +56,6 @@ Material: - _TransparentDepthPostpassEnable: 0 - _TransparentDepthPrepassEnable: 0 - _TransparentSortPriority: 0 - - _TransparentWritingMotionVec: 0 - _TransparentZWrite: 0 - _UseShadowThreshold: 0 - _ZTestDepthEqualForOpaque: 3 @@ -83,4 +79,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 5 + version: 4 diff --git a/com.unity.testing.visualeffectgraph/Scenes/009_MultiCamera.mat b/com.unity.testing.visualeffectgraph/Scenes/009_MultiCamera.mat index 48cb7c699a3..69ffd5fe378 100644 --- a/com.unity.testing.visualeffectgraph/Scenes/009_MultiCamera.mat +++ b/com.unity.testing.visualeffectgraph/Scenes/009_MultiCamera.mat @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 5 + version: 4 --- !u!21 &2100000 Material: serializedVersion: 6 @@ -75,7 +75,6 @@ Material: m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} m_Floats: - - _AddPrecomputedVelocity: 0 - _AlphaClip: 0 - _AlphaCutoffEnable: 0 - _AlphaDstBlend: 0 @@ -88,7 +87,6 @@ Material: - _CullMode: 2 - _CullModeForward: 2 - _Cutoff: 0.5 - - _DepthOffsetEnable: 0 - _DoubleSidedEnable: 0 - _DoubleSidedNormalMode: 2 - _DstBlend: 0 @@ -99,7 +97,6 @@ Material: - _GlossyReflections: 0 - _Metallic: 0 - _OcclusionStrength: 1 - - _OpaqueCullMode: 2 - _QueueOffset: 0 - _ReceiveShadows: 1 - _ReceivesSSR: 0 @@ -127,7 +124,6 @@ Material: - _TransparentDepthPostpassEnable: 0 - _TransparentDepthPrepassEnable: 0 - _TransparentSortPriority: 0 - - _TransparentWritingMotionVec: 0 - _TransparentZWrite: 0 - _UseShadowThreshold: 0 - _WorkflowMode: 1