summaryrefslogtreecommitdiffstats
path: root/Editor
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2024-12-09 01:16:52 -0800
committeryum <yum.food.vr@gmail.com>2024-12-09 01:16:52 -0800
commit81537629668cdda03f83b0b63870d53963ba5229 (patch)
tree6a648845e75d4278dfb7de7491f1becf6f883815 /Editor
parent2356cdf85d2c52f70052828bb5a18419a30d4de9 (diff)
Add SDF mode to decals
Also: * add gen_sdf script, which converts solid color (ideally b&w) decals into sdf textures * add 6 more decal slots * add color, sdf options, alpha multiplier, tiling mode, and mask to decals * add token pasting macros (MERGE) to minimize code size of new decal slots
Diffstat (limited to 'Editor')
-rw-r--r--Editor/tooner.cs63
1 files changed, 55 insertions, 8 deletions
diff --git a/Editor/tooner.cs b/Editor/tooner.cs
index c92f35d..865934d 100644
--- a/Editor/tooner.cs
+++ b/Editor/tooner.cs
@@ -519,10 +519,18 @@ public class ToonerGUI : ShaderGUI {
show_ui.RemoveAt(show_ui.Count - 1);
}
+ enum TilingMode {
+ Clamp,
+ Repeat,
+ }
+ enum BaseColorMode {
+ Color,
+ SDF,
+ }
void DoDecal() {
show_ui.Add(AddCollapsibleMenu("Decals", "_Decal"));
EditorGUI.indentLevel += 1;
- for (int i = 0; i < 4; i++) {
+ for (int i = 0; i < 10; i++) {
show_ui.Add(AddCollapsibleMenu($"Decal {i}", $"_Decal{i}"));
EditorGUI.indentLevel += 1;
@@ -535,12 +543,27 @@ public class ToonerGUI : ShaderGUI {
SetKeyword($"_DECAL{i}", enabled);
if (enabled) {
- bc = FindProperty($"_Decal{i}_BaseColor");
- TexturePropertySingleLine(
- MakeLabel(bc, "Base color (RGBA)"),
- bc);
- if (bc.textureValue) {
- TextureScaleOffsetProperty(bc);
+ MaterialProperty bct;
+ bc = FindProperty($"_Decal{i}_Color");
+ bct = FindProperty($"_Decal{i}_BaseColor");
+ TexturePropertySingleLine(MakeLabel(bct, "Base color (RGBA)"), bct, bc);
+ // Unconditionally drive scale + offset because it affects all textures.
+ TextureScaleOffsetProperty(bct);
+
+ bc = FindProperty($"_Decal{i}_BaseColor_Mode");
+ BaseColorMode base_color_mode = (BaseColorMode) Math.Round(bc.floatValue);
+ base_color_mode = (BaseColorMode) EnumPopup(MakeLabel("Base color mode"), base_color_mode);
+ bc.floatValue = (int) base_color_mode;
+
+ if (base_color_mode == BaseColorMode.SDF) {
+ bc = FindProperty($"_Decal{i}_SDF_Threshold");
+ RangeProperty(bc, "SDF threshold");
+
+ bc = FindProperty($"_Decal{i}_SDF_Softness");
+ RangeProperty(bc, "SDF softness");
+
+ bc = FindProperty($"_Decal{i}_SDF_Px_Range");
+ FloatProperty(bc, "SDF px range");
}
bc = FindProperty($"_Decal{i}_Roughness");
@@ -564,6 +587,30 @@ public class ToonerGUI : ShaderGUI {
bc,
"Angle");
+ bc = FindProperty($"_Decal{i}_Alpha_Multiplier");
+ RangeProperty(bc, "Alpha multiplier");
+
+ bc = FindProperty($"_Decal{i}_Round_Alpha_Multiplier");
+
+ bct = FindProperty($"_Decal{i}_Mask");
+ TexturePropertySingleLine(MakeLabel(bct, "Mask"), bct);
+ SetKeyword($"_DECAL{i}_MASK", bct.textureValue);
+
+ if (bct.textureValue) {
+ bc = FindProperty($"_Decal{i}_Mask_Invert");
+ enabled = bc.floatValue > 1E-6;
+ EditorGUI.BeginChangeCheck();
+ enabled = Toggle("Invert mask", enabled);
+ EditorGUI.EndChangeCheck();
+ bc.floatValue = enabled ? 1.0f : 0.0f;
+ }
+
+ bc = FindProperty($"_Decal{i}_Tiling_Mode");
+ TilingMode tiling_mode = (TilingMode) Math.Round(bc.floatValue);
+ tiling_mode = (TilingMode) EnumPopup(
+ MakeLabel("Tiling mode"), tiling_mode);
+ bc.floatValue = (int) tiling_mode;
+
bc = FindProperty($"_Decal{i}_UV_Select");
RangeProperty(
bc,
@@ -688,7 +735,7 @@ public class ToonerGUI : ShaderGUI {
if (bc.textureValue) {
EditorGUI.indentLevel += 1;
- bc = FindProperty($"_Matcap{i}_Mask2_Invert");
+ bc = FindProperty($"_Matcap{i}_Mask2_Invert_Colors");
enabled = bc.floatValue > 1E-6;
EditorGUI.BeginChangeCheck();
enabled = Toggle("Invert mask colors", enabled);