From a57eca5f6f8756209018d034a12e0d75f9ee1ef5 Mon Sep 17 00:00:00 2001 From: yum Date: Sat, 29 Jun 2024 03:17:55 -0700 Subject: Add basic decals Also add polar masking rim lighting. Polar masking calculates the angle of the matcap UV (theta) and evalutes this function: m_{polar} = 1 / (1 + length(theta - theta_{configured}) It then masks the rim lighting effect using m_{polar}. Quantization applies to this effect. --- Editor/tooner.cs | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) (limited to 'Editor') diff --git a/Editor/tooner.cs b/Editor/tooner.cs index 7063972..a484bc8 100644 --- a/Editor/tooner.cs +++ b/Editor/tooner.cs @@ -208,7 +208,35 @@ public class ToonerGUI : ShaderGUI { } } - void DoCubemap() { + void DoDecal() { + for (int i = 0; i < 4; i++) { + GUILayout.Label($"Decal {i}", EditorStyles.boldLabel); + EditorGUI.indentLevel += 1; + + MaterialProperty bc = FindProperty($"_Decal{i}_Enable"); + bool enabled = bc.floatValue > 1E-6; + EditorGUI.BeginChangeCheck(); + enabled = EditorGUILayout.Toggle("Enable", enabled); + EditorGUI.EndChangeCheck(); + bc.floatValue = enabled ? 1.0f : 0.0f; + SetKeyword($"_DECAL{i}", enabled); + + if (enabled) { + bc = FindProperty($"_Decal{i}_BaseColor"); + editor.TexturePropertySingleLine( + MakeLabel(bc, "Base color (RGBA)"), + bc); + if (bc.textureValue) { + editor.TextureScaleOffsetProperty(bc); + } + bc = FindProperty($"_Decal{i}_Emission_Strength"); + editor.FloatProperty( + bc, + "Emission strength"); + } + + EditorGUI.indentLevel -= 1; + } } void DoBrightness() { @@ -410,6 +438,27 @@ public class ToonerGUI : ShaderGUI { EditorGUI.indentLevel -= 1; } + bc = FindProperty($"_Rim_Lighting{i}_PolarMask_Enabled"); + enabled = bc.floatValue > 1E-6; + EditorGUI.BeginChangeCheck(); + enabled = EditorGUILayout.Toggle("Polar mask", enabled); + EditorGUI.EndChangeCheck(); + bc.floatValue = enabled ? 1.0f : 0.0f; + SetKeyword($"_RIM_LIGHTING{i}_POLAR_MASK", enabled); + + if (enabled) { + EditorGUI.indentLevel += 1; + bc = FindProperty($"_Rim_Lighting{i}_PolarMask_Theta"); + editor.FloatProperty( + bc, + "Theta"); + bc = FindProperty($"_Rim_Lighting{i}_PolarMask_Power"); + editor.FloatProperty( + bc, + "Power"); + EditorGUI.indentLevel -= 1; + } + EditorGUI.indentLevel -= 1; } } @@ -961,6 +1010,8 @@ public class ToonerGUI : ShaderGUI { DoPBROverlay(); + DoDecal(); + GUILayout.Label("Lighting", EditorStyles.boldLabel); EditorGUI.indentLevel += 1; DoLighting(); -- cgit v1.2.3