summaryrefslogtreecommitdiffstats
path: root/Editor
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2024-05-22 15:51:37 -0700
committeryum <yum.food.vr@gmail.com>2024-05-22 15:51:37 -0700
commit72a4f411ff04375caffebc557592b98bcf700ae1 (patch)
tree9fee16abe57a0722cdeaae810fa6d27bd1020331 /Editor
parente8fd83bb9d9fb42d122229a9fd1a04514908e146 (diff)
Add stochastic cutout rendering mode
Use a randomized threshold instead of a static one when rendering transparency in cutout mode. This lets us render things like fabrics. Requires UVs to work properly.
Diffstat (limited to 'Editor')
-rw-r--r--Editor/tooner.cs26
1 files changed, 21 insertions, 5 deletions
diff --git a/Editor/tooner.cs b/Editor/tooner.cs
index 9409dbc..ca2d1c8 100644
--- a/Editor/tooner.cs
+++ b/Editor/tooner.cs
@@ -324,7 +324,7 @@ public class ToonerGUI : ShaderGUI {
mode = (NormalsMode) EditorGUILayout.EnumPopup(
MakeLabel("Normals mode"), mode);
if (EditorGUI.EndChangeCheck()) {
- RecordAction("Rendering Mode");
+ RecordAction("Rendering mode");
}
bc.floatValue = (float) mode;
@@ -620,6 +620,11 @@ public class ToonerGUI : ShaderGUI {
Fade
}
+ enum CutoutMode {
+ Cutoff,
+ Stochastic
+ }
+
void DoRendering() {
RenderingMode mode = RenderingMode.Opaque;
if (target.IsKeywordEnabled("_RENDERING_CUTOUT")) {
@@ -630,13 +635,13 @@ public class ToonerGUI : ShaderGUI {
EditorGUI.BeginChangeCheck();
mode = (RenderingMode) EditorGUILayout.EnumPopup(
- MakeLabel("Rendering Mode"), mode);
+ MakeLabel("Rendering mode"), mode);
BlendMode src_blend = BlendMode.One;
BlendMode dst_blend = BlendMode.Zero;
bool zwrite = false;
if (EditorGUI.EndChangeCheck()) {
- RecordAction("Rendering Mode");
+ RecordAction("Rendering mode");
SetKeyword("_RENDERING_CUTOUT", mode == RenderingMode.Cutout);
SetKeyword("_RENDERING_FADE", mode == RenderingMode.Fade);
@@ -676,8 +681,19 @@ public class ToonerGUI : ShaderGUI {
MaterialProperty bc;
if (mode == RenderingMode.Cutout) {
- bc = FindProperty("_Alpha_Cutoff");
- editor.ShaderProperty(bc, MakeLabel(bc));
+ EditorGUI.BeginChangeCheck();
+ bc = FindProperty("_Cutout_Mode");
+ CutoutMode cmode = (CutoutMode) Math.Round(bc.floatValue);
+ cmode = (CutoutMode) EditorGUILayout.EnumPopup(
+ MakeLabel("Cutout mode"), cmode);
+ EditorGUI.EndChangeCheck();
+ bc.floatValue = (float) cmode;
+ SetKeyword("_RENDERING_CUTOUT_STOCHASTIC", cmode == CutoutMode.Stochastic);
+
+ if (cmode == CutoutMode.Cutoff) {
+ bc = FindProperty("_Alpha_Cutoff");
+ editor.ShaderProperty(bc, MakeLabel(bc));
+ }
}
bc = FindProperty("_Cull");