From b7407fa9d7a917f7d62a7a2e12f96e90af11215c Mon Sep 17 00:00:00 2001 From: yum Date: Tue, 20 Aug 2024 13:45:54 -0700 Subject: Add normals replace option to matcap Also add mix factor slider so you can animate matcap opacity. This is useful for adding things like bodysuits. --- Editor/tooner.cs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'Editor') diff --git a/Editor/tooner.cs b/Editor/tooner.cs index 4e96e61..4d96d76 100644 --- a/Editor/tooner.cs +++ b/Editor/tooner.cs @@ -480,6 +480,11 @@ public class ToonerGUI : ShaderGUI { bc, "Matcap strength"); + bc = FindProperty($"_Matcap{i}MixFactor"); + editor.RangeProperty( + bc, + "Mix factor"); + bc = FindProperty($"_Matcap{i}Emission"); editor.FloatProperty( bc, @@ -490,6 +495,29 @@ public class ToonerGUI : ShaderGUI { bc, "Quantization"); + bc = FindProperty($"_Matcap{i}Normal_Enabled"); + enabled = bc.floatValue > 1E-6; + EditorGUI.BeginChangeCheck(); + enabled = EditorGUILayout.Toggle("Replace normals", enabled); + EditorGUI.EndChangeCheck(); + bc.floatValue = enabled ? 1.0f : 0.0f; + SetKeyword($"_MATCAP{i}_NORMAL", enabled); + + if (enabled) { + EditorGUI.indentLevel += 1; + bc = FindProperty($"_Matcap{i}Normal"); + editor.TexturePropertySingleLine( + MakeLabel(bc, "Normal map"), + bc); + if (bc.textureValue) { + editor.TextureScaleOffsetProperty(bc); + + bc = FindProperty($"_Matcap{i}Normal_Str"); + editor.RangeProperty(bc, "Strength"); + } + EditorGUI.indentLevel -= 1; + } + bc = FindProperty($"_Matcap{i}Distortion0"); enabled = bc.floatValue > 1E-6; EditorGUI.BeginChangeCheck(); -- cgit v1.2.3