From 8948b000fb82cea4ce1d966a669daf68bfeb3166 Mon Sep 17 00:00:00 2001 From: yum Date: Sat, 10 Aug 2024 13:41:58 -0700 Subject: Implement metallics in PBR overlay --- Editor/tooner.cs | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'Editor/tooner.cs') diff --git a/Editor/tooner.cs b/Editor/tooner.cs index 252dce9..01ab5a2 100644 --- a/Editor/tooner.cs +++ b/Editor/tooner.cs @@ -235,16 +235,26 @@ public class ToonerGUI : ShaderGUI { } SetKeyword($"_PBR_OVERLAY{i}_NORMAL_MAP", bct.textureValue); - bc = FindProperty($"_PBR_Overlay{i}_Metallic"); - bct = FindProperty($"_PBR_Overlay{i}_MetallicTex"); - editor.TexturePropertySingleLine( - MakeLabel(bct, "Metallic (RGBA)"), - bct, - bc); - if (bct.textureValue) { - editor.TextureScaleOffsetProperty(bct); + bc = FindProperty($"_PBR_Overlay{i}_Metallic_Enable"); + enabled = bc.floatValue > 1E-6; + EditorGUI.BeginChangeCheck(); + enabled = EditorGUILayout.Toggle("Enable metallic", enabled); + EditorGUI.EndChangeCheck(); + bc.floatValue = enabled ? 1.0f : 0.0f; + SetKeyword($"_PBR_OVERLAY{i}_METALLIC", enabled); + + if (enabled) { + bc = FindProperty($"_PBR_Overlay{i}_Metallic"); + bct = FindProperty($"_PBR_Overlay{i}_MetallicTex"); + editor.TexturePropertySingleLine( + MakeLabel(bct, "Metallic (RGBA)"), + bct, + bc); + if (bct.textureValue) { + editor.TextureScaleOffsetProperty(bct); + } + SetKeyword($"_PBR_OVERLAY{i}_METALLIC_MAP", bct.textureValue); } - SetKeyword($"_PBR_OVERLAY{i}_METALLIC_MAP", bct.textureValue); bc = FindProperty($"_PBR_Overlay{i}_Roughness_Enable"); enabled = bc.floatValue > 1E-6; -- cgit v1.2.3