From f11dd1fc54bb959aedef8089358c5b5f6150d135 Mon Sep 17 00:00:00 2001 From: Dieter De Baets Date: Wed, 18 Aug 2021 21:33:37 +0200 Subject: [PATCH] Fixed a serialization bug wrt PVT property flags when using subgraphs. This fixes SRP batcher compatibility --- com.unity.shadergraph/CHANGELOG.md | 1 + .../Data/Graphs/VirtualTextureShaderProperty.cs | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/com.unity.shadergraph/CHANGELOG.md b/com.unity.shadergraph/CHANGELOG.md index d208a303eaf..b21e0052464 100644 --- a/com.unity.shadergraph/CHANGELOG.md +++ b/com.unity.shadergraph/CHANGELOG.md @@ -130,6 +130,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed the BuiltIn Target to perform shader variant stripping [1345580] (https://issuetracker.unity3d.com/product/unity/issues/guid/1345580/) - Fixed incorrect warning while using VFXTarget - Fixed a bug with Sprite Targets in ShaderGraph not rendering correctly in game view [1352225] +- Fixed a serialization bug wrt PVT property flags when using subgraphs. This fixes SRP batcher compatibility. ## [11.0.0] - 2020-10-21 diff --git a/com.unity.shadergraph/Editor/Data/Graphs/VirtualTextureShaderProperty.cs b/com.unity.shadergraph/Editor/Data/Graphs/VirtualTextureShaderProperty.cs index 2320c903db0..100992d8be7 100644 --- a/com.unity.shadergraph/Editor/Data/Graphs/VirtualTextureShaderProperty.cs +++ b/com.unity.shadergraph/Editor/Data/Graphs/VirtualTextureShaderProperty.cs @@ -75,9 +75,8 @@ internal override void ForeachHLSLProperty(Action action) int numLayers = value.layers.Count; if (numLayers > 0) { - HLSLDeclaration decl = HLSLDeclaration.UnityPerMaterial; - if (value.procedural) - decl = GetDefaultHLSLDeclaration(); + // PVT should always be Global to be compatible with SRP batcher + HLSLDeclaration decl = (value.procedural) ? HLSLDeclaration.Global : HLSLDeclaration.UnityPerMaterial; action(new HLSLProperty(HLSLType._CUSTOM, referenceName + "_CBDecl", decl, concretePrecision) { @@ -206,8 +205,11 @@ internal void AddTextureInfo(List infos) public override void OnAfterDeserialize(string json) { - // VT shader properties must always be exposed - generatePropertyBlock = true; + if (!value.procedural) + { + // non procedural VT shader properties must always be exposed + generatePropertyBlock = true; + } } } }