summaryrefslogtreecommitdiffstats
path: root/Editor
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2024-08-02 16:28:13 -0700
committeryum <yum.food.vr@gmail.com>2024-08-02 16:28:13 -0700
commita627c1f915b86956b528af304fa85fee42dc11a0 (patch)
tree47121889429eed9b17d50e24baf00c58ecb1caff /Editor
parent22d3a28ef6ac9f4fc9204ae3bc0c67d82feac46e (diff)
Add controls for overlays on transparent materials
Add ability to constrain overlay to parts of the texture based on opacity. Min/max opacity are configurable. Add slider to multiply the overlay's alpha channel. This helps prevent transparent overlays from disappearing in less detailed mip maps.
Diffstat (limited to 'Editor')
-rw-r--r--Editor/tooner.cs30
1 files changed, 29 insertions, 1 deletions
diff --git a/Editor/tooner.cs b/Editor/tooner.cs
index 4ad7fa7..f7bdc50 100644
--- a/Editor/tooner.cs
+++ b/Editor/tooner.cs
@@ -166,6 +166,23 @@ public class ToonerGUI : ShaderGUI {
SetKeyword($"_PBR_OVERLAY{i}_MIX_MIN", mode == PbrAlbedoMixMode.Min);
SetKeyword($"_PBR_OVERLAY{i}_MIX_MAX", mode == PbrAlbedoMixMode.Max);
+ bc = FindProperty($"_PBR_Overlay{i}_Constrain_By_Alpha");
+ enabled = bc.floatValue > 1E-6;
+ EditorGUI.BeginChangeCheck();
+ enabled = EditorGUILayout.Toggle("Constrain to transparent sections", enabled);
+ EditorGUI.EndChangeCheck();
+ bc.floatValue = enabled ? 1.0f : 0.0f;
+ if (enabled) {
+ EditorGUI.indentLevel += 1;
+ bc = FindProperty($"_PBR_Overlay{i}_Constrain_By_Alpha_Min");
+ editor.RangeProperty(bc, "Min");
+ bc = FindProperty($"_PBR_Overlay{i}_Constrain_By_Alpha_Max");
+ editor.RangeProperty(bc, "Max");
+ EditorGUI.indentLevel -= 1;
+ }
+ bc = FindProperty($"_PBR_Overlay{i}_Alpha_Multiplier");
+ editor.RangeProperty(bc, "Alpha multiplier");
+
bc = FindProperty($"_PBR_Overlay{i}_Emission");
bct = FindProperty($"_PBR_Overlay{i}_EmissionTex");
editor.TexturePropertySingleLine(
@@ -223,6 +240,17 @@ public class ToonerGUI : ShaderGUI {
EditorGUI.EndChangeCheck();
bc.floatValue = enabled ? 1.0f : 0.0f;
}
+ } else {
+ SetKeyword($"_PBR_OVERLAY{i}_BASECOLOR_MAP", false);
+ SetKeyword($"_PBR_OVERLAY{i}_MIX_ALPHA_BLEND", false);
+ SetKeyword($"_PBR_OVERLAY{i}_MIX_ADD", false);
+ SetKeyword($"_PBR_OVERLAY{i}_MIX_MIN", false);
+ SetKeyword($"_PBR_OVERLAY{i}_MIX_MAX", false);
+ SetKeyword($"_PBR_OVERLAY{i}_EMISSION_MAP", false);
+ SetKeyword($"_PBR_OVERLAY{i}_NORMAL_MAP", false);
+ SetKeyword($"_PBR_OVERLAY{i}_METALLIC_MAP", false);
+ SetKeyword($"_PBR_OVERLAY{i}_ROUGHNESS_MAP", false);
+ SetKeyword($"_PBR_OVERLAY{i}_MASK", false);
}
EditorGUI.indentLevel -= 1;
}
@@ -1217,7 +1245,7 @@ public class ToonerGUI : ShaderGUI {
case RenderingMode.TransClipping:
queue = RenderQueue.AlphaTest;
render_type = "Transparent";
- src_blend = BlendMode.One;
+ src_blend = BlendMode.SrcAlpha;
dst_blend = BlendMode.OneMinusSrcAlpha;
zwrite = true;
break;