diff options
| author | yum <yum.food.vr@gmail.com> | 2024-06-29 03:17:55 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2024-06-29 03:17:55 -0700 |
| commit | a57eca5f6f8756209018d034a12e0d75f9ee1ef5 (patch) | |
| tree | 8f98a715c902a6251e79740a49cc4668f18f46fc /Editor | |
| parent | 24d1a84d2b18ee771585e22ec00fa190afde3df5 (diff) | |
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.
Diffstat (limited to 'Editor')
| -rw-r--r-- | Editor/tooner.cs | 53 |
1 files changed, 52 insertions, 1 deletions
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(); |
