From 767864849b1deab6b8f46f67a1f559ac0f2cad39 Mon Sep 17 00:00:00 2001 From: Vladislav Kantaev Date: Fri, 10 Nov 2023 23:49:54 +0100 Subject: [PATCH] Shader Graph: add float material property for Alpha to Coverage --- .../com.deltation.toon-rp/Editor/ShaderGUI/PropertyNames.cs | 1 + .../Editor/ShaderGraph/Targets/ToonSubTarget.cs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Packages/com.deltation.toon-rp/Editor/ShaderGUI/PropertyNames.cs b/Packages/com.deltation.toon-rp/Editor/ShaderGUI/PropertyNames.cs index 65d6b3d2..23bb64b6 100644 --- a/Packages/com.deltation.toon-rp/Editor/ShaderGUI/PropertyNames.cs +++ b/Packages/com.deltation.toon-rp/Editor/ShaderGUI/PropertyNames.cs @@ -7,6 +7,7 @@ public static class PropertyNames public const string SurfaceType = "_SurfaceType"; public const string AlphaClipping = "_AlphaClipping"; + public const string AlphaToCoverage = "_AlphaToCoverage"; public const string AlphaClipThreshold = "_AlphaClipThreshold"; public const string BlendMode = "_BlendMode"; public const string BlendSrc = "_BlendSrc"; diff --git a/Packages/com.deltation.toon-rp/Editor/ShaderGraph/Targets/ToonSubTarget.cs b/Packages/com.deltation.toon-rp/Editor/ShaderGraph/Targets/ToonSubTarget.cs index bd6fb07d..69415c3c 100644 --- a/Packages/com.deltation.toon-rp/Editor/ShaderGraph/Targets/ToonSubTarget.cs +++ b/Packages/com.deltation.toon-rp/Editor/ShaderGraph/Targets/ToonSubTarget.cs @@ -69,6 +69,7 @@ public override void ProcessPreviewMaterial(Material material) material.SetFloat(PropertyNames.SurfaceType, (float) target.SurfaceType); material.SetFloat(PropertyNames.BlendMode, (float) target.AlphaMode); material.SetFloat(PropertyNames.AlphaClipping, target.AlphaClip ? 1.0f : 0.0f); + material.SetFloat(PropertyNames.AlphaToCoverage, target.AlphaToCoverage ? 1.0f : 0.0f); material.SetFloat(PropertyNames.ForceDisableFogPropertyName, !target.Fog ? 1.0f : 0.0f); material.SetFloat(PropertyNames.RenderFace, (int) target.RenderFace); material.SetFloat(PropertyNames.CastShadows, target.CastShadows ? 1.0f : 0.0f); @@ -110,6 +111,7 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera collector.AddFloatProperty(PropertyNames.SurfaceType, (float) target.SurfaceType); collector.AddFloatProperty(PropertyNames.BlendMode, (float) target.AlphaMode); collector.AddFloatProperty(PropertyNames.AlphaClipping, target.AlphaClip ? 1.0f : 0.0f); + collector.AddFloatProperty(PropertyNames.AlphaToCoverage, target.AlphaToCoverage ? 1.0f : 0.0f); collector.AddFloatProperty(PropertyNames.ForceDisableFogPropertyName, !target.Fog ? 1.0f : 0.0f); collector.AddFloatProperty(PropertyNames.BlendSrc, 1.0f ); // always set by material inspector, ok to have incorrect values here