From fa44a3879806176d48d0c16a960a2c4fe6198dd6 Mon Sep 17 00:00:00 2001 From: yum Date: Fri, 2 Aug 2024 16:40:30 -0700 Subject: Add second clearcoat mask, and add invert ability Also optimize by locking each behind a keyword. --- Editor/tooner.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'Editor') diff --git a/Editor/tooner.cs b/Editor/tooner.cs index f7bdc50..9efdd21 100644 --- a/Editor/tooner.cs +++ b/Editor/tooner.cs @@ -115,6 +115,33 @@ public class ToonerGUI : ShaderGUI { editor.RangeProperty(bc, "Roughness"); bc = FindProperty("_Clearcoat_Mask"); editor.TexturePropertySingleLine(MakeLabel(bc, "Mask"), bc); + SetKeyword($"_CLEARCOAT_MASK", bc.textureValue); + + if (bc.textureValue) { + EditorGUI.indentLevel += 1; + bc = FindProperty("_Clearcoat_Mask_Invert"); + enabled = bc.floatValue > 1E-6; + EditorGUI.BeginChangeCheck(); + enabled = EditorGUILayout.Toggle("Invert mask", enabled); + EditorGUI.EndChangeCheck(); + bc.floatValue = enabled ? 1.0f : 0.0f; + EditorGUI.indentLevel -= 1; + } + + bc = FindProperty("_Clearcoat_Mask2"); + editor.TexturePropertySingleLine(MakeLabel(bc, "Mask 2"), bc); + SetKeyword($"_CLEARCOAT_MASK2", bc.textureValue); + + if (bc.textureValue) { + EditorGUI.indentLevel += 1; + bc = FindProperty("_Clearcoat_Mask2_Invert"); + enabled = bc.floatValue > 1E-6; + EditorGUI.BeginChangeCheck(); + enabled = EditorGUILayout.Toggle("Invert mask", enabled); + EditorGUI.EndChangeCheck(); + bc.floatValue = enabled ? 1.0f : 0.0f; + EditorGUI.indentLevel -= 1; + } } } -- cgit v1.2.3