yum-archive/Tooner

A toon shader for Unity's BIRP.

git clone https://git.yummers.dev/yum-archive/Tooner

yumAdd 4x4 textures to ssfd9b52e08

master
123.9 KiB3880 linesraw
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4using UnityEngine.Rendering;
5using UnityEditor;
6
7public class ToonerGUI : ShaderGUI {
8  Material target;
9  MaterialEditor editor;
10  MaterialProperty[] properties;
11  List<bool> show_ui;
12
13  public override void OnGUI(
14      MaterialEditor editor,
15      MaterialProperty[] properties) {
16    this.target = editor.target as Material;
17    this.editor = editor;
18    this.properties = properties;
19    this.show_ui = new List<bool>();
20    DoMain();
21  }
22
23  void TexturePropertySingleLine(GUIContent label, MaterialProperty bct)
24  {
25    if (show_ui.Contains(false)) {
26      return;
27    }
28    editor.TexturePropertySingleLine(label, bct);
29  }
30  void TexturePropertySingleLine(GUIContent label, MaterialProperty bct, MaterialProperty bc)
31  {
32    if (show_ui.Contains(false)) {
33      return;
34    }
35    editor.TexturePropertySingleLine(label, bct, bc);
36  }
37  void TexturePropertyWithHDRColor(GUIContent label, MaterialProperty bct, MaterialProperty bc, bool opt)
38  {
39    if (show_ui.Contains(false)) {
40      return;
41    }
42    editor.TexturePropertyWithHDRColor(label, bct, bc, opt);
43  }
44  void TextureScaleOffsetProperty(MaterialProperty bc)
45  {
46    if (show_ui.Contains(false)) {
47      return;
48    }
49    editor.TextureScaleOffsetProperty(bc);
50  }
51  void RangeProperty(MaterialProperty bc, string label)
52  {
53    if (show_ui.Contains(false)) {
54      return;
55    }
56    editor.RangeProperty(bc, label);
57  }
58  void ShaderProperty(MaterialProperty bc, GUIContent label)
59  {
60    if (show_ui.Contains(false)) {
61      return;
62    }
63    editor.ShaderProperty(bc, label);
64  }
65  void FloatProperty(MaterialProperty bc, string label)
66  {
67    if (show_ui.Contains(false)) {
68      return;
69    }
70    editor.FloatProperty(bc, label);
71  }
72  void IntegerProperty(MaterialProperty bc, string label)
73  {
74    if (show_ui.Contains(false)) {
75      return;
76    }
77    editor.IntegerProperty(bc, label);
78  }
79  void VectorProperty(MaterialProperty bc, string label)
80  {
81    if (show_ui.Contains(false)) {
82      return;
83    }
84    editor.VectorProperty(bc, label);
85  }
86  void ColorProperty(MaterialProperty bc, string label)
87  {
88    if (show_ui.Contains(false)) {
89      return;
90    }
91    editor.ColorProperty(bc, label);
92  }
93  Enum EnumPopup(GUIContent label, Enum selected)
94  {
95    if (show_ui.Contains(false)) {
96      return selected;
97    }
98    return EditorGUILayout.EnumPopup(label, selected);
99  }
100  bool Toggle(string label, bool v)
101  {
102    if (show_ui.Contains(false)) {
103      return v;
104    }
105    return EditorGUILayout.Toggle(label, v);
106  }
107  void LabelField(string label)
108  {
109    if (show_ui.Contains(false)) {
110      return;
111    }
112    EditorGUILayout.LabelField(label);
113  }
114  void LabelField(string label, UnityEngine.GUIStyle style)
115  {
116    if (show_ui.Contains(false)) {
117      return;
118    }
119    EditorGUILayout.LabelField(label, style);
120  }
121
122  static GUIContent staticLabel = new GUIContent();
123
124  static GUIContent MakeLabel(string prop, string tooltip = null) {
125    staticLabel.text = prop;
126    staticLabel.tooltip = tooltip;
127    return staticLabel;
128  }
129
130  static GUIContent MakeLabel(MaterialProperty prop, string tooltip = null) {
131    staticLabel.text = prop.displayName;
132    staticLabel.tooltip = tooltip;
133    return staticLabel;
134  }
135
136  void RecordAction (string label) {
137    editor.RegisterPropertyChangeUndo(label);
138  }
139
140  MaterialProperty FindProperty(string label) {
141    return FindProperty(label, properties);
142  }
143
144  void SetKeyword(string keyword, bool state) {
145    if (state) {
146      target.EnableKeyword(keyword);
147    } else {
148      target.DisableKeyword(keyword);
149    }
150  }
151
152  void DoBaseColor() {
153    MaterialProperty bc = FindProperty("_Color");
154    MaterialProperty bct = FindProperty("_MainTex");
155    TexturePropertySingleLine(
156        MakeLabel(bct, "Base color (RGBA)"),
157        bct,
158        bc);
159    SetKeyword("_BASECOLOR_MAP", bct.textureValue);
160    if (bct.textureValue) {
161      TextureScaleOffsetProperty(bct);
162    }
163  }
164
165  void DoNormal() {
166    MaterialProperty bct = FindProperty("_BumpMap");
167    TexturePropertySingleLine(
168        MakeLabel(bct, "Normal"),
169        bct,
170        FindProperty("_Tex_NormalStr"));
171    if (bct.textureValue) {
172      TextureScaleOffsetProperty(bct);
173    }
174    SetKeyword("_NORMAL_MAP", bct.textureValue);
175  }
176
177  void DoMetallic() {
178    MaterialProperty bc = FindProperty("_Metallic");
179    MaterialProperty bct = FindProperty("_MetallicTex");
180    TexturePropertySingleLine(
181        MakeLabel(bct, "Metallic (RGBA)"),
182        bct,
183        bc);
184    SetKeyword("_METALLIC_MAP", bct.textureValue);
185    if (bct.textureValue) {
186      TextureScaleOffsetProperty(bct);
187
188      bc = FindProperty("_MetallicTexChannel");
189      RangeProperty(bc, "Channel");
190    }
191  }
192
193  void DoRoughness() {
194      MaterialProperty bc = FindProperty("_Roughness");
195      MaterialProperty bct = FindProperty("_RoughnessTex");
196      TexturePropertySingleLine(
197          MakeLabel(bct, "Roughness (RGBA)"),
198          bct,
199          bc);
200      SetKeyword("_ROUGHNESS_MAP", bct.textureValue);
201      if (bct.textureValue) {
202        TextureScaleOffsetProperty(bct);
203
204        bc = FindProperty("_RoughnessTexChannel");
205        RangeProperty(bc, "Channel");
206
207        bc = FindProperty("_Roughness_Invert");
208        bool enabled = bc.floatValue > 1E-6;
209        EditorGUI.BeginChangeCheck();
210        enabled = Toggle("Invert", enabled);
211        EditorGUI.EndChangeCheck();
212        bc.floatValue = enabled ? 1.0f : 0.0f;
213      }
214  }
215
216  bool AddCollapsibleMenu(string name, string matprop) {
217    MaterialProperty bc = FindProperty(matprop + "_UI_Show");
218    bool enabled = bc.floatValue > 1E-6;
219    EditorGUI.BeginChangeCheck();
220    var fs_orig = EditorStyles.label.fontStyle;
221    EditorStyles.label.fontStyle = FontStyle.Bold;
222    enabled = Toggle(name, enabled);
223    EditorStyles.label.fontStyle = fs_orig;
224    EditorGUI.EndChangeCheck();
225    bc.floatValue = enabled ? 1.0f : 0.0f;
226
227    return enabled;
228  }
229
230  // Why do the cartesian product here rather than in C? Easier to do it here
231  // than with C macros!
232  enum SamplerMode {
233    // Why this order? Backwards compatibility when interpolation selection was introduced
234    LinearRepeat,
235    LinearClamp,
236    PointRepeat,
237    PointClamp,
238    BilinearRepeat,
239    BilinearClamp,
240  };
241  void DoPBR() {
242    show_ui.Add(AddCollapsibleMenu("PBR", "_PBR"));
243    EditorGUI.indentLevel += 1;
244    {
245      DoBaseColor();
246      DoNormal();
247      DoMetallic();
248      DoRoughness();
249
250      EditorGUI.BeginChangeCheck();
251      MaterialProperty bc = FindProperty($"_PBR_Sampler_Mode");
252      SamplerMode sampler_mode = (SamplerMode) Math.Round(bc.floatValue);
253      sampler_mode = (SamplerMode) EnumPopup(
254          MakeLabel("Sampler mode"), sampler_mode);
255      EditorGUI.EndChangeCheck();
256      bc.floatValue = (int) sampler_mode;
257
258      SetKeyword($"_PBR_SAMPLER_LINEAR_REPEAT", sampler_mode == SamplerMode.LinearRepeat);
259      SetKeyword($"_PBR_SAMPLER_LINEAR_CLAMP", sampler_mode == SamplerMode.LinearClamp);
260      SetKeyword($"_PBR_SAMPLER_BILINEAR_REPEAT", sampler_mode == SamplerMode.BilinearRepeat);
261      SetKeyword($"_PBR_SAMPLER_BILINEAR_CLAMP", sampler_mode == SamplerMode.BilinearClamp);
262      SetKeyword($"_PBR_SAMPLER_POINT_REPEAT", sampler_mode == SamplerMode.PointRepeat);
263      SetKeyword($"_PBR_SAMPLER_POINT_CLAMP", sampler_mode == SamplerMode.PointClamp);
264    }
265    EditorGUI.indentLevel -= 1;
266    show_ui.RemoveAt(show_ui.Count - 1);
267  }
268
269  void DoClearcoat() {
270    show_ui.Add(AddCollapsibleMenu($"Clearcoat", $"_Clearcoat"));
271    EditorGUI.indentLevel += 1;
272
273    MaterialProperty bc;
274    bc = FindProperty("_Clearcoat_Enabled");
275    bool enabled = bc.floatValue > 1E-6;
276    EditorGUI.BeginChangeCheck();
277    enabled = Toggle("Enable clearcoat", enabled);
278    EditorGUI.EndChangeCheck();
279    bc.floatValue = enabled ? 1.0f : 0.0f;
280    SetKeyword("_CLEARCOAT", enabled);
281
282    if (enabled) {
283        bc = FindProperty("_Clearcoat_Strength");
284        RangeProperty(bc, "Strength");
285        bc = FindProperty("_Clearcoat_Roughness");
286        RangeProperty(bc, "Roughness");
287        bc = FindProperty("_Clearcoat_Mask");
288        TexturePropertySingleLine(MakeLabel(bc, "Mask"), bc);
289        SetKeyword($"_CLEARCOAT_MASK", bc.textureValue);
290
291        if (bc.textureValue) {
292          EditorGUI.indentLevel += 1;
293          bc = FindProperty("_Clearcoat_Mask_Invert");
294          enabled = bc.floatValue > 1E-6;
295          EditorGUI.BeginChangeCheck();
296          enabled = Toggle("Invert mask", enabled);
297          EditorGUI.EndChangeCheck();
298          bc.floatValue = enabled ? 1.0f : 0.0f;
299          EditorGUI.indentLevel -= 1;
300        }
301
302        bc = FindProperty("_Clearcoat_Mask2");
303        TexturePropertySingleLine(MakeLabel(bc, "Mask 2"), bc);
304        SetKeyword($"_CLEARCOAT_MASK2", bc.textureValue);
305
306        if (bc.textureValue) {
307          EditorGUI.indentLevel += 1;
308          bc = FindProperty("_Clearcoat_Mask2_Invert");
309          enabled = bc.floatValue > 1E-6;
310          EditorGUI.BeginChangeCheck();
311          enabled = Toggle("Invert mask", enabled);
312          EditorGUI.EndChangeCheck();
313          bc.floatValue = enabled ? 1.0f : 0.0f;
314          EditorGUI.indentLevel -= 1;
315        }
316
317        bc = FindProperty("_Clearcoat_Use_Texture_Normals");
318        enabled = bc.floatValue > 1E-6;
319        EditorGUI.BeginChangeCheck();
320        enabled = Toggle("Use texture normals", enabled);
321        EditorGUI.EndChangeCheck();
322        bc.floatValue = enabled ? 1.0f : 0.0f;
323    }
324    EditorGUI.indentLevel -= 1;
325    show_ui.RemoveAt(show_ui.Count - 1);
326  }
327
328  enum PbrAlbedoMixMode {
329    AlphaBlend,
330    Add,
331    Min,
332    Max,
333    Multiply
334  };
335
336  void DoPBROverlay() {
337    show_ui.Add(AddCollapsibleMenu($"PBR overlays", $"_PBR_Overlay"));
338    EditorGUI.indentLevel += 1;
339    for (int i = 0; i < 4; i++) {
340      show_ui.Add(AddCollapsibleMenu($"PBR overlay {i}", $"_PBR_Overlay{i}"));
341      EditorGUI.indentLevel += 1;
342
343      MaterialProperty bc = FindProperty($"_PBR_Overlay{i}_Enable");
344      bool enabled = bc.floatValue > 1E-6;
345      EditorGUI.BeginChangeCheck();
346      enabled = Toggle("Enable", enabled);
347      EditorGUI.EndChangeCheck();
348      bc.floatValue = enabled ? 1.0f : 0.0f;
349      SetKeyword($"_PBR_OVERLAY{i}", enabled);
350
351      if (enabled) {
352        bc = FindProperty($"_PBR_Overlay{i}_BaseColor");
353        MaterialProperty bct = FindProperty($"_PBR_Overlay{i}_BaseColorTex");
354        TexturePropertySingleLine(
355            MakeLabel(bct, "Base color (RGBA)"),
356            bct,
357            bc);
358        if (bct.textureValue) {
359          TextureScaleOffsetProperty(bct);
360        }
361        SetKeyword($"_PBR_OVERLAY{i}_BASECOLOR_MAP", bct.textureValue);
362
363        EditorGUI.BeginChangeCheck();
364        bc = FindProperty($"_PBR_Overlay{i}_Mix");
365        PbrAlbedoMixMode mode = (PbrAlbedoMixMode) Math.Round(bc.floatValue);
366        mode = (PbrAlbedoMixMode) EnumPopup(
367            MakeLabel("Mix mode"), mode);
368        if (EditorGUI.EndChangeCheck()) {
369          RecordAction($"PBR overlay mix mode {i}");
370          foreach (Material m in editor.targets) {
371            m.SetFloat($"_PBR_Overlay{i}_Mix", (int) mode);
372          }
373        }
374        SetKeyword($"_PBR_OVERLAY{i}_MIX_ALPHA_BLEND", mode == PbrAlbedoMixMode.AlphaBlend);
375        SetKeyword($"_PBR_OVERLAY{i}_MIX_ADD", mode == PbrAlbedoMixMode.Add);
376        SetKeyword($"_PBR_OVERLAY{i}_MIX_MIN", mode == PbrAlbedoMixMode.Min);
377        SetKeyword($"_PBR_OVERLAY{i}_MIX_MAX", mode == PbrAlbedoMixMode.Max);
378        SetKeyword($"_PBR_OVERLAY{i}_MIX_MULTIPLY", mode == PbrAlbedoMixMode.Multiply);
379
380        bc = FindProperty($"_PBR_Overlay{i}_Constrain_By_Alpha");
381        enabled = bc.floatValue > 1E-6;
382        EditorGUI.BeginChangeCheck();
383        enabled = Toggle("Constrain to transparent sections", enabled);
384        EditorGUI.EndChangeCheck();
385        bc.floatValue = enabled ? 1.0f : 0.0f;
386        if (enabled) {
387          EditorGUI.indentLevel += 1;
388          bc = FindProperty($"_PBR_Overlay{i}_Constrain_By_Alpha_Min");
389          RangeProperty(bc, "Min");
390          bc = FindProperty($"_PBR_Overlay{i}_Constrain_By_Alpha_Max");
391          RangeProperty(bc, "Max");
392          EditorGUI.indentLevel -= 1;
393        }
394        bc = FindProperty($"_PBR_Overlay{i}_Alpha_Multiplier");
395        RangeProperty(bc, "Alpha multiplier");
396
397        bc = FindProperty($"_PBR_Overlay{i}_Emission");
398        bct = FindProperty($"_PBR_Overlay{i}_EmissionTex");
399        TexturePropertySingleLine(
400            MakeLabel(bct, "Emission (RGB)"),
401            bct,
402            bc);
403        if (bct.textureValue) {
404          TextureScaleOffsetProperty(bct);
405        }
406        SetKeyword($"_PBR_OVERLAY{i}_EMISSION_MAP", bct.textureValue);
407
408        bct = FindProperty($"_PBR_Overlay{i}_NormalTex");
409        TexturePropertySingleLine(
410            MakeLabel(bct, "Normal"),
411            bct,
412            FindProperty($"_PBR_Overlay{i}_Tex_NormalStr"));
413        if (bct.textureValue) {
414          TextureScaleOffsetProperty(bct);
415        }
416        SetKeyword($"_PBR_OVERLAY{i}_NORMAL_MAP", bct.textureValue);
417
418        bc = FindProperty($"_PBR_Overlay{i}_Metallic_Enable");
419        enabled = bc.floatValue > 1E-6;
420        EditorGUI.BeginChangeCheck();
421        enabled = Toggle("Enable metallic", enabled);
422        EditorGUI.EndChangeCheck();
423        bc.floatValue = enabled ? 1.0f : 0.0f;
424        SetKeyword($"_PBR_OVERLAY{i}_METALLIC", enabled);
425
426        if (enabled) {
427          bc = FindProperty($"_PBR_Overlay{i}_Metallic");
428          bct = FindProperty($"_PBR_Overlay{i}_MetallicTex");
429          TexturePropertySingleLine(
430              MakeLabel(bct, "Metallic (RGBA)"),
431              bct,
432              bc);
433          if (bct.textureValue) {
434            TextureScaleOffsetProperty(bct);
435          }
436          SetKeyword($"_PBR_OVERLAY{i}_METALLIC_MAP", bct.textureValue);
437        }
438
439        bc = FindProperty($"_PBR_Overlay{i}_Roughness_Enable");
440        enabled = bc.floatValue > 1E-6;
441        EditorGUI.BeginChangeCheck();
442        enabled = Toggle("Enable roughness", enabled);
443        EditorGUI.EndChangeCheck();
444        bc.floatValue = enabled ? 1.0f : 0.0f;
445        SetKeyword($"_PBR_OVERLAY{i}_ROUGHNESS", enabled);
446
447        if (enabled) {
448          EditorGUI.indentLevel += 1;
449          bc = FindProperty($"_PBR_Overlay{i}_Roughness");
450          bct = FindProperty($"_PBR_Overlay{i}_RoughnessTex");
451          TexturePropertySingleLine(
452              MakeLabel(bct, "Roughness (RGBA)"),
453              bct,
454              bc);
455          if (bct.textureValue) {
456            TextureScaleOffsetProperty(bct);
457          }
458          SetKeyword($"_PBR_OVERLAY{i}_ROUGHNESS_MAP", bct.textureValue);
459          EditorGUI.indentLevel -= 1;
460        }
461
462        bct = FindProperty($"_PBR_Overlay{i}_Mask");
463        TexturePropertySingleLine(
464            MakeLabel(bct, "Mask"),
465            bct);
466        SetKeyword($"_PBR_OVERLAY{i}_MASK", bct.textureValue);
467
468        if (bct.textureValue) {
469          TextureScaleOffsetProperty(bct);
470
471          bc = FindProperty($"_PBR_Overlay{i}_Mask_Invert");
472          enabled = bc.floatValue > 1E-6;
473          EditorGUI.BeginChangeCheck();
474          enabled = Toggle("Invert mask", enabled);
475          EditorGUI.EndChangeCheck();
476          bc.floatValue = enabled ? 1.0f : 0.0f;
477        }
478
479        bc = FindProperty($"_PBR_Overlay{i}_UV_Select");
480        RangeProperty(
481            bc,
482            "UV channel");
483
484        bc = FindProperty($"_PBR_Overlay{i}_Mask_Glitter");
485        enabled = bc.floatValue > 1E-6;
486        EditorGUI.BeginChangeCheck();
487        enabled = Toggle("Mask glitter", enabled);
488        EditorGUI.EndChangeCheck();
489        bc.floatValue = enabled ? 1.0f : 0.0f;
490
491        EditorGUI.BeginChangeCheck();
492        bc = FindProperty($"_PBR_Overlay{i}_Sampler_Mode");
493        SamplerMode sampler_mode = (SamplerMode) Math.Round(bc.floatValue);
494        sampler_mode = (SamplerMode) EnumPopup(
495            MakeLabel("Sampler wrapping mode"), sampler_mode);
496        EditorGUI.EndChangeCheck();
497        bc.floatValue = (int) sampler_mode;
498        SetKeyword($"_PBR_OVERLAY{i}_SAMPLER_LINEAR_REPEAT", sampler_mode == SamplerMode.LinearRepeat);
499        SetKeyword($"_PBR_OVERLAY{i}_SAMPLER_LINEAR_CLAMP", sampler_mode == SamplerMode.LinearClamp);
500        SetKeyword($"_PBR_OVERLAY{i}_SAMPLER_BILINEAR_REPEAT", sampler_mode == SamplerMode.BilinearRepeat);
501        SetKeyword($"_PBR_OVERLAY{i}_SAMPLER_BILINEAR_CLAMP", sampler_mode == SamplerMode.BilinearClamp);
502        SetKeyword($"_PBR_OVERLAY{i}_SAMPLER_POINT_REPEAT", sampler_mode == SamplerMode.PointRepeat);
503        SetKeyword($"_PBR_OVERLAY{i}_SAMPLER_POINT_CLAMP", sampler_mode == SamplerMode.PointClamp);
504
505        bc = FindProperty($"_PBR_Overlay{i}_Mip_Bias");
506        FloatProperty(bc, "Mip bias");
507      } else {
508        SetKeyword($"_PBR_OVERLAY{i}_BASECOLOR_MAP", false);
509        SetKeyword($"_PBR_OVERLAY{i}_MIX_ALPHA_BLEND", false);
510        SetKeyword($"_PBR_OVERLAY{i}_MIX_ADD", false);
511        SetKeyword($"_PBR_OVERLAY{i}_MIX_MIN", false);
512        SetKeyword($"_PBR_OVERLAY{i}_MIX_MAX", false);
513        SetKeyword($"_PBR_OVERLAY{i}_MIX_MULTIPLY", false);
514        SetKeyword($"_PBR_OVERLAY{i}_EMISSION_MAP", false);
515        SetKeyword($"_PBR_OVERLAY{i}_NORMAL_MAP", false);
516        SetKeyword($"_PBR_OVERLAY{i}_METALLIC_MAP", false);
517        SetKeyword($"_PBR_OVERLAY{i}_ROUGHNESS_MAP", false);
518        SetKeyword($"_PBR_OVERLAY{i}_MASK", false);
519        SetKeyword($"_PBR_OVERLAY{i}_SAMPLER_REPEAT", false);
520        SetKeyword($"_PBR_OVERLAY{i}_SAMPLER_CLAMP", false);
521      }
522      EditorGUI.indentLevel -= 1;
523      show_ui.RemoveAt(show_ui.Count - 1);
524    }
525    EditorGUI.indentLevel -= 1;
526    show_ui.RemoveAt(show_ui.Count - 1);
527  }
528
529  enum TilingMode {
530    Clamp,
531    Repeat,
532  };
533  enum BaseColorMode {
534    Color,
535    SDF,
536  };
537  void DoDecal() {
538    show_ui.Add(AddCollapsibleMenu("Decals", "_Decal"));
539    EditorGUI.indentLevel += 1;
540    for (int i = 0; i < 10; i++) {
541        show_ui.Add(AddCollapsibleMenu($"Decal {i}", $"_Decal{i}"));
542        EditorGUI.indentLevel += 1;
543
544        MaterialProperty bc = FindProperty($"_Decal{i}_Enable");
545        bool enabled = bc.floatValue > 1E-6;
546        EditorGUI.BeginChangeCheck();
547        enabled = Toggle("Enable", enabled);
548        EditorGUI.EndChangeCheck();
549        bc.floatValue = enabled ? 1.0f : 0.0f;
550        SetKeyword($"_DECAL{i}", enabled);
551
552        if (enabled) {
553          // Add up/down buttons in a horizontal layout
554          EditorGUILayout.BeginHorizontal();
555          if (i > 0 && GUILayout.Button("↑", GUILayout.Width(30))) {
556              SwapDecalSlots(i - 1, i);
557          }
558          if (i < 9 && GUILayout.Button("↓", GUILayout.Width(30))) {
559              SwapDecalSlots(i, i + 1);
560          }
561          EditorGUILayout.EndHorizontal();
562
563          MaterialProperty bct;
564          bc = FindProperty($"_Decal{i}_Color");
565          bct = FindProperty($"_Decal{i}_BaseColor");
566          TexturePropertySingleLine(MakeLabel(bct, "Base color (RGBA)"), bct, bc);
567          // Unconditionally drive scale + offset because it affects all textures.
568          TextureScaleOffsetProperty(bct);
569
570          bc = FindProperty($"_Decal{i}_BaseColor_Mode");
571          BaseColorMode base_color_mode = (BaseColorMode) Math.Round(bc.floatValue);
572          base_color_mode = (BaseColorMode) EnumPopup(MakeLabel("Base color mode"), base_color_mode);
573          bc.floatValue = (int) base_color_mode;
574
575          if (base_color_mode == BaseColorMode.SDF) {
576            bc = FindProperty($"_Decal{i}_SDF_Threshold");
577            RangeProperty(bc, "SDF threshold");
578
579            bc = FindProperty($"_Decal{i}_SDF_Softness");
580            RangeProperty(bc, "SDF softness");
581
582            bc = FindProperty($"_Decal{i}_SDF_Px_Range");
583            FloatProperty(bc, "SDF px range");
584
585            bc = FindProperty($"_Decal{i}_SDF_Invert");
586            enabled = bc.floatValue > 1E-6;
587            EditorGUI.BeginChangeCheck();
588            enabled = Toggle("Invert SDF", enabled);
589            EditorGUI.EndChangeCheck();
590            bc.floatValue = enabled ? 1.0f : 0.0f;
591          }
592
593          bc = FindProperty($"_Decal{i}_Roughness");
594          TexturePropertySingleLine(
595              MakeLabel(bc, "Roughness"),
596              bc);
597          SetKeyword($"_DECAL{i}_ROUGHNESS", bc.textureValue);
598
599          bc = FindProperty($"_Decal{i}_Metallic");
600          TexturePropertySingleLine(
601              MakeLabel(bc, "Metallic"),
602              bc);
603          SetKeyword($"_DECAL{i}_METALLIC", bc.textureValue);
604
605          bc = FindProperty($"_Decal{i}_Emission_Strength");
606          FloatProperty(
607              bc,
608              "Emission strength");
609          bc = FindProperty($"_Decal{i}_Angle");
610          RangeProperty(
611              bc,
612              "Angle");
613
614          bc = FindProperty($"_Decal{i}_Alpha_Multiplier");
615          RangeProperty(bc, "Alpha multiplier");
616
617          bc = FindProperty($"_Decal{i}_Round_Alpha_Multiplier");
618          enabled = bc.floatValue > 1E-6;
619          EditorGUI.BeginChangeCheck();
620          enabled = Toggle("Round alpha multiplier", enabled);
621          EditorGUI.EndChangeCheck();
622          bc.floatValue = enabled ? 1.0f : 0.0f;
623
624          bct = FindProperty($"_Decal{i}_Mask");
625          TexturePropertySingleLine(MakeLabel(bct, "Mask"), bct);
626          SetKeyword($"_DECAL{i}_MASK", bct.textureValue);
627
628          if (bct.textureValue) {
629            bc = FindProperty($"_Decal{i}_Mask_Invert");
630            enabled = bc.floatValue > 1E-6;
631            EditorGUI.BeginChangeCheck();
632            enabled = Toggle("Invert mask", enabled);
633            EditorGUI.EndChangeCheck();
634            bc.floatValue = enabled ? 1.0f : 0.0f;
635          }
636
637          bc = FindProperty($"_Decal{i}_Tiling_Mode");
638          TilingMode tiling_mode = (TilingMode) Math.Round(bc.floatValue);
639          tiling_mode = (TilingMode) EnumPopup(
640              MakeLabel("Tiling mode"), tiling_mode);
641          bc.floatValue = (int) tiling_mode;
642
643          bc = FindProperty($"_Decal{i}_UV_Select");
644          RangeProperty(
645              bc,
646              "UV channel");
647
648          bc = FindProperty($"_Decal{i}_Domain_Warping_Enable_Static");
649          enabled = bc.floatValue > 1E-6;
650          EditorGUI.BeginChangeCheck();
651          enabled = Toggle("Enable domain warping", enabled);
652          EditorGUI.EndChangeCheck();
653          bc.floatValue = enabled ? 1.0f : 0.0f;
654          SetKeyword($"_DECAL{i}_DOMAIN_WARPING", enabled);
655
656          if (enabled) {
657            bc = FindProperty($"_Decal{i}_Domain_Warping_Noise");
658            TexturePropertySingleLine(MakeLabel(bc, "Domain warping noise"), bc);
659            bc = FindProperty($"_Decal{i}_Domain_Warping_Strength");
660            FloatProperty(bc, "Domain warping noise strength");
661            bc = FindProperty($"_Decal{i}_Domain_Warping_Speed");
662            FloatProperty(bc, "Domain warping noise speed");
663            bc = FindProperty($"_Decal{i}_Domain_Warping_Octaves");
664            FloatProperty(bc, "Domain warping octaves");
665            bc = FindProperty($"_Decal{i}_Domain_Warping_Scale");
666            FloatProperty(bc, "Domain warping scale");
667          }
668        }
669        EditorGUI.indentLevel -= 1;
670        show_ui.RemoveAt(show_ui.Count - 1);
671    }
672    EditorGUI.indentLevel -= 1;
673    show_ui.RemoveAt(show_ui.Count - 1);
674  }
675
676  void SwapDecalSlots(int slotA, int slotB) {
677    // List of property suffixes to swap
678    string[] propertiesToSwap = new string[] {
679        "_Enable",
680        "_Color",
681        "_BaseColor",
682        "_BaseColor_Mode",
683        "_SDF_Threshold",
684        "_SDF_Softness",
685        "_SDF_Px_Range",
686        "_Roughness",
687        "_Metallic",
688        "_Emission_Strength",
689        "_Angle",
690        "_Alpha_Multiplier",
691        "_Round_Alpha_Multiplier",
692        "_Mask",
693        "_Mask_Invert",
694        "_Tiling_Mode",
695        "_UV_Select",
696        "_Domain_Warping_Enable_Static",
697        "_Domain_Warping_Noise",
698        "_Domain_Warping_Strength", 
699        "_Domain_Warping_Speed",
700        "_Domain_Warping_Octaves",
701        "_Domain_Warping_Scale"
702    };
703
704    // Record undo
705    RecordAction($"Swap decal slots {slotA} and {slotB}");
706
707    // For each property, swap values between slots
708    foreach (string prop in propertiesToSwap) {
709        MaterialProperty propA = FindProperty($"_Decal{slotA}{prop}");
710        MaterialProperty propB = FindProperty($"_Decal{slotB}{prop}");
711        
712        if (propA != null && propB != null) {
713            if (propA.type == MaterialProperty.PropType.Color) {
714                Color tempColor = propA.colorValue;
715                propA.colorValue = propB.colorValue;
716                propB.colorValue = tempColor;
717            } else if (propA.type == MaterialProperty.PropType.Texture) {
718                var tempTex = propA.textureValue;
719                propA.textureValue = propB.textureValue;
720                propB.textureValue = tempTex;
721                
722                // Also swap texture scale and offset
723                Vector4 tempScale = propA.textureScaleAndOffset;
724                propA.textureScaleAndOffset = propB.textureScaleAndOffset;
725                propB.textureScaleAndOffset = tempScale;
726            } else {
727              var tempValue = propA.floatValue;
728              propA.floatValue = propB.floatValue;
729              propB.floatValue = tempValue;
730            }
731        }
732    }
733  }
734
735  void DoEmission() {
736    show_ui.Add(AddCollapsibleMenu("Emission", "_Emission"));
737    EditorGUI.indentLevel += 1;
738
739    MaterialProperty bc;
740    MaterialProperty bct;
741    {
742      LabelField($"Base slot", EditorStyles.boldLabel);
743      EditorGUI.indentLevel += 1;
744
745      bc = FindProperty($"_EmissionColor");
746      bct = FindProperty($"_EmissionMap");
747      TexturePropertyWithHDRColor(
748          MakeLabel(bct, "Emission (RGB)"),
749          bct, bc, false);
750      SetKeyword($"_EMISSION", bct.textureValue);
751
752      EditorGUI.indentLevel -= 1;
753    }
754    for (int i = 0; i < 2; i++) {
755      LabelField($"Extra slot {i}", EditorStyles.boldLabel);
756      EditorGUI.indentLevel += 1;
757      {
758        bc = FindProperty($"_Emission{i}Color");
759        bct = FindProperty($"_Emission{i}Tex");
760        TexturePropertyWithHDRColor(
761            MakeLabel(bct, "Emission (RGB)"),
762            bct, bc, false);
763        SetKeyword($"_EMISSION{i}", bct.textureValue);
764
765        if (bct.textureValue) {
766          bc = FindProperty($"_Emission{i}_UV_Select");
767          RangeProperty(
768              bc,
769              "UV channel");
770
771          bc = FindProperty($"_Emission{i}Multiplier");
772          RangeProperty(bc, "Multiplier");
773        }
774      }
775      EditorGUI.indentLevel -= 1;
776    }
777
778    bc = FindProperty("_Global_Emission_Factor");
779    FloatProperty(bc, "Global emissions multiplier");
780
781    bc = FindProperty("_Global_Emission_Additive_Factor");
782    FloatProperty(bc, "Global emissions additive factor");
783
784    EditorGUI.indentLevel -= 1;
785    show_ui.RemoveAt(show_ui.Count - 1);
786  }
787
788  enum MatcapMode {
789    Add,
790    Multiply,
791    Replace,
792    Subtract,
793    Min,
794    Max,
795  };
796
797  void DoMatcap() {
798    for (int i = 0; i < 2; i++) {
799      show_ui.Add(AddCollapsibleMenu($"Matcap {i}", $"_Matcap{i}"));
800      EditorGUI.indentLevel += 1;
801
802      MaterialProperty bc;
803
804      bc = FindProperty($"_Matcap{i}");
805      TexturePropertySingleLine(
806          MakeLabel(bc, $"Matcap {i}"),
807          bc);
808      SetKeyword($"_MATCAP{i}", bc.textureValue);
809
810      if (!bc.textureValue) {
811        EditorGUI.indentLevel -= 1;
812        show_ui.RemoveAt(show_ui.Count - 1);
813        continue;
814      }
815
816      bc = FindProperty($"_Matcap{i}_Mask");
817      TexturePropertySingleLine(
818          MakeLabel(bc, "Mask"),
819          bc);
820      SetKeyword($"_MATCAP{i}_MASK", bc.textureValue);
821
822      bool enabled;  // c# is a shitty language
823      if (bc.textureValue) {
824        EditorGUI.indentLevel += 1;
825        bc = FindProperty($"_Matcap{i}_Mask_Invert");
826        enabled = bc.floatValue > 1E-6;
827        EditorGUI.BeginChangeCheck();
828        enabled = Toggle("Invert mask", enabled);
829        EditorGUI.EndChangeCheck();
830        bc.floatValue = enabled ? 1.0f : 0.0f;
831
832        bc = FindProperty($"_Matcap{i}_Mask_UV_Select");
833        RangeProperty(
834            bc,
835            "UV channel");
836        EditorGUI.indentLevel -= 1;
837      }
838
839      bc = FindProperty($"_Matcap{i}_Mask2");
840      TexturePropertySingleLine(
841          MakeLabel(bc, "Mask"),
842          bc);
843      SetKeyword($"_MATCAP{i}_MASK2", bc.textureValue);
844
845      if (bc.textureValue) {
846        EditorGUI.indentLevel += 1;
847        bc = FindProperty($"_Matcap{i}_Mask2_Invert_Colors");
848        enabled = bc.floatValue > 1E-6;
849        EditorGUI.BeginChangeCheck();
850        enabled = Toggle("Invert mask colors", enabled);
851        EditorGUI.EndChangeCheck();
852        bc.floatValue = enabled ? 1.0f : 0.0f;
853
854        bc = FindProperty($"_Matcap{i}_Mask2_Invert_Alpha");
855        enabled = bc.floatValue > 1E-6;
856        EditorGUI.BeginChangeCheck();
857        enabled = Toggle("Invert mask alpha", enabled);
858        EditorGUI.EndChangeCheck();
859        bc.floatValue = enabled ? 1.0f : 0.0f;
860
861        bc = FindProperty($"_Matcap{i}_Mask2_UV_Select");
862        RangeProperty(
863            bc,
864            "UV channel");
865        EditorGUI.indentLevel -= 1;
866      }
867
868      bc = FindProperty($"_Matcap{i}_Center_Eye_Fix");
869      enabled = bc.floatValue > 1E-6;
870      EditorGUI.BeginChangeCheck();
871      enabled = Toggle("Center eye fix", enabled);
872      EditorGUI.EndChangeCheck();
873      bc.floatValue = enabled ? 1.0f : 0.0f;
874
875      EditorGUI.BeginChangeCheck();
876      bc = FindProperty($"_Matcap{i}Mode");
877      MatcapMode mode = (MatcapMode) Math.Round(bc.floatValue);
878      mode = (MatcapMode) EnumPopup(
879          MakeLabel("Matcap mode"), mode);
880      if (EditorGUI.EndChangeCheck()) {
881        RecordAction($"Matcap {i}");
882        foreach (Material m in editor.targets) {
883          m.SetFloat($"_Matcap{i}Mode", (int) mode);
884        }
885      }
886
887      bc = FindProperty($"_Matcap{i}Str");
888      FloatProperty(
889          bc,
890          "Matcap strength");
891
892      bc = FindProperty($"_Matcap{i}MixFactor");
893      RangeProperty(
894          bc,
895          "Mix factor");
896
897      bc = FindProperty($"_Matcap{i}Emission");
898      FloatProperty(
899          bc,
900          "Emission strength");
901
902      bc = FindProperty($"_Matcap{i}Quantization");
903      FloatProperty(
904          bc,
905          "Quantization");
906
907      bc = FindProperty($"_Matcap{i}Normal_Enabled");
908      enabled = bc.floatValue > 1E-6;
909      EditorGUI.BeginChangeCheck();
910      enabled = Toggle("Replace normals", enabled);
911      EditorGUI.EndChangeCheck();
912      bc.floatValue = enabled ? 1.0f : 0.0f;
913      SetKeyword($"_MATCAP{i}_NORMAL", enabled);
914
915      if (enabled) {
916        EditorGUI.indentLevel += 1;
917        bc = FindProperty($"_Matcap{i}Normal");
918        TexturePropertySingleLine(
919            MakeLabel(bc, "Normal map"),
920            bc);
921        if (bc.textureValue) {
922          TextureScaleOffsetProperty(bc);
923
924          bc = FindProperty($"_Matcap{i}Normal_Str");
925          RangeProperty(bc, "Strength");
926
927          bc = FindProperty($"_Matcap{i}Normal_UV_Select");
928          RangeProperty(
929              bc,
930              "UV channel");
931
932          bc = FindProperty($"_Matcap{i}Normal_Mip_Bias");
933          FloatProperty(bc, "Mip bias");
934        }
935        EditorGUI.indentLevel -= 1;
936      }
937
938      bc = FindProperty($"_Matcap{i}Distortion0");
939      enabled = bc.floatValue > 1E-6;
940      EditorGUI.BeginChangeCheck();
941      enabled = Toggle("Enable distortion 0", enabled);
942      EditorGUI.EndChangeCheck();
943      bc.floatValue = enabled ? 1.0f : 0.0f;
944      SetKeyword($"_MATCAP{i}_DISTORTION0", enabled);
945
946      for (int j = 0; j < 4; j++) {
947        bc = FindProperty($"_Matcap{i}_Overwrite_Rim_Lighting_{j}");
948        enabled = bc.floatValue > 1E-6;
949        EditorGUI.BeginChangeCheck();
950        enabled = Toggle($"Overwrite rim lighting {j}", enabled);
951        EditorGUI.EndChangeCheck();
952        bc.floatValue = enabled ? 1.0f : 0.0f;
953      }
954
955      EditorGUI.indentLevel -= 1;
956      show_ui.RemoveAt(show_ui.Count - 1);
957    }
958  }
959
960  void DoRimLighting() {
961    for (int i = 0; i < 4; i++) {
962      show_ui.Add(AddCollapsibleMenu($"Rim lighting {i}", $"_Rim_Lighting{i}"));
963      EditorGUI.indentLevel += 1;
964
965      MaterialProperty bc;
966
967      bc = FindProperty($"_Rim_Lighting{i}_Enabled");
968      bool enabled = bc.floatValue > 1E-6;
969      EditorGUI.BeginChangeCheck();
970      enabled = Toggle("Enable", enabled);
971      EditorGUI.EndChangeCheck();
972      bc.floatValue = enabled ? 1.0f : 0.0f;
973      SetKeyword($"_RIM_LIGHTING{i}", enabled);
974
975      if (!enabled) {
976        EditorGUI.indentLevel -= 1;
977        show_ui.RemoveAt(show_ui.Count - 1);
978        continue;
979      }
980
981      bc = FindProperty($"_Rim_Lighting{i}_Color");
982      ColorProperty(bc, "Color (RGB)");
983
984      bc = FindProperty($"_Rim_Lighting{i}_Mask");
985      TexturePropertySingleLine(
986          MakeLabel(bc, "Mask"),
987          bc);
988      SetKeyword($"_RIM_LIGHTING{i}_MASK", bc.textureValue);
989      if (bc.textureValue) {
990        EditorGUI.indentLevel += 1;
991
992        bc = FindProperty($"_Rim_Lighting{i}_Mask_Invert");
993        enabled = bc.floatValue > 1E-6;
994        EditorGUI.BeginChangeCheck();
995        enabled = Toggle("Invert mask", enabled);
996        EditorGUI.EndChangeCheck();
997        bc.floatValue = enabled ? 1.0f : 0.0f;
998
999        bc = FindProperty($"_Rim_Lighting{i}_Mask_UV_Select");
1000        RangeProperty(bc, "UV channel");
1001
1002        EditorGUI.indentLevel -= 1;
1003      }
1004
1005      bc = FindProperty($"_Rim_Lighting{i}_Mask2");
1006      TexturePropertySingleLine(
1007          MakeLabel(bc, "Mask 2"),
1008          bc);
1009      SetKeyword($"_RIM_LIGHTING{i}_MASK2", bc.textureValue);
1010      if (bc.textureValue) {
1011        EditorGUI.indentLevel += 1;
1012
1013        bc = FindProperty($"_Rim_Lighting{i}_Mask2_Invert_Colors");
1014        enabled = bc.floatValue > 1E-6;
1015        EditorGUI.BeginChangeCheck();
1016        enabled = Toggle("Invert mask colors", enabled);
1017        EditorGUI.EndChangeCheck();
1018        bc.floatValue = enabled ? 1.0f : 0.0f;
1019
1020        bc = FindProperty($"_Rim_Lighting{i}_Mask2_Invert_Alpha");
1021        enabled = bc.floatValue > 1E-6;
1022        EditorGUI.BeginChangeCheck();
1023        enabled = Toggle("Invert mask alpha", enabled);
1024        EditorGUI.EndChangeCheck();
1025        bc.floatValue = enabled ? 1.0f : 0.0f;
1026
1027        bc = FindProperty($"_Rim_Lighting{i}_Mask2_UV_Select");
1028        RangeProperty(bc, "UV channel");
1029
1030        EditorGUI.indentLevel -= 1;
1031      }
1032
1033      bc = FindProperty($"_Rim_Lighting{i}_Mask_Sampler_Mode");
1034      SamplerMode sampler_mode = (SamplerMode) Math.Round(bc.floatValue);
1035      sampler_mode = (SamplerMode) EnumPopup(
1036          MakeLabel("Sampler mode"), sampler_mode);
1037      EditorGUI.EndChangeCheck();
1038      bc.floatValue = (int) sampler_mode;
1039
1040      SetKeyword($"_RIM_LIGHTING{i}_SAMPLER_LINEAR_REPEAT", sampler_mode == SamplerMode.LinearRepeat);
1041      SetKeyword($"_RIM_LIGHTING{i}_SAMPLER_LINEAR_CLAMP", sampler_mode == SamplerMode.LinearClamp);
1042      SetKeyword($"_RIM_LIGHTING{i}_SAMPLER_BILINEAR_REPEAT", sampler_mode == SamplerMode.BilinearRepeat);
1043      SetKeyword($"_RIM_LIGHTING{i}_SAMPLER_BILINEAR_CLAMP", sampler_mode == SamplerMode.BilinearClamp);
1044      SetKeyword($"_RIM_LIGHTING{i}_SAMPLER_POINT_REPEAT", sampler_mode == SamplerMode.PointRepeat);
1045      SetKeyword($"_RIM_LIGHTING{i}_SAMPLER_POINT_CLAMP", sampler_mode == SamplerMode.PointClamp);
1046
1047      bc = FindProperty($"_Rim_Lighting{i}_Center_Eye_Fix");
1048      enabled = bc.floatValue > 1E-6;
1049      EditorGUI.BeginChangeCheck();
1050      enabled = Toggle("Center eye fix", enabled);
1051      EditorGUI.EndChangeCheck();
1052      bc.floatValue = enabled ? 1.0f : 0.0f;
1053
1054      bc = FindProperty($"_Rim_Lighting{i}_Use_Texture_Normals");
1055      enabled = bc.floatValue > 1E-6;
1056      EditorGUI.BeginChangeCheck();
1057      enabled = Toggle("Use texture normals", enabled);
1058      EditorGUI.EndChangeCheck();
1059      bc.floatValue = enabled ? 1.0f : 0.0f;
1060
1061      EditorGUI.BeginChangeCheck();
1062      bc = FindProperty($"_Rim_Lighting{i}_Mode");
1063      MatcapMode mode = (MatcapMode) Math.Round(bc.floatValue);
1064      mode = (MatcapMode) EnumPopup(
1065          MakeLabel("Rim lighting mode"), mode);
1066      if (EditorGUI.EndChangeCheck()) {
1067        RecordAction("Rim lighting mode");
1068        foreach (Material m in editor.targets) {
1069          m.SetFloat($"_Rim_Lighting{i}_Mode", (int) mode);
1070        }
1071      }
1072
1073      bc = FindProperty($"_Rim_Lighting{i}_Center");
1074      FloatProperty(
1075          bc,
1076          "Center");
1077
1078      bc = FindProperty($"_Rim_Lighting{i}_Power");
1079      FloatProperty(
1080          bc,
1081          "Power");
1082
1083      bc = FindProperty($"_Rim_Lighting{i}_Strength");
1084      FloatProperty(
1085          bc,
1086          "Strength");
1087
1088      bc = FindProperty($"_Rim_Lighting{i}_Emission");
1089      FloatProperty(
1090          bc,
1091          "Emission");
1092
1093      bc = FindProperty($"_Rim_Lighting{i}_Quantization");
1094      FloatProperty(
1095          bc,
1096          "Quantization");
1097
1098      bc = FindProperty($"_Rim_Lighting{i}_Glitter_Enabled");
1099      enabled = bc.floatValue > 1E-6;
1100      EditorGUI.BeginChangeCheck();
1101      enabled = Toggle("Glitter", enabled);
1102      EditorGUI.EndChangeCheck();
1103      bc.floatValue = enabled ? 1.0f : 0.0f;
1104      SetKeyword($"_RIM_LIGHTING{i}_GLITTER", enabled);
1105
1106      if (enabled) {
1107        EditorGUI.indentLevel += 1;
1108
1109        bc = FindProperty($"_Rim_Lighting{i}_Glitter_Density");
1110        FloatProperty(
1111            bc,
1112            "Density");
1113
1114        bc = FindProperty($"_Rim_Lighting{i}_Glitter_Amount");
1115        FloatProperty(
1116            bc,
1117            "Amount");
1118
1119        bc = FindProperty($"_Rim_Lighting{i}_Glitter_Speed");
1120        FloatProperty(
1121            bc,
1122            "Speed");
1123
1124        bc = FindProperty($"_Rim_Lighting{i}_Glitter_Quantization");
1125        FloatProperty(
1126            bc,
1127            "Quantization");
1128
1129        bc = FindProperty($"_Rim_Lighting{i}_Glitter_UV_Select");
1130        RangeProperty(
1131            bc,
1132            "UV channel");
1133
1134        EditorGUI.indentLevel -= 1;
1135      }
1136
1137      bc = FindProperty($"_Rim_Lighting{i}_PolarMask_Enabled");
1138      enabled = bc.floatValue > 1E-6;
1139      EditorGUI.BeginChangeCheck();
1140      enabled = Toggle("Polar mask", enabled);
1141      EditorGUI.EndChangeCheck();
1142      bc.floatValue = enabled ? 1.0f : 0.0f;
1143      SetKeyword($"_RIM_LIGHTING{i}_POLAR_MASK", enabled);
1144
1145      if (enabled) {
1146        EditorGUI.indentLevel += 1;
1147        bc = FindProperty($"_Rim_Lighting{i}_PolarMask_Theta");
1148        FloatProperty(
1149            bc,
1150            "Theta");
1151        bc = FindProperty($"_Rim_Lighting{i}_PolarMask_Power");
1152        FloatProperty(
1153            bc,
1154            "Power");
1155        EditorGUI.indentLevel -= 1;
1156      }
1157
1158      bc = FindProperty($"_Rim_Lighting{i}_Custom_View_Vector_Enabled");
1159      enabled = bc.floatValue > 1E-6;
1160      EditorGUI.BeginChangeCheck();
1161      enabled = Toggle("Custom view vector", enabled);
1162      EditorGUI.EndChangeCheck();
1163      bc.floatValue = enabled ? 1.0f : 0.0f;
1164      SetKeyword($"_RIM_LIGHTING{i}_CUSTOM_VIEW_VECTOR", enabled);
1165
1166      if (enabled) {
1167        EditorGUI.indentLevel += 1;
1168        bc = FindProperty($"_Rim_Lighting{i}_Custom_View_Vector");
1169        VectorProperty(bc, "Vector");
1170        EditorGUI.indentLevel -= 1;
1171      }
1172
1173      bc = FindProperty($"_Rim_Lighting{i}_Reflect_In_World_Space");
1174      enabled = bc.floatValue > 1E-6;
1175      EditorGUI.BeginChangeCheck();
1176      enabled = Toggle("Reflect in world space", enabled);
1177      EditorGUI.EndChangeCheck();
1178      bc.floatValue = enabled ? 1.0f : 0.0f;
1179      SetKeyword($"_RIM_LIGHTING{i}_REFLECT_IN_WORLD", enabled);
1180
1181      EditorGUI.indentLevel -= 1;
1182      show_ui.RemoveAt(show_ui.Count - 1);
1183    }
1184  }
1185
1186  void DoMatcapRL() {
1187    show_ui.Add(AddCollapsibleMenu("Matcaps", "_Matcaps"));
1188    EditorGUI.indentLevel += 1;
1189
1190    DoMatcap();
1191    DoRimLighting();
1192
1193    EditorGUI.indentLevel -= 1;
1194    show_ui.RemoveAt(show_ui.Count - 1);
1195  }
1196
1197  enum NormalsMode {
1198    Flat,
1199    Spherical,
1200    Realistic,
1201    Toon
1202  };
1203
1204  void DoShadingMode() {
1205    show_ui.Add(AddCollapsibleMenu("Shading", "_Shading"));
1206    EditorGUI.indentLevel += 1;
1207
1208    MaterialProperty bc;
1209
1210    bc = FindProperty($"_Mesh_Normals_Mode");
1211    EditorGUI.BeginChangeCheck();
1212    NormalsMode mode = (NormalsMode) Math.Round(bc.floatValue, 0);
1213    mode = (NormalsMode) EnumPopup(
1214        MakeLabel("Normals mode"), mode);
1215    if (EditorGUI.EndChangeCheck()) {
1216      RecordAction("Rendering mode");
1217    }
1218    bc.floatValue = (float) mode;
1219
1220    if (mode == NormalsMode.Flat) {
1221      bc = FindProperty("_Flatten_Mesh_Normals_Str");
1222      FloatProperty(
1223          bc,
1224          "Flattening strength");
1225    }
1226    EditorGUI.indentLevel -= 1;
1227    show_ui.RemoveAt(show_ui.Count - 1);
1228  }
1229
1230  void DoOKLAB() {
1231    show_ui.Add(AddCollapsibleMenu("OKLAB", "_Hue_Shift_OKLAB"));
1232    EditorGUI.indentLevel += 1;
1233
1234    MaterialProperty bc;
1235
1236    bc = FindProperty("_OKLAB_Enabled");
1237    bool enabled = bc.floatValue > 1E-6;
1238    EditorGUI.BeginChangeCheck();
1239    enabled = Toggle("Enable", enabled);
1240    EditorGUI.EndChangeCheck();
1241    bc.floatValue = enabled ? 1.0f : 0.0f;
1242
1243    SetKeyword("_OKLAB", enabled);
1244
1245    if (enabled) {
1246      bc = FindProperty("_OKLAB_Mask");
1247      TexturePropertySingleLine(
1248          MakeLabel(bc, "Mask"),
1249          bc);
1250
1251      if (bc.textureValue) {
1252        bc = FindProperty("_OKLAB_Mask_Invert");
1253        enabled = bc.floatValue > 1E-6;
1254        EditorGUI.BeginChangeCheck();
1255        enabled = Toggle("Invert", enabled);
1256        EditorGUI.EndChangeCheck();
1257        bc.floatValue = enabled ? 1.0f : 0.0f;
1258      }
1259
1260      bc = FindProperty("_OKLAB_Lightness_Shift");
1261      RangeProperty(
1262          bc,
1263          "Lightness shift");
1264      bc = FindProperty("_OKLAB_Chroma_Shift");
1265      RangeProperty(
1266          bc,
1267          "Chroma shift");
1268      bc = FindProperty("_OKLAB_Hue_Shift");
1269      RangeProperty(
1270          bc,
1271          "Hue shift");
1272    }
1273    EditorGUI.indentLevel -= 1;
1274    show_ui.RemoveAt(show_ui.Count - 1);
1275  }
1276
1277  void DoHSV() {
1278    show_ui.Add(AddCollapsibleMenu("HSV", "_Hue_Shift_HSV"));
1279    EditorGUI.indentLevel += 1;
1280
1281    MaterialProperty bc;
1282
1283		for (int i = 0; i < 3; i++) {
1284			bc = FindProperty($"_HSV{i}_Enabled");
1285			bool enabled = bc.floatValue > 1E-6;
1286			EditorGUI.BeginChangeCheck();
1287			enabled = Toggle($"Enable slot {i}", enabled);
1288			EditorGUI.EndChangeCheck();
1289			bc.floatValue = enabled ? 1.0f : 0.0f;
1290
1291			SetKeyword($"_HSV{i}", enabled);
1292
1293			if (enabled) {
1294				bc = FindProperty($"_HSV{i}_Mask");
1295				TexturePropertySingleLine(
1296						MakeLabel(bc, "Mask"),
1297						bc);
1298
1299				if (bc.textureValue) {
1300					bc = FindProperty($"_HSV{i}_Mask_Invert");
1301					enabled = bc.floatValue > 1E-6;
1302					EditorGUI.BeginChangeCheck();
1303					enabled = Toggle("Invert", enabled);
1304					EditorGUI.EndChangeCheck();
1305					bc.floatValue = enabled ? 1.0f : 0.0f;
1306				}
1307
1308				bc = FindProperty($"_HSV{i}_Hue_Shift");
1309				RangeProperty(
1310						bc,
1311						"Hue shift");
1312				bc = FindProperty($"_HSV{i}_Sat_Shift");
1313				RangeProperty(
1314						bc,
1315						"Saturation shift");
1316				bc = FindProperty($"_HSV{i}_Val_Shift");
1317				RangeProperty(
1318						bc,
1319						"Value shift");
1320			}
1321		}
1322    EditorGUI.indentLevel -= 1;
1323    show_ui.RemoveAt(show_ui.Count - 1);
1324  }
1325
1326  void DoHueShift() {
1327    show_ui.Add(AddCollapsibleMenu("Hue shift", "_Hue_Shift"));
1328    EditorGUI.indentLevel += 1;
1329
1330    DoOKLAB();
1331    DoHSV();
1332
1333    EditorGUI.indentLevel -= 1;
1334    show_ui.RemoveAt(show_ui.Count - 1);
1335  }
1336
1337  void DoClones() {
1338    show_ui.Add(AddCollapsibleMenu("Clones", "_Clones"));
1339    EditorGUI.indentLevel += 1;
1340
1341    MaterialProperty bc;
1342
1343    bc = FindProperty("_Clones_Enabled");
1344    bool enabled = bc.floatValue > 1E-6;
1345    EditorGUI.BeginChangeCheck();
1346    enabled = Toggle("Enable", enabled);
1347    EditorGUI.EndChangeCheck();
1348    bc.floatValue = enabled ? 1.0f : 0.0f;
1349
1350    SetKeyword("_CLONES", enabled);
1351
1352    if (enabled) {
1353      bc = FindProperty("_Clones_Count");
1354      RangeProperty(
1355          bc,
1356          "Number of clones");
1357      bc = FindProperty("_Clones_dx");
1358      RangeProperty(bc, "x offset");
1359      bc = FindProperty("_Clones_dy");
1360      RangeProperty(bc, "y offset");
1361      bc = FindProperty("_Clones_dz");
1362      RangeProperty(bc, "z offset");
1363      bc = FindProperty("_Clones_Scale");
1364      VectorProperty(bc, "Scale");
1365    }
1366    EditorGUI.indentLevel -= 1;
1367    show_ui.RemoveAt(show_ui.Count - 1);
1368  }
1369
1370  void DoOutlines() {
1371    show_ui.Add(AddCollapsibleMenu("Outlines", "_Outlines"));
1372    EditorGUI.indentLevel += 1;
1373    MaterialProperty bc;
1374
1375    bc = FindProperty("_Outline_Width");
1376    RangeProperty(
1377        bc,
1378        "Outline width");
1379    SetKeyword("_OUTLINES", bc.floatValue > 1E-9);
1380
1381    if (bc.floatValue > 1E-6) {
1382      bc = FindProperty("_Outline_Color");
1383      ColorProperty(
1384          bc,
1385          "Outline color (RGBA)");
1386
1387      bc = FindProperty("_Outline_Emission_Strength");
1388      RangeProperty(
1389          bc,
1390          "Outline emission strength");
1391
1392      bc = FindProperty("_Outline_Mask");
1393      TexturePropertySingleLine(
1394          MakeLabel(bc, "Outline mask"),
1395          bc);
1396
1397      bc = FindProperty("_Outline_Mask_Invert");
1398      bool inverted = bc.floatValue > 1E-6;
1399      EditorGUI.BeginChangeCheck();
1400      inverted = Toggle("Invert mask", inverted);
1401      EditorGUI.EndChangeCheck();
1402      bc.floatValue = inverted ? 1.0f : 0.0f;
1403
1404      bc = FindProperty("_Outline_Width_Multiplier");
1405      FloatProperty(
1406          bc,
1407          "Outline width multiplier");
1408    }
1409    EditorGUI.indentLevel -= 1;
1410    show_ui.RemoveAt(show_ui.Count - 1);
1411  }
1412
1413  void DoGlitter() {
1414    show_ui.Add(AddCollapsibleMenu("Glitter", "_Glitter"));
1415    EditorGUI.indentLevel += 1;
1416
1417    MaterialProperty bc = FindProperty("_Glitter_Enabled");
1418    bool enabled = bc.floatValue > 1E-6;
1419
1420    EditorGUI.BeginChangeCheck();
1421    enabled = Toggle("Enable", enabled);
1422    EditorGUI.EndChangeCheck();
1423    SetKeyword("_GLITTER", enabled);
1424    bc.floatValue = enabled ? 1.0f : 0.0f;
1425
1426    if (enabled) {
1427      bc = FindProperty("_Glitter_Mask");
1428      TexturePropertySingleLine(
1429          MakeLabel(bc, "Glitter mask (RGBA)"),
1430          bc);
1431
1432      bc = FindProperty("_Glitter_Color");
1433      ColorProperty(bc, "Color");
1434
1435      bc = FindProperty("_Glitter_Density");
1436      FloatProperty(
1437          bc,
1438          "Density");
1439
1440      bc = FindProperty("_Glitter_Amount");
1441      FloatProperty(
1442          bc,
1443          "Amount");
1444
1445      bc = FindProperty("_Glitter_Speed");
1446      FloatProperty(
1447          bc,
1448          "Speed");
1449
1450      bc = FindProperty("_Glitter_Brightness_Lit");
1451      FloatProperty(
1452          bc,
1453          "Brightness (lit)");
1454
1455      bc = FindProperty("_Glitter_Brightness");
1456      FloatProperty(
1457          bc,
1458          "Brightness (unlit)");
1459
1460      bc = FindProperty("_Glitter_Angle");
1461      FloatProperty(
1462          bc,
1463          "Angle");
1464
1465      bc = FindProperty("_Glitter_Power");
1466      FloatProperty(
1467          bc,
1468          "Power");
1469
1470      bc = FindProperty("_Glitter_UV_Select");
1471      RangeProperty(
1472          bc,
1473          "UV select");
1474
1475      bc = FindProperty("_Glitter_Vector_Mask_Enabled");
1476      enabled = bc.floatValue > 1E-6;
1477      EditorGUI.BeginChangeCheck();
1478      enabled = Toggle("Vector mask", enabled);
1479      EditorGUI.EndChangeCheck();
1480      bc.floatValue = enabled ? 1.0f : 0.0f;
1481
1482      if (enabled) {
1483        EditorGUI.indentLevel += 1;
1484
1485        bc = FindProperty("_Glitter_Vector_Mask_Vector");
1486        VectorProperty(bc, "Vector");
1487        bc = FindProperty("_Glitter_Vector_Mask_Power");
1488        FloatProperty(bc, "Power");
1489        bc = FindProperty("_Glitter_Vector_Mask_Invert");
1490        bool inverted = bc.floatValue > 1E-6;
1491        EditorGUI.BeginChangeCheck();
1492        inverted = Toggle("Invert", inverted);
1493        EditorGUI.EndChangeCheck();
1494        bc.floatValue = inverted ? 1.0f : 0.0f;
1495
1496        EditorGUI.indentLevel -= 1;
1497      }
1498    }
1499    EditorGUI.indentLevel -= 1;
1500    show_ui.RemoveAt(show_ui.Count - 1);
1501  }
1502
1503  void DoExplosion() {
1504    show_ui.Add(AddCollapsibleMenu("Explosion", "_Explosion"));
1505    EditorGUI.indentLevel += 1;
1506
1507    MaterialProperty bc = FindProperty("_Explode_Toggle");
1508    bool enabled = bc.floatValue > 1E-6;
1509
1510    EditorGUI.BeginChangeCheck();
1511    enabled = Toggle("Enable", enabled);
1512    EditorGUI.EndChangeCheck();
1513    SetKeyword("_EXPLODE", enabled);
1514    bc.floatValue = enabled ? 1.0f : 0.0f;
1515
1516    bc = FindProperty("_Explode_Phase");
1517    if (enabled) {
1518      RangeProperty(
1519          bc,
1520          "Explosion phase");
1521    } else {
1522      bc.floatValue = 0.0f;
1523    }
1524    bc = FindProperty("_OutlinesCull");
1525    bc.floatValue = (float) UnityEngine.Rendering.CullMode.Front;
1526
1527    /*
1528    if (enabled) {
1529      bc = FindProperty("_Explode_Phase");
1530      RangeProperty(
1531          bc,
1532          "Explosion phase");
1533      if (bc.floatValue > 1E-3) {
1534        bc = FindProperty("_Cull");
1535        bc.floatValue = (float) UnityEngine.Rendering.CullMode.Back;
1536      } else {
1537        bc = FindProperty("_Cull");
1538        bc.floatValue = (float) UnityEngine.Rendering.CullMode.Front;
1539      }
1540    } else {
1541      bc = FindProperty("_Explode_Phase");
1542      bc.floatValue = 0.0f;
1543      bc = FindProperty("_Cull");
1544      bc.floatValue = (float) UnityEngine.Rendering.CullMode.Front;
1545    }
1546    */
1547    EditorGUI.indentLevel -= 1;
1548    show_ui.RemoveAt(show_ui.Count - 1);
1549  }
1550
1551  void DoGeoScroll() {
1552    show_ui.Add(AddCollapsibleMenu("Geometry scroll", "_Geometry_Scroll"));
1553    EditorGUI.indentLevel += 1;
1554
1555    MaterialProperty bc = FindProperty("_Scroll_Toggle");
1556    bool enabled = bc.floatValue > 1E-6;
1557
1558    EditorGUI.BeginChangeCheck();
1559    enabled = Toggle("Enable", enabled);
1560    EditorGUI.EndChangeCheck();
1561    SetKeyword("_SCROLL", enabled);
1562    bc.floatValue = enabled ? 1.0f : 0.0f;
1563
1564    if (enabled) {
1565      bc = FindProperty("_Scroll_Top");
1566      RangeProperty(
1567          bc,
1568          "Scroll top");
1569
1570      bc = FindProperty("_Scroll_Bottom");
1571      RangeProperty(
1572          bc,
1573          "Scroll bottom");
1574
1575      bc = FindProperty("_Scroll_Width");
1576      RangeProperty(
1577          bc,
1578          "Scroll width");
1579
1580      bc = FindProperty("_Scroll_Strength");
1581      RangeProperty(
1582          bc,
1583          "Scroll strength");
1584
1585      bc = FindProperty("_Scroll_Speed");
1586      RangeProperty(
1587          bc,
1588          "Scroll speed");
1589    }
1590    EditorGUI.indentLevel -= 1;
1591    show_ui.RemoveAt(show_ui.Count - 1);
1592  }
1593
1594  void DoUVScroll() {
1595    show_ui.Add(AddCollapsibleMenu("UV Scroll", "_UV_Scroll"));
1596    EditorGUI.indentLevel += 1;
1597
1598    MaterialProperty bc = FindProperty("_UVScroll_Enabled");
1599    bool enabled = bc.floatValue > 1E-6;
1600
1601    EditorGUI.BeginChangeCheck();
1602    enabled = Toggle("Enable", enabled);
1603    EditorGUI.EndChangeCheck();
1604    SetKeyword("_UVSCROLL", enabled);
1605    bc.floatValue = enabled ? 1.0f : 0.0f;
1606
1607    if (enabled) {
1608      bc = FindProperty("_UVScroll_Mask");
1609      TexturePropertySingleLine(
1610          MakeLabel(bc, "Mask"),
1611          bc);
1612
1613      bc = FindProperty("_UVScroll_U_Speed");
1614      FloatProperty(
1615          bc,
1616          "U speed");
1617
1618      bc = FindProperty("_UVScroll_V_Speed");
1619      FloatProperty(
1620          bc,
1621          "V speed");
1622
1623      bc = FindProperty("_UVScroll_Alpha");
1624      TexturePropertySingleLine(
1625          MakeLabel(bc, "Alpha"),
1626          bc);
1627    }
1628    EditorGUI.indentLevel -= 1;
1629    show_ui.RemoveAt(show_ui.Count - 1);
1630  }
1631
1632  void DoGimmickFlatColor()
1633  {
1634    MaterialProperty bc;
1635    bc = FindProperty("_Gimmick_Flat_Color_Enable_Static");
1636    bool enabled = (bc.floatValue != 0.0);
1637    EditorGUI.BeginChangeCheck();
1638    enabled = Toggle("Flat color", enabled);
1639    EditorGUI.EndChangeCheck();
1640    bc.floatValue = enabled ? 1.0f : 0.0f;
1641    SetKeyword("_GIMMICK_FLAT_COLOR", enabled);
1642
1643    if (!enabled) {
1644      return;
1645    }
1646
1647    EditorGUI.indentLevel += 1;
1648
1649    bc = FindProperty("_Gimmick_Flat_Color_Enable_Dynamic");
1650    enabled = (bc.floatValue != 0.0);
1651    EditorGUI.BeginChangeCheck();
1652    enabled = Toggle("Enable (runtime switch)", enabled);
1653    EditorGUI.EndChangeCheck();
1654    bc.floatValue = enabled ? 1.0f : 0.0f;
1655
1656    bc = FindProperty("_Gimmick_Flat_Color_Color");
1657    ColorProperty(bc, "Color");
1658    bc = FindProperty("_Gimmick_Flat_Color_Emission");
1659    ColorProperty(bc, "Emission");
1660
1661    EditorGUI.indentLevel -= 1;
1662  }
1663
1664  void DoGimmickUVDomainWarping() {
1665    MaterialProperty bc;
1666    bc = FindProperty("_Gimmick_UV_Domain_Warping_Enable_Static");
1667    bool enabled = (bc.floatValue != 0.0);
1668    EditorGUI.BeginChangeCheck();
1669    enabled = Toggle("UV domain warping", enabled);
1670    EditorGUI.EndChangeCheck();
1671    bc.floatValue = enabled ? 1.0f : 0.0f;
1672    SetKeyword("_GIMMICK_UV_DOMAIN_WARPING", enabled);
1673
1674    if (!enabled) {
1675      return;
1676    }
1677
1678    EditorGUI.indentLevel += 1;
1679
1680    bc = FindProperty("_Gimmick_UV_Domain_Warping_Octaves");
1681    FloatProperty(bc, "Octaves");
1682    bc = FindProperty("_Gimmick_UV_Domain_Warping_Strength");
1683    FloatProperty(bc, "Strength");
1684    bc = FindProperty("_Gimmick_UV_Domain_Warping_Scale");
1685    FloatProperty(bc, "Scale");
1686    bc = FindProperty("_Gimmick_UV_Domain_Warping_Speed");
1687    FloatProperty(bc, "Speed");
1688    bc = FindProperty("_Gimmick_UV_Domain_Warping_Noise");
1689    TexturePropertySingleLine(
1690        MakeLabel(bc, "Noise"),
1691        bc);
1692    bc = FindProperty("_Gimmick_UV_Domain_Warping_Mask");
1693    TexturePropertySingleLine(
1694        MakeLabel(bc, "Mask"),
1695        bc);
1696    if (bc.textureValue) {
1697      EditorGUI.indentLevel += 1;
1698      bc = FindProperty("_Gimmick_UV_Domain_Warping_Mask_Invert");
1699      FloatProperty(bc, "Invert");
1700      EditorGUI.indentLevel -= 1;
1701    }
1702
1703    EditorGUI.indentLevel -= 1;
1704  }
1705
1706  void DoGimmickQuantizeLocation() {
1707    MaterialProperty bc;
1708    bc = FindProperty("_Gimmick_Quantize_Location_Enable_Static");
1709    bool enabled = (bc.floatValue != 0.0);
1710    EditorGUI.BeginChangeCheck();
1711    enabled = Toggle("Quantize location", enabled);
1712    EditorGUI.EndChangeCheck();
1713    bc.floatValue = enabled ? 1.0f : 0.0f;
1714    SetKeyword("_GIMMICK_QUANTIZE_LOCATION", enabled);
1715
1716    if (!enabled) {
1717      return;
1718    }
1719
1720    EditorGUI.indentLevel += 1;
1721
1722    bc = FindProperty("_Gimmick_Quantize_Location_Enable_Dynamic");
1723    enabled = (bc.floatValue != 0.0);
1724    EditorGUI.BeginChangeCheck();
1725    enabled = Toggle("Enable (runtime switch)", enabled);
1726    EditorGUI.EndChangeCheck();
1727    bc.floatValue = enabled ? 1.0f : 0.0f;
1728
1729    bc = FindProperty("_Gimmick_Quantize_Location_Precision");
1730    FloatProperty(bc, "Precision");
1731    bc = FindProperty("_Gimmick_Quantize_Location_Direction");
1732    FloatProperty(bc, "Direction");
1733    bc = FindProperty("_Gimmick_Quantize_Location_Multiplier");
1734    RangeProperty(bc, "Multiplier");
1735    bc = FindProperty("_Gimmick_Quantize_Location_Mask");
1736    TexturePropertySingleLine(
1737        MakeLabel(bc, "Mask"),
1738        bc);
1739
1740    bc = FindProperty("_Gimmick_Quantize_Location_Audiolink_Enable_Static");
1741    enabled = (bc.floatValue != 0.0);
1742    EditorGUI.BeginChangeCheck();
1743    enabled = Toggle("Audiolink", enabled);
1744    EditorGUI.EndChangeCheck();
1745    bc.floatValue = enabled ? 1.0f : 0.0f;
1746    SetKeyword("_GIMMICK_QUANTIZE_LOCATION_AUDIOLINK", enabled);
1747
1748    if (enabled) {
1749      EditorGUI.indentLevel += 1;
1750
1751      bc = FindProperty("_Gimmick_Quantize_Location_Audiolink_Enable_Dynamic");
1752      enabled = (bc.floatValue != 0.0);
1753      EditorGUI.BeginChangeCheck();
1754      enabled = Toggle("Enable (runtime switch)", enabled);
1755      EditorGUI.EndChangeCheck();
1756      bc.floatValue = enabled ? 1.0f : 0.0f;
1757
1758      bc = FindProperty("_Gimmick_Quantize_Location_Audiolink_Strength");
1759      FloatProperty(
1760          bc,
1761          "Strength");
1762
1763      EditorGUI.indentLevel -= 1;
1764    }
1765
1766    EditorGUI.indentLevel -= 1;
1767  }
1768
1769  void DoGimmickShearLocation() {
1770    MaterialProperty bc;
1771    bc = FindProperty("_Gimmick_Shear_Location_Enable_Static");
1772    bool enabled = (bc.floatValue != 0.0);
1773    EditorGUI.BeginChangeCheck();
1774    enabled = Toggle("Shear location", enabled);
1775    EditorGUI.EndChangeCheck();
1776    bc.floatValue = enabled ? 1.0f : 0.0f;
1777    SetKeyword("_GIMMICK_SHEAR_LOCATION", enabled);
1778
1779    if (!enabled) {
1780      return;
1781    }
1782
1783    EditorGUI.indentLevel += 1;
1784
1785    bc = FindProperty("_Gimmick_Shear_Location_Enable_Dynamic");
1786    enabled = (bc.floatValue != 0.0);
1787    EditorGUI.BeginChangeCheck();
1788    enabled = Toggle("Enable (runtime switch)", enabled);
1789    EditorGUI.EndChangeCheck();
1790    bc.floatValue = enabled ? 1.0f : 0.0f;
1791
1792    bc = FindProperty("_Gimmick_Shear_Location_Strength");
1793    VectorProperty(bc, "Strength");
1794
1795    bc = FindProperty("_Gimmick_Shear_Location_Mesh_Renderer_Fix");
1796    enabled = (bc.floatValue != 0.0);
1797    EditorGUI.BeginChangeCheck();
1798    enabled = Toggle("Mesh renderer fix", enabled);
1799    EditorGUI.EndChangeCheck();
1800    bc.floatValue = enabled ? 1.0f : 0.0f;
1801
1802    if (enabled) {
1803      EditorGUI.indentLevel += 1;
1804      bc = FindProperty("_Gimmick_Shear_Location_Mesh_Renderer_Offset");
1805      VectorProperty(bc, "Offset");
1806      bc = FindProperty("_Gimmick_Shear_Location_Mesh_Renderer_Rotation");
1807      VectorProperty(bc, "Rotation");
1808      bc = FindProperty("_Gimmick_Shear_Location_Mesh_Renderer_Scale");
1809      VectorProperty(bc, "Scale");
1810      EditorGUI.indentLevel -= 1;
1811    }
1812
1813    EditorGUI.indentLevel -= 1;
1814  }
1815
1816  void DoGimmickSpherizeLocation() {
1817    MaterialProperty bc;
1818    bc = FindProperty("_Gimmick_Spherize_Location_Enable_Static");
1819    bool enabled = (bc.floatValue != 0.0);
1820    EditorGUI.BeginChangeCheck();
1821    enabled = Toggle("Spherize location", enabled);
1822    EditorGUI.EndChangeCheck();
1823    bc.floatValue = enabled ? 1.0f : 0.0f;
1824    SetKeyword("_GIMMICK_SPHERIZE_LOCATION", enabled);
1825
1826    if (!enabled) {
1827      return;
1828    }
1829
1830    EditorGUI.indentLevel += 1;
1831
1832    bc = FindProperty("_Gimmick_Spherize_Location_Enable_Dynamic");
1833    enabled = (bc.floatValue != 0.0);
1834    EditorGUI.BeginChangeCheck();
1835    enabled = Toggle("Enable (runtime switch)", enabled);
1836    EditorGUI.EndChangeCheck();
1837    bc.floatValue = enabled ? 1.0f : 0.0f;
1838
1839    bc = FindProperty("_Gimmick_Spherize_Location_Strength");
1840    RangeProperty(bc, "Strength");
1841    bc = FindProperty("_Gimmick_Spherize_Location_Radius");
1842    FloatProperty(bc, "Radius");
1843
1844    EditorGUI.indentLevel -= 1;
1845  }
1846
1847
1848  void DoGimmickEyes00() {
1849    MaterialProperty bc;
1850    bc = FindProperty("_Gimmick_Eyes00_Enable_Static");
1851    bool enabled = (bc.floatValue != 0.0);
1852    EditorGUI.BeginChangeCheck();
1853    enabled = Toggle("Eyes 00", enabled);
1854    EditorGUI.EndChangeCheck();
1855    bc.floatValue = enabled ? 1.0f : 0.0f;
1856    SetKeyword("_GIMMICK_EYES_00", enabled);
1857
1858    if (!enabled) {
1859      return;
1860    }
1861
1862    EditorGUI.indentLevel += 1;
1863
1864    bc = FindProperty("_Gimmick_Eyes00_Effect_Mask");
1865    TexturePropertySingleLine(
1866        MakeLabel(bc, "Effect mask"),
1867        bc);
1868
1869    EditorGUI.indentLevel -= 1;
1870  }
1871
1872  void DoGimmickEyes01() {
1873    MaterialProperty bc;
1874    bc = FindProperty("_Gimmick_Eyes01_Enable_Static");
1875    bool enabled = (bc.floatValue != 0.0);
1876    EditorGUI.BeginChangeCheck();
1877    enabled = Toggle("Eyes 01", enabled);
1878    EditorGUI.EndChangeCheck();
1879    bc.floatValue = enabled ? 1.0f : 0.0f;
1880    SetKeyword("_GIMMICK_EYES_01", enabled);
1881
1882    if (!enabled) {
1883      return;
1884    }
1885
1886    EditorGUI.indentLevel += 1;
1887
1888    bc = FindProperty("_Gimmick_Eyes01_Radius");
1889    FloatProperty(bc, "Radius (meters, object space)");
1890
1891    EditorGUI.indentLevel -= 1;
1892  }
1893
1894  void DoGimmickEyes02() {
1895    MaterialProperty bc;
1896    bc = FindProperty("_Gimmick_Eyes02_Enable_Static");
1897    bool enabled = (bc.floatValue != 0.0);
1898    EditorGUI.BeginChangeCheck();
1899    enabled = Toggle("Eyes 02", enabled);
1900    EditorGUI.EndChangeCheck();
1901    bc.floatValue = enabled ? 1.0f : 0.0f;
1902    SetKeyword("_GIMMICK_EYES_02", enabled);
1903
1904    if (!enabled) {
1905      return;
1906    }
1907
1908    EditorGUI.indentLevel += 1;
1909
1910    bc = FindProperty("_Gimmick_Eyes02_N");
1911    RangeProperty(bc, "n");
1912    bc = FindProperty("_Gimmick_Eyes02_A0");
1913    RangeProperty(bc, "a0");
1914    bc = FindProperty("_Gimmick_Eyes02_A1");
1915    RangeProperty(bc, "a1");
1916    bc = FindProperty("_Gimmick_Eyes02_A2");
1917    RangeProperty(bc, "a2");
1918    bc = FindProperty("_Gimmick_Eyes02_A3");
1919    RangeProperty(bc, "a3");
1920    bc = FindProperty("_Gimmick_Eyes02_A4");
1921    RangeProperty(bc, "a4");
1922
1923    bc = FindProperty("_Gimmick_Eyes02_Animate");
1924    enabled = (bc.floatValue != 0.0);
1925    EditorGUI.BeginChangeCheck();
1926    enabled = Toggle("Animate", enabled);
1927    EditorGUI.EndChangeCheck();
1928    bc.floatValue = enabled ? 1.0f : 0.0f;
1929    if (enabled) {
1930      EditorGUI.indentLevel += 1;
1931      bc = FindProperty("_Gimmick_Eyes02_Animate_Speed");
1932      FloatProperty(bc, "Speed");
1933
1934      bc = FindProperty("_Gimmick_Eyes02_Animate_Strength");
1935      FloatProperty(bc, "Strength");
1936      EditorGUI.indentLevel -= 1;
1937    }
1938
1939    bc = FindProperty("_Gimmick_Eyes02_UV_X_Symmetry");
1940    enabled = (bc.floatValue != 0.0);
1941    EditorGUI.BeginChangeCheck();
1942    enabled = Toggle("UV x symmetry", enabled);
1943    EditorGUI.EndChangeCheck();
1944    bc.floatValue = enabled ? 1.0f : 0.0f;
1945
1946    bc = FindProperty("_Gimmick_Eyes02_UV_Adjust");
1947    VectorProperty(bc, "UV scale & offset");
1948
1949    bc = FindProperty("_Gimmick_Eyes02_Albedo");
1950    ColorProperty(bc, "Albedo");
1951    bc = FindProperty("_Gimmick_Eyes02_Metallic");
1952    FloatProperty(bc, "Metallic");
1953    bc = FindProperty("_Gimmick_Eyes02_Roughness");
1954    FloatProperty(bc, "Roughness");
1955    bc = FindProperty("_Gimmick_Eyes02_Emission");
1956    ColorProperty(bc, "Emission");
1957
1958    EditorGUI.indentLevel -= 1;
1959  }
1960
1961  void DoGimmickDownstairs2() {
1962    MaterialProperty bc;
1963    bc = FindProperty("_Gimmick_DS2_Enable_Static");
1964    bool enabled = (bc.floatValue != 0.0);
1965    EditorGUI.BeginChangeCheck();
1966    enabled = Toggle("Downstairs 2", enabled);
1967    EditorGUI.EndChangeCheck();
1968    bc.floatValue = enabled ? 1.0f : 0.0f;
1969    SetKeyword("_GIMMICK_DS2", enabled);
1970
1971    if (!enabled) {
1972      return;
1973    }
1974
1975    EditorGUI.indentLevel += 1;
1976
1977    bc = FindProperty("_Gimmick_DS2_Mask");
1978    TexturePropertySingleLine(MakeLabel(bc, "Mask"), bc);
1979    bc = FindProperty("_Gimmick_DS2_Noise");
1980    TexturePropertySingleLine(MakeLabel(bc, "Noise"), bc);
1981    bc = FindProperty("_Gimmick_DS2_Albedo_Factor");
1982    FloatProperty(bc, "Albedo factor");
1983    bc = FindProperty("_Gimmick_DS2_Emission_Factor");
1984    FloatProperty(bc, "Emission factor");
1985
1986    bc = FindProperty("_Gimmick_DS2_Choice");
1987    FloatProperty(bc, "Choice");
1988    float choice = bc.floatValue;
1989
1990    if (Mathf.Round(choice) == -1) {
1991      EditorGUI.indentLevel += 1;
1992
1993      EditorGUI.indentLevel -= 1;
1994    }
1995
1996    if (Mathf.Round(choice) == 0) {
1997      EditorGUI.indentLevel += 1;
1998
1999      bc = FindProperty("_Gimmick_DS2_00_Domain_Warping_Octaves");
2000      FloatProperty(bc, "Domain warping octaves");
2001      bc = FindProperty("_Gimmick_DS2_00_Domain_Warping_Strength");
2002      FloatProperty(bc, "Domain warping strength");
2003      bc = FindProperty("_Gimmick_DS2_00_Domain_Warping_Scale");
2004      FloatProperty(bc, "Domain warping scale");
2005      bc = FindProperty("_Gimmick_DS2_00_Domain_Warping_Speed");
2006      FloatProperty(bc, "Domain warping speed");
2007
2008      EditorGUI.indentLevel -= 1;
2009    }
2010
2011    if (Mathf.Round(choice) == 1) {
2012      EditorGUI.indentLevel += 1;
2013
2014      bc = FindProperty("_Gimmick_DS2_01_Period");
2015      VectorProperty(bc, "Period");
2016      bc = FindProperty("_Gimmick_DS2_01_Count");
2017      VectorProperty(bc, "Count");
2018      bc = FindProperty("_Gimmick_DS2_01_Radius");
2019      FloatProperty(bc, "Radius");
2020
2021      bc = FindProperty("_Gimmick_DS2_01_Domain_Warping_Octaves");
2022      FloatProperty(bc, "Domain warping octaves");
2023      bc = FindProperty("_Gimmick_DS2_01_Domain_Warping_Strength");
2024      FloatProperty(bc, "Domain warping strength");
2025      bc = FindProperty("_Gimmick_DS2_01_Domain_Warping_Scale");
2026      FloatProperty(bc, "Domain warping scale");
2027      bc = FindProperty("_Gimmick_DS2_01_Domain_Warping_Speed");
2028      FloatProperty(bc, "Domain warping speed");
2029
2030      EditorGUI.indentLevel -= 1;
2031    }
2032
2033    if (Mathf.Round(choice) == 2) {
2034      EditorGUI.indentLevel += 1;
2035
2036      bc = FindProperty("_Gimmick_DS2_02_Period");
2037      VectorProperty(bc, "Period");
2038      bc = FindProperty("_Gimmick_DS2_02_Count");
2039      VectorProperty(bc, "Count");
2040      bc = FindProperty("_Gimmick_DS2_02_Edge_Length");
2041      FloatProperty(bc, "Edge length");
2042
2043      bc = FindProperty("_Gimmick_DS2_02_Domain_Warping_Octaves");
2044      FloatProperty(bc, "Domain warping octaves");
2045      bc = FindProperty("_Gimmick_DS2_02_Domain_Warping_Strength");
2046      FloatProperty(bc, "Domain warping strength");
2047      bc = FindProperty("_Gimmick_DS2_02_Domain_Warping_Scale");
2048      FloatProperty(bc, "Domain warping scale");
2049      bc = FindProperty("_Gimmick_DS2_02_Domain_Warping_Speed");
2050      FloatProperty(bc, "Domain warping speed");
2051
2052      EditorGUI.indentLevel -= 1;
2053    }
2054
2055    if (Mathf.Round(choice) == 3) {
2056      EditorGUI.indentLevel += 1;
2057
2058      bc = FindProperty("_Gimmick_DS2_03_Period");
2059      VectorProperty(bc, "Period");
2060      bc = FindProperty("_Gimmick_DS2_03_Count");
2061      VectorProperty(bc, "Count");
2062      bc = FindProperty("_Gimmick_DS2_03_Edge_Length");
2063      FloatProperty(bc, "Edge length");
2064
2065      EditorGUI.indentLevel -= 1;
2066    }
2067
2068    if (Mathf.Round(choice) == 11) {
2069      EditorGUI.indentLevel += 1;
2070
2071      bc = FindProperty("_Gimmick_DS2_11_Fog_Enable");
2072      enabled = (bc.floatValue != 0.0);
2073      EditorGUI.BeginChangeCheck();
2074      enabled = Toggle("Fog enable", enabled);
2075      EditorGUI.EndChangeCheck();
2076      bc.floatValue = enabled ? 1.0f : 0.0f;
2077
2078      if (enabled) {
2079        bc = FindProperty("_Gimmick_DS2_11_Fog_Density");
2080        FloatProperty(bc, "Fog density");
2081        bc = FindProperty("_Gimmick_DS2_11_Fog_Sun_Direction");
2082        VectorProperty(bc, "Fog sun direction");
2083        bc = FindProperty("_Gimmick_DS2_11_Fog_Sun_Exponent");
2084        FloatProperty(bc, "Fog sun exponent");
2085        bc = FindProperty("_Gimmick_DS2_11_Fog_Color");
2086        ColorProperty(bc, "Fog color");
2087        bc = FindProperty("_Gimmick_DS2_11_Fog_Sun_Color");
2088        ColorProperty(bc, "Fog sun color");
2089
2090        bc = FindProperty("_Gimmick_DS2_11_Fog_Sun_Color_2_Enable");
2091        enabled = (bc.floatValue != 0.0);
2092        EditorGUI.BeginChangeCheck();
2093        enabled = Toggle("Fog sun color 2 enable", enabled);
2094        EditorGUI.EndChangeCheck();
2095        bc.floatValue = enabled ? 1.0f : 0.0f;
2096
2097        if (enabled) {
2098          bc = FindProperty("_Gimmick_DS2_11_Fog_Sun_Color_2");
2099          ColorProperty(bc, "Fog sun color 2");
2100          bc = FindProperty("_Gimmick_DS2_11_Fog_Sun_Exponent_2");
2101          FloatProperty(bc, "Fog sun exponent 2");
2102        }
2103      }
2104
2105      bc = FindProperty("_Gimmick_DS2_11_FBM");
2106      TexturePropertySingleLine(MakeLabel(bc, "FBM"), bc);
2107
2108      bc = FindProperty("_Gimmick_DS2_11_Snow_Color");
2109      ColorProperty(bc, "Snow color");
2110      bc = FindProperty("_Gimmick_DS2_11_Snowline");
2111      FloatProperty(bc, "Snowline");
2112      bc = FindProperty("_Gimmick_DS2_11_Snowline_Octaves");
2113      FloatProperty(bc, "Snowline octaves");
2114      bc = FindProperty("_Gimmick_DS2_11_Snowline_Width");
2115      FloatProperty(bc, "Snowline width");
2116      bc = FindProperty("_Gimmick_DS2_11_Snowline_Noise_Scale");
2117      FloatProperty(bc, "Snowline noise scale");
2118
2119      bc = FindProperty("_Gimmick_DS2_11_Rock_Color");
2120      ColorProperty(bc, "Rock color");
2121      bc = FindProperty("_Gimmick_DS2_11_Rockline");
2122      FloatProperty(bc, "Rockline");
2123      bc = FindProperty("_Gimmick_DS2_11_Rockline_Octaves");
2124      FloatProperty(bc, "Rockline octaves");
2125      bc = FindProperty("_Gimmick_DS2_11_Rockline_Width");
2126      FloatProperty(bc, "Rockline width");
2127      bc = FindProperty("_Gimmick_DS2_11_Rockline_Noise_Scale");
2128      FloatProperty(bc, "Rockline noise scale");
2129
2130      bc = FindProperty("_Gimmick_DS2_11_Grass_Color");
2131      ColorProperty(bc, "Grass color");
2132      bc = FindProperty("_Gimmick_DS2_11_Alpha");
2133      RangeProperty(bc, "Alpha");
2134
2135      bc = FindProperty("_Gimmick_DS2_11_Offset");
2136      VectorProperty(bc, "Offset");
2137      bc = FindProperty("_Gimmick_DS2_11_Octaves");
2138      FloatProperty(bc, "Octaves");
2139      bc = FindProperty("_Gimmick_DS2_11_March_Initial_Offset");
2140      FloatProperty(bc, "March initial offset");
2141      bc = FindProperty("_Gimmick_DS2_11_March_Initial_Step_Size");
2142      FloatProperty(bc, "March initial step size");
2143      bc = FindProperty("_Gimmick_DS2_11_March_Steps");
2144      FloatProperty(bc, "March steps");
2145      bc = FindProperty("_Gimmick_DS2_11_March_Backtrack_Steps");
2146      FloatProperty(bc, "March backtrack steps");
2147      bc = FindProperty("_Gimmick_DS2_11_Simulation_Scale");
2148      FloatProperty(bc, "Simulation scale");
2149      bc = FindProperty("_Gimmick_DS2_11_Coord_Scale");
2150      FloatProperty(bc, "Coord scale");
2151      bc = FindProperty("_Gimmick_DS2_11_Height_Scale");
2152      FloatProperty(bc, "Height scale");
2153      bc = FindProperty("_Gimmick_DS2_11_Height_Power");
2154      FloatProperty(bc, "Height power");
2155      bc = FindProperty("_Gimmick_DS2_11_Valley_Power");
2156      FloatProperty(bc, "Valley power");
2157      bc = FindProperty("_Gimmick_DS2_11_Valley_Depth");
2158      FloatProperty(bc, "Valley depth");
2159      bc = FindProperty("_Gimmick_DS2_11_Early_Exit_Cutoff_Cos_Theta");
2160      FloatProperty(bc, "Early exit cutoff (cos theta)");
2161
2162      bc = FindProperty("_Gimmick_DS2_11_Distance_Culling_Enable");
2163      enabled = (bc.floatValue != 0.0);
2164      EditorGUI.BeginChangeCheck();
2165      enabled = Toggle("Distance culling enable", enabled);
2166      EditorGUI.EndChangeCheck();
2167      bc.floatValue = enabled ? 1.0f : 0.0f;
2168      
2169      if (enabled) {
2170        EditorGUI.indentLevel += 1;
2171
2172        bc = FindProperty("_Gimmick_DS2_11_Activation_Y");
2173        FloatProperty(bc, "Activation Y");
2174
2175        EditorGUI.indentLevel -= 1;
2176      }
2177
2178      bc = FindProperty("_Gimmick_DS2_11_Normal_Epsilon");
2179      FloatProperty(bc, "Normal epsilon");
2180
2181      EditorGUI.indentLevel -= 1;
2182    }
2183
2184    EditorGUI.indentLevel -= 1;
2185  }
2186
2187  void DoGimmickHalo00() {
2188    MaterialProperty bc;
2189    bc = FindProperty("_Gimmick_Halo00_Enable_Static");
2190    bool enabled = (bc.floatValue != 0.0);
2191    EditorGUI.BeginChangeCheck();
2192    enabled = Toggle("Halo 00", enabled);
2193    EditorGUI.EndChangeCheck();
2194    bc.floatValue = enabled ? 1.0f : 0.0f;
2195    SetKeyword("_GIMMICK_HALO_00", enabled);
2196
2197    if (!enabled) {
2198      return;
2199    }
2200
2201    EditorGUI.indentLevel += 1;
2202
2203    EditorGUI.indentLevel -= 1;
2204  }
2205
2206  void DoGimmickPixellate() {
2207    MaterialProperty bc;
2208    bc = FindProperty("_Gimmick_Pixellate_Enable_Static");
2209    bool enabled = (bc.floatValue != 0.0);
2210    EditorGUI.BeginChangeCheck();
2211    enabled = Toggle("Pixellate", enabled);
2212    EditorGUI.EndChangeCheck();
2213    bc.floatValue = enabled ? 1.0f : 0.0f;
2214    SetKeyword("_PIXELLATE", enabled);
2215
2216    if (!enabled) {
2217      return;
2218    }
2219
2220    EditorGUI.indentLevel += 1;
2221
2222    bc = FindProperty("_Gimmick_Pixellate_Resolution_U");
2223    FloatProperty(bc, "Resolution (U)");
2224    bc = FindProperty("_Gimmick_Pixellate_Resolution_V");
2225    FloatProperty(bc, "Resolution (V)");
2226    bc = FindProperty("_Gimmick_Pixellate_Effect_Mask");
2227    TexturePropertySingleLine(
2228        MakeLabel(bc, "Effect mask"),
2229        bc);
2230
2231    EditorGUI.indentLevel -= 1;
2232  }
2233
2234  void DoGimmickTrochoid() {
2235    MaterialProperty bc;
2236    bc = FindProperty("_Trochoid_Enable_Static");
2237    bool enabled = (bc.floatValue != 0.0);
2238    EditorGUI.BeginChangeCheck();
2239    enabled = Toggle("Trochoid", enabled);
2240    EditorGUI.EndChangeCheck();
2241    bc.floatValue = enabled ? 1.0f : 0.0f;
2242    SetKeyword("_TROCHOID", enabled);
2243
2244    if (!enabled) {
2245      return;
2246    }
2247
2248    EditorGUI.indentLevel += 1;
2249
2250    bc = FindProperty("_Trochoid_R");
2251    FloatProperty(bc, "R");
2252    bc = FindProperty("_Trochoid_r");
2253    FloatProperty(bc, "r");
2254    bc = FindProperty("_Trochoid_d");
2255    FloatProperty(bc, "d");
2256    bc = FindProperty("_Trochoid_Speed");
2257    FloatProperty(bc, "Speed");
2258    bc = FindProperty("_Trochoid_Radius_Power");
2259    FloatProperty(bc, "Radius power");
2260    bc = FindProperty("_Trochoid_Radius_Scale");
2261    FloatProperty(bc, "Radius scale");
2262    bc = FindProperty("_Trochoid_Height_Scale");
2263    FloatProperty(bc, "Height scale");
2264
2265    bc = FindProperty("_Trochoid_Enable_Fragment_Normals");
2266    enabled = (bc.floatValue != 0.0);
2267    EditorGUI.BeginChangeCheck();
2268    enabled = Toggle("Enable fragment normals", enabled);
2269    EditorGUI.EndChangeCheck();
2270    bc.floatValue = enabled ? 1.0f : 0.0f;
2271
2272    bc = FindProperty("_Trochoid_Distance_Culling_Enable");
2273    enabled = (bc.floatValue != 0.0);
2274    EditorGUI.BeginChangeCheck();
2275    enabled = Toggle("Distance culling enable", enabled);
2276    EditorGUI.EndChangeCheck();
2277    bc.floatValue = enabled ? 1.0f : 0.0f;
2278
2279    if (enabled) {
2280      EditorGUI.indentLevel += 1;
2281
2282      bc = FindProperty("_Trochoid_Activation_Center");
2283      VectorProperty(bc, "Activation center");
2284      bc = FindProperty("_Trochoid_Activation_Radius");
2285      FloatProperty(bc, "Activation radius");
2286
2287      EditorGUI.indentLevel -= 1;
2288    }
2289
2290    EditorGUI.indentLevel -= 1;
2291  }
2292
2293  void DoGimmickFaceMeWorldY() {
2294    MaterialProperty bc;
2295    bc = FindProperty("_FaceMeWorldY_Enable_Static");
2296    bool enabled = (bc.floatValue != 0.0);
2297    EditorGUI.BeginChangeCheck();
2298    enabled = Toggle("FaceMeWorldY", enabled);
2299    EditorGUI.EndChangeCheck();
2300    bc.floatValue = enabled ? 1.0f : 0.0f;
2301    SetKeyword("_FACE_ME_WORLD_Y", enabled);
2302
2303    if (!enabled) {
2304      return;
2305    }
2306
2307    EditorGUI.indentLevel += 1;
2308
2309    bc = FindProperty("_FaceMeWorldY_Enable_Dynamic");
2310    enabled = (bc.floatValue != 0.0);
2311    EditorGUI.BeginChangeCheck();
2312    enabled = Toggle("Enable (runtime switch)", enabled);
2313    EditorGUI.EndChangeCheck();
2314    bc.floatValue = enabled ? 1.0f : 0.0f;
2315
2316    bc = FindProperty("_FaceMeWorldY_Enable_X");
2317    FloatProperty(bc, "X");
2318    bc = FindProperty("_FaceMeWorldY_Enable_Y");
2319    FloatProperty(bc, "Y");
2320    bc = FindProperty("_FaceMeWorldY_Enable_Z");
2321    FloatProperty(bc, "Z");
2322
2323    EditorGUI.indentLevel -= 1;
2324  }
2325
2326  void DoGimmickRorschach() {
2327    MaterialProperty bc;
2328    bc = FindProperty("_Rorschach_Enable_Static");
2329    bool enabled = (bc.floatValue != 0.0);
2330    EditorGUI.BeginChangeCheck();
2331    enabled = Toggle("Rorschach", enabled);
2332    EditorGUI.EndChangeCheck();
2333    bc.floatValue = enabled ? 1.0f : 0.0f;
2334    SetKeyword("_RORSCHACH", enabled);
2335
2336    if (!enabled) {
2337      return;
2338    }
2339
2340    EditorGUI.indentLevel += 1;
2341
2342    bc = FindProperty("_Rorschach_Enable_Dynamic");
2343    enabled = (bc.floatValue != 0.0);
2344    EditorGUI.BeginChangeCheck();
2345    enabled = Toggle("Enable (runtime switch)", enabled);
2346    EditorGUI.EndChangeCheck();
2347    bc.floatValue = enabled ? 1.0f : 0.0f;
2348
2349    bc = FindProperty("_Rorschach_Color");
2350    ColorProperty(bc, "Color");
2351    bc = FindProperty("_Rorschach_Count_X");
2352    FloatProperty(bc, "Count (x)");
2353    bc = FindProperty("_Rorschach_Count_Y");
2354    FloatProperty(bc, "Count (y)");
2355    bc = FindProperty("_Rorschach_Center_Randomization");
2356    FloatProperty(bc, "Center randomization");
2357    bc = FindProperty("_Rorschach_Radius");
2358    FloatProperty(bc, "Radius");
2359    bc = FindProperty("_Rorschach_Emission_Strength");
2360    FloatProperty(bc, "Emission strength");
2361    bc = FindProperty("_Rorschach_Speed");
2362    FloatProperty(bc, "Speed");
2363    bc = FindProperty("_Rorschach_Quantization");
2364    FloatProperty(bc, "Quantization");
2365    bc = FindProperty("_Rorschach_Alpha_Cutoff");
2366    FloatProperty(bc, "Alpha cutoff");
2367    bc = FindProperty("_Rorschach_Mask");
2368    TexturePropertySingleLine(
2369        MakeLabel(bc, "Mask"),
2370        bc);
2371    SetKeyword("_RORSCHACH_MASK", bc.textureValue);
2372    if (bc.textureValue) {
2373      EditorGUI.indentLevel += 1;
2374      bc = FindProperty("_Rorschach_Mask_Invert");
2375      enabled = bc.floatValue > 1E-6;
2376      EditorGUI.BeginChangeCheck();
2377      enabled = Toggle("Invert", enabled);
2378      EditorGUI.EndChangeCheck();
2379      bc.floatValue = enabled ? 1.0f : 0.0f;
2380      EditorGUI.indentLevel -= 1;
2381    }
2382
2383    EditorGUI.indentLevel -= 1;
2384  }
2385
2386  void DoGimmickMirrorUVFlip() {
2387    MaterialProperty bc;
2388    bc = FindProperty("_Mirror_UV_Flip_Enable_Static");
2389    bool enabled = (bc.floatValue != 0.0);
2390    EditorGUI.BeginChangeCheck();
2391    enabled = Toggle("Flip UVs in mirror", enabled);
2392    EditorGUI.EndChangeCheck();
2393    bc.floatValue = enabled ? 1.0f : 0.0f;
2394    SetKeyword("_MIRROR_UV_FLIP", enabled);
2395
2396    if (!enabled) {
2397      return;
2398    }
2399
2400    EditorGUI.indentLevel += 1;
2401
2402    bc = FindProperty("_Mirror_UV_Flip_Enable_Dynamic");
2403    enabled = (bc.floatValue != 0.0);
2404    EditorGUI.BeginChangeCheck();
2405    enabled = Toggle("Enable (runtime switch)", enabled);
2406    EditorGUI.EndChangeCheck();
2407    bc.floatValue = enabled ? 1.0f : 0.0f;
2408
2409    EditorGUI.indentLevel -= 1;
2410  }
2411
2412	void DoGimmickLetterGrid() {
2413    MaterialProperty bc;
2414    bc = FindProperty("_Gimmick_Letter_Grid_Enable_Static");
2415    bool enabled = (bc.floatValue != 0.0);
2416    EditorGUI.BeginChangeCheck();
2417    enabled = Toggle("Letter grid", enabled);
2418    EditorGUI.EndChangeCheck();
2419    bc.floatValue = enabled ? 1.0f : 0.0f;
2420    SetKeyword("_GIMMICK_LETTER_GRID", enabled);
2421
2422    if (!enabled) {
2423      return;
2424    }
2425
2426    EditorGUI.indentLevel += 1;
2427
2428    bc = FindProperty("_Gimmick_Letter_Grid_Texture");
2429    TexturePropertySingleLine(
2430        MakeLabel(bc, "Texture"),
2431        bc);
2432
2433    bc = FindProperty("_Gimmick_Letter_Grid_Tex_Res_X");
2434    FloatProperty(bc, "Number of glyphs in texture (X)");
2435    bc = FindProperty("_Gimmick_Letter_Grid_Tex_Res_Y");
2436    FloatProperty(bc, "Number of glyphs in texture (Y)");
2437
2438    bc = FindProperty("_Gimmick_Letter_Grid_Res_X");
2439    FloatProperty(bc, "Number of glyphs in grid (X)");
2440    bc = FindProperty("_Gimmick_Letter_Grid_Res_Y");
2441    FloatProperty(bc, "Number of glyphs in grid (Y)");
2442
2443    bc = FindProperty("_Gimmick_Letter_Grid_UV_Scale_Offset");
2444    VectorProperty(bc, "UV scale & offset");
2445    bc = FindProperty("_Gimmick_Letter_Grid_Padding");
2446    FloatProperty(bc, "Padding");
2447
2448    bc = FindProperty("_Gimmick_Letter_Grid_Color");
2449    bc = FindProperty("_Gimmick_Letter_Grid_Metallic");
2450    RangeProperty(bc, "Metallic");
2451    bc = FindProperty("_Gimmick_Letter_Grid_Roughness");
2452    RangeProperty(bc, "Roughness");
2453    bc = FindProperty("_Gimmick_Letter_Grid_Emission");
2454    FloatProperty(bc, "Emission");
2455
2456    bc = FindProperty("_Gimmick_Letter_Grid_UV_Select");
2457    RangeProperty(
2458        bc,
2459        "UV channel");
2460
2461    bc = FindProperty("_Gimmick_Letter_Grid_Color_Wave");
2462    enabled = (bc.floatValue != 0.0);
2463    EditorGUI.BeginChangeCheck();
2464    enabled = Toggle("Color waves", enabled);
2465    EditorGUI.EndChangeCheck();
2466    bc.floatValue = enabled ? 1.0f : 0.0f;
2467    SetKeyword("_GIMMICK_LETTER_GRID_COLOR_WAVE", enabled);
2468
2469    if (enabled) {
2470      EditorGUI.indentLevel += 1;
2471      bc = FindProperty("_Gimmick_Letter_Grid_Color_Wave_Speed");
2472      FloatProperty(bc, "Speed");
2473      bc = FindProperty("_Gimmick_Letter_Grid_Color_Wave_Frequency");
2474      FloatProperty(bc, "Frequency");
2475      EditorGUI.indentLevel -= 1;
2476    }
2477
2478    bc = FindProperty("_Gimmick_Letter_Grid_Rim_Lighting");
2479    enabled = (bc.floatValue != 0.0);
2480    EditorGUI.BeginChangeCheck();
2481    enabled = Toggle("Rim lighting", enabled);
2482    EditorGUI.EndChangeCheck();
2483    bc.floatValue = enabled ? 1.0f : 0.0f;
2484    SetKeyword("_GIMMICK_LETTER_GRID_RIM_LIGHTING", enabled);
2485
2486    if (enabled) {
2487      EditorGUI.indentLevel += 1;
2488      bc = FindProperty("_Gimmick_Letter_Grid_Rim_Lighting_Power");
2489      FloatProperty(bc, "Power");
2490      bc = FindProperty("_Gimmick_Letter_Grid_Rim_Lighting_Center");
2491      FloatProperty(bc, "Center");
2492      bc = FindProperty("_Gimmick_Letter_Grid_Rim_Lighting_Quantization");
2493      FloatProperty(bc, "Quantization");
2494      bc = FindProperty("_Gimmick_Letter_Grid_Rim_Lighting_Mask");
2495      TexturePropertySingleLine(MakeLabel(bc, "Mask"), bc);
2496      if (bc.textureValue) {
2497        EditorGUI.indentLevel += 1;
2498        bc = FindProperty("_Gimmick_Letter_Grid_Rim_Lighting_Mask_UV_Select");
2499        FloatProperty(bc, "Mask UV Select");
2500        bc = FindProperty("_Gimmick_Letter_Grid_Rim_Lighting_Mask_Invert");
2501        FloatProperty(bc, "Mask invert");
2502        EditorGUI.indentLevel -= 1;
2503      }
2504      EditorGUI.indentLevel -= 1;
2505    }
2506
2507    EditorGUI.indentLevel -= 1;
2508	}
2509
2510	void DoGimmickLetterGrid2() {
2511    MaterialProperty bc;
2512    bc = FindProperty("_Gimmick_Letter_Grid_2_Enable_Static");
2513    bool enabled = (bc.floatValue != 0.0);
2514    EditorGUI.BeginChangeCheck();
2515    enabled = Toggle("Letter grid 2", enabled);
2516    EditorGUI.EndChangeCheck();
2517    bc.floatValue = enabled ? 1.0f : 0.0f;
2518    SetKeyword("_GIMMICK_LETTER_GRID_2", enabled);
2519
2520    if (!enabled) {
2521      return;
2522    }
2523
2524    EditorGUI.indentLevel += 1;
2525
2526    bc = FindProperty("_Gimmick_Letter_Grid_2_Texture");
2527    TexturePropertySingleLine(
2528        MakeLabel(bc, "Texture"),
2529        bc);
2530
2531    bc = FindProperty("_Gimmick_Letter_Grid_2_Tex_Res_X");
2532    FloatProperty(bc, "Number of glyphs in texture (X)");
2533    bc = FindProperty("_Gimmick_Letter_Grid_2_Tex_Res_Y");
2534    FloatProperty(bc, "Number of glyphs in texture (Y)");
2535
2536    MaterialProperty rows = FindProperty("_Gimmick_Letter_Grid_2_Res_X");
2537    RangeProperty(rows, "Number of glyphs in grid (X)");
2538    MaterialProperty cols = FindProperty("_Gimmick_Letter_Grid_2_Res_Y");
2539    RangeProperty(cols, "Number of glyphs in grid (Y)");
2540
2541    for (int i = 0; i < rows.floatValue; i++) {
2542      EditorGUI.indentLevel += 1;
2543      bc = FindProperty($"_Gimmick_Letter_Grid_2_Data_Row_{i}");
2544      VectorProperty(bc, $"Letter grid data row {i}");
2545      EditorGUI.indentLevel -= 1;
2546    }
2547
2548    bc = FindProperty("_Gimmick_Letter_Grid_2_UV_Scale_Offset");
2549    VectorProperty(bc, "UV scale & offset");
2550    bc = FindProperty("_Gimmick_Letter_Grid_2_Padding");
2551    FloatProperty(bc, "Padding");
2552
2553    bc = FindProperty("_Gimmick_Letter_Grid_2_Color");
2554    ColorProperty(bc, "Color");
2555    bc = FindProperty("_Gimmick_Letter_Grid_2_Metallic");
2556    RangeProperty(bc, "Metallic");
2557    bc = FindProperty("_Gimmick_Letter_Grid_2_Roughness");
2558    RangeProperty(bc, "Roughness");
2559    bc = FindProperty("_Gimmick_Letter_Grid_2_Emission");
2560    FloatProperty(bc, "Emission");
2561
2562    bc = FindProperty("_Gimmick_Letter_Grid_2_Mask");
2563    TexturePropertySingleLine(MakeLabel(bc, "Mask"), bc);
2564
2565    bc = FindProperty("_Gimmick_Letter_Grid_2_Global_Offset");
2566    FloatProperty(bc, "Global offset");
2567
2568    bc = FindProperty("_Gimmick_Letter_Grid_2_Screen_Px_Range");
2569    FloatProperty(bc, "Screen px range (from msdfgen)");
2570    bc = FindProperty("_Gimmick_Letter_Grid_2_Min_Screen_Px_Range");
2571    FloatProperty(bc, "Minimum screen px range");
2572    bc = FindProperty("_Gimmick_Letter_Grid_2_Blurriness");
2573    FloatProperty(bc, "Blurriness");
2574    bc = FindProperty("_Gimmick_Letter_Grid_2_Alpha_Threshold");
2575    RangeProperty(bc, "Alpha threshold");
2576
2577    EditorGUI.indentLevel -= 1;
2578	}
2579
2580	void DoGimmickAudiolinkChroma00() {
2581    MaterialProperty bc;
2582    bc = FindProperty("_Gimmick_AL_Chroma_00_Enable_Static");
2583    bool enabled = (bc.floatValue != 0.0);
2584    EditorGUI.BeginChangeCheck();
2585    enabled = Toggle("Audiolink chroma 00", enabled);
2586    EditorGUI.EndChangeCheck();
2587    bc.floatValue = enabled ? 1.0f : 0.0f;
2588    SetKeyword("_GIMMICK_AL_CHROMA_00", enabled);
2589
2590    if (!enabled) {
2591      return;
2592    }
2593
2594    EditorGUI.indentLevel += 1;
2595
2596    bc = FindProperty("_Gimmick_AL_Chroma_00_Forward_Pass");
2597    enabled = bc.floatValue > 1E-6;
2598    EditorGUI.BeginChangeCheck();
2599    enabled = Toggle("Forward pass", enabled);
2600    EditorGUI.EndChangeCheck();
2601    bc.floatValue = enabled ? 1.0f : 0.0f;
2602
2603    if (enabled) {
2604      bc = FindProperty("_Gimmick_AL_Chroma_00_Forward_Blend");
2605      RangeProperty(bc, "Blend factor");
2606    }
2607
2608    bc = FindProperty("_Gimmick_AL_Chroma_00_Outline_Pass");
2609    enabled = bc.floatValue > 1E-6;
2610    EditorGUI.BeginChangeCheck();
2611    enabled = Toggle("Outline pass", enabled);
2612    EditorGUI.EndChangeCheck();
2613    bc.floatValue = enabled ? 1.0f : 0.0f;
2614
2615    if (enabled) {
2616      EditorGUI.indentLevel += 1;
2617
2618      bc = FindProperty("_Gimmick_AL_Chroma_00_Outline_Blend");
2619      RangeProperty(bc, "Blend factor");
2620
2621      bc = FindProperty("_Gimmick_AL_Chroma_00_Outline_Emission");
2622      RangeProperty(bc, "Emission strength");
2623      EditorGUI.indentLevel -= 1;
2624    }
2625
2626    bc = FindProperty("_Gimmick_AL_Chroma_00_Hue_Shift_Enable_Static");
2627    enabled = bc.floatValue > 1E-6;
2628    EditorGUI.BeginChangeCheck();
2629    enabled = Toggle("Hue shift", enabled);
2630    EditorGUI.EndChangeCheck();
2631    bc.floatValue = enabled ? 1.0f : 0.0f;
2632    SetKeyword("_GIMMICK_AL_CHROMA_00_HUE_SHIFT", enabled);
2633
2634    if (enabled) {
2635      EditorGUI.indentLevel += 1;
2636
2637      bc = FindProperty("_Gimmick_AL_Chroma_00_Hue_Shift_Theta");
2638      RangeProperty(bc, "Theta");
2639
2640      EditorGUI.indentLevel -= 1;
2641    }
2642
2643    EditorGUI.indentLevel -= 1;
2644	}
2645
2646  enum GimmickFog00BoundaryType {
2647    Cylinder = 0,
2648    Plane = 1,
2649    Sphere = 2,
2650  };
2651
2652  void DoGimmickFog0() {
2653    MaterialProperty bc;
2654
2655    bc = FindProperty("_Gimmick_Fog_00_Enable_Static");
2656    bool enabled = (bc.floatValue != 0.0);
2657    EditorGUI.BeginChangeCheck();
2658    enabled = Toggle("Fog 00", enabled);
2659    EditorGUI.EndChangeCheck();
2660    bc.floatValue = enabled ? 1.0f : 0.0f;
2661    SetKeyword("_GIMMICK_FOG_00", enabled);
2662
2663    if (!enabled) {
2664      return;
2665    }
2666
2667    EditorGUI.indentLevel += 1;
2668
2669    bc = FindProperty("_Gimmick_Fog_00_Density");
2670    RangeProperty(bc, "Density");
2671
2672    bc = FindProperty("_Gimmick_Fog_00_Boundary_Type");
2673    EditorGUI.BeginChangeCheck();
2674    GimmickFog00BoundaryType boundary_type = (GimmickFog00BoundaryType) Math.Round(bc.floatValue);
2675    boundary_type = (GimmickFog00BoundaryType) EnumPopup(
2676        MakeLabel("Boundary type"), boundary_type);
2677    EditorGUI.EndChangeCheck();
2678    bc.floatValue = (int) boundary_type;
2679
2680    if (boundary_type == GimmickFog00BoundaryType.Cylinder || boundary_type == GimmickFog00BoundaryType.Sphere) {
2681      bc = FindProperty("_Gimmick_Fog_00_Radius");
2682      FloatProperty(bc, "Radius");
2683    } else if (boundary_type == GimmickFog00BoundaryType.Plane) {
2684      bc = FindProperty("_Gimmick_Fog_00_Plane_Normal");
2685      VectorProperty(bc, "Plane normal");
2686      bc = FindProperty("_Gimmick_Fog_00_Plane_Center");
2687      VectorProperty(bc, "Plane center");
2688    }
2689    SetKeyword("_GIMMICK_FOG_00_BOUNDARY_CYLINDER", boundary_type == GimmickFog00BoundaryType.Cylinder);
2690    SetKeyword("_GIMMICK_FOG_00_BOUNDARY_SPHERE", boundary_type == GimmickFog00BoundaryType.Sphere);
2691    SetKeyword("_GIMMICK_FOG_00_BOUNDARY_PLANE", boundary_type == GimmickFog00BoundaryType.Plane);
2692
2693    bc = FindProperty("_Gimmick_Fog_00_Step_Size_Factor");
2694    FloatProperty(bc, "Step size multiplier");
2695    bc = FindProperty("_Gimmick_Fog_00_Initial_Offset");
2696    FloatProperty(bc, "Initial offset");
2697    bc = FindProperty("_Gimmick_Fog_00_Max_Ray");
2698    FloatProperty(bc, "Max ray length (m)");
2699    bc = FindProperty("_Gimmick_Fog_00_Noise_Scale");
2700    VectorProperty(bc, "Noise scale");
2701    bc = FindProperty("_Gimmick_Fog_00_Motion_Vector");
2702    VectorProperty(bc, "Motion vector");
2703    bc = FindProperty("_Gimmick_Fog_00_Noise_Exponent");
2704    FloatProperty(bc, "Noise exponent");
2705    bc = FindProperty("_Gimmick_Fog_00_Normal_Cutoff");
2706    RangeProperty(bc, "Normal cutoff");
2707    bc = FindProperty("_Gimmick_Fog_00_Alpha_Cutoff");
2708    RangeProperty(bc, "Alpha cutoff");
2709    bc = FindProperty("_Gimmick_Fog_00_Ray_Origin_Randomization");
2710    RangeProperty(bc, "Ray origin randomization");
2711    bc = FindProperty("_Gimmick_Fog_00_Lod_Half_Life");
2712    FloatProperty(bc, "LOD half life");
2713    bc = FindProperty("_Gimmick_Fog_00_Max_Brightness");
2714    RangeProperty(bc, "Max brightness");
2715    bc = FindProperty("_Gimmick_Fog_00_Noise");
2716    TexturePropertySingleLine(
2717        MakeLabel(bc, "3D Noise"),
2718        bc);
2719    bc = FindProperty("_Gimmick_Fog_00_Noise_2D");
2720    TexturePropertySingleLine(
2721        MakeLabel(bc, "2D Noise (optional)"),
2722        bc);
2723    SetKeyword("_GIMMICK_FOG_00_NOISE_2D", bc.textureValue);
2724
2725    bc = FindProperty("_Gimmick_Fog_00_LTCGI_Brightness");
2726    FloatProperty(bc, "LTCGI brightness");
2727
2728    bc = FindProperty("_Gimmick_Fog_00_Emitter_Texture");
2729    TexturePropertySingleLine(
2730        MakeLabel(bc, "Emitter texture"),
2731        bc);
2732    SetKeyword("_GIMMICK_FOG_00_EMITTER_TEXTURE", bc.textureValue);
2733    if (bc.textureValue) {
2734      EditorGUI.indentLevel += 1;
2735
2736      // TODO this is a misnomer, it's actually enabling normal-based
2737      // lighting.
2738      bc = FindProperty("_Gimmick_Fog_00_Emitter_Variable_Density");
2739      enabled = (bc.floatValue != 0.0);
2740      EditorGUI.BeginChangeCheck();
2741      enabled = Toggle("Enable variable density", enabled);
2742      EditorGUI.EndChangeCheck();
2743      bc.floatValue = enabled ? 1.0f : 0.0f;
2744      SetKeyword("_GIMMICK_FOG_00_EMITTER_VARIABLE_DENSITY", enabled);
2745
2746      bc = FindProperty("_Gimmick_Fog_00_Emitter0_Location");
2747      VectorProperty(bc, "Location (world)");
2748      bc = FindProperty("_Gimmick_Fog_00_Emitter0_Normal");
2749      VectorProperty(bc, "Normal (world)");
2750      bc = FindProperty("_Gimmick_Fog_00_Emitter0_Tangent");
2751      VectorProperty(bc, "Tangent (world)");
2752      bc = FindProperty("_Gimmick_Fog_00_Emitter0_Scale_T");
2753      FloatProperty(bc, "Scale (tangent)");
2754      bc = FindProperty("_Gimmick_Fog_00_Emitter0_Scale_NxT");
2755      FloatProperty(bc, "Scale (normal x tangent)");
2756
2757      bc = FindProperty("_Gimmick_Fog_00_Emitter_Brightness_Diffuse");
2758      FloatProperty(bc, "Brightness (diffuse)");
2759      bc = FindProperty("_Gimmick_Fog_00_Emitter_Brightness_Direct");
2760      FloatProperty(bc, "Brightness (direct)");
2761      bc = FindProperty("_Gimmick_Fog_00_Emitter_Lod_Half_Life");
2762      FloatProperty(bc, "LOD half life");
2763
2764      for (int i = 0; i < 2; i++) {
2765        bc = FindProperty($"_Gimmick_Fog_00_Emitter{i+1}_Enable_Static");
2766        enabled = (bc.floatValue != 0.0);
2767        EditorGUI.BeginChangeCheck();
2768        enabled = Toggle($"Enable emitter {i+1}", enabled);
2769        EditorGUI.EndChangeCheck();
2770        bc.floatValue = enabled ? 1.0f : 0.0f;
2771        SetKeyword($"_GIMMICK_FOG_00_EMITTER_{i+1}", enabled);
2772
2773        if (enabled) {
2774          EditorGUI.indentLevel += 1;
2775
2776          bc = FindProperty($"_Gimmick_Fog_00_Emitter{i+1}_Location");
2777          VectorProperty(bc, "Location (world)");
2778          bc = FindProperty($"_Gimmick_Fog_00_Emitter{i+1}_Normal");
2779          VectorProperty(bc, "Normal (world)");
2780          bc = FindProperty($"_Gimmick_Fog_00_Emitter{i+1}_Scale_X");
2781          FloatProperty(bc, "Scale (x)");
2782          bc = FindProperty($"_Gimmick_Fog_00_Emitter{i+1}_Scale_Y");
2783          FloatProperty(bc, "Scale (y)");
2784
2785          EditorGUI.indentLevel -= 1;
2786        }
2787      }
2788
2789      EditorGUI.indentLevel -= 1;
2790    }
2791
2792    bc = FindProperty("_Gimmick_Fog_00_Ray_March_0_Enable_Static");
2793    enabled = (bc.floatValue != 0.0);
2794    EditorGUI.BeginChangeCheck();
2795    enabled = Toggle("Ray march effect 0", enabled);
2796    EditorGUI.EndChangeCheck();
2797    bc.floatValue = enabled ? 1.0f : 0.0f;
2798    SetKeyword("_GIMMICK_FOG_00_RAY_MARCH_0", enabled);
2799
2800    if (enabled) {
2801      EditorGUI.indentLevel += 1;
2802
2803      bc = FindProperty("_Gimmick_Fog_00_Ray_March_0_Seed");
2804      FloatProperty(bc, "Seed");
2805
2806      EditorGUI.indentLevel -= 1;
2807    }
2808
2809    // Composite fog on top of some raymarched effect. Does not rely on depth
2810    // buffer; uses whatever the raymarch generated.
2811    bc = FindProperty("_Gimmick_Fog_00_Overlay_Mode");
2812    enabled = (bc.floatValue != 0.0);
2813    EditorGUI.BeginChangeCheck();
2814    enabled = Toggle("Overlay mode", enabled);
2815    EditorGUI.EndChangeCheck();
2816    bc.floatValue = enabled ? 1.0f : 0.0f;
2817
2818    EditorGUI.indentLevel -= 1;
2819  }
2820
2821  void DoGimmickFog1() {
2822    MaterialProperty bc;
2823
2824    bc = FindProperty("_Gimmick_Fog_01_Enable_Static");
2825    bool enabled = (bc.floatValue != 0.0);
2826    EditorGUI.BeginChangeCheck();
2827    enabled = Toggle("Fog 01", enabled);
2828    EditorGUI.EndChangeCheck();
2829    bc.floatValue = enabled ? 1.0f : 0.0f;
2830    SetKeyword("_GIMMICK_FOG_01", enabled);
2831
2832    if (!enabled) {
2833      return;
2834    }
2835    EditorGUI.indentLevel += 1;
2836
2837    bc = FindProperty("_Gimmick_Fog_01_Density");
2838    RangeProperty(bc, "Density");
2839    bc = FindProperty("_Gimmick_Fog_01_Sun_Direction");
2840    VectorProperty(bc, "Sun direction");
2841    bc = FindProperty("_Gimmick_Fog_01_Color");
2842    ColorProperty(bc, "Color");
2843    bc = FindProperty("_Gimmick_Fog_01_Sun_Color");
2844    ColorProperty(bc, "Sun color");
2845    bc = FindProperty("_Gimmick_Fog_01_Sun_Exponent");
2846    FloatProperty(bc, "Sun exponent");
2847
2848    bc = FindProperty("_Gimmick_Fog_01_Sun_Color_2_Enable");
2849    enabled = (bc.floatValue != 0.0);
2850    EditorGUI.BeginChangeCheck();
2851    enabled = Toggle("Sun color 2", enabled);
2852    EditorGUI.EndChangeCheck();
2853    bc.floatValue = enabled ? 1.0f : 0.0f;
2854
2855    if (enabled) {
2856      EditorGUI.indentLevel += 1;
2857
2858      bc = FindProperty("_Gimmick_Fog_01_Sun_Color_2");
2859      ColorProperty(bc, "Color");
2860      bc = FindProperty("_Gimmick_Fog_01_Sun_Exponent_2");
2861      FloatProperty(bc, "Exponent");
2862
2863      EditorGUI.indentLevel -= 1;
2864    }
2865
2866    bc = FindProperty("_Gimmick_Fog_01_Distance_Culling_Enable");
2867    enabled = (bc.floatValue != 0.0);
2868    EditorGUI.BeginChangeCheck();
2869    enabled = Toggle("Distance culling enable", enabled);
2870    EditorGUI.EndChangeCheck();
2871    bc.floatValue = enabled ? 1.0f : 0.0f;
2872
2873    if (enabled) {
2874      EditorGUI.indentLevel += 1;
2875
2876      bc = FindProperty("_Gimmick_Fog_01_Activation_Center");
2877      VectorProperty(bc, "Activation center");
2878      bc = FindProperty("_Gimmick_Fog_01_Activation_Radius");
2879      FloatProperty(bc, "Activation radius");
2880
2881      EditorGUI.indentLevel -= 1;
2882    }
2883
2884    bc = FindProperty("_Gimmick_Fog_01_Overlay_Mode");
2885    enabled = (bc.floatValue != 0.0);
2886    EditorGUI.BeginChangeCheck();
2887    enabled = Toggle("Overlay mode", enabled);
2888    EditorGUI.EndChangeCheck();
2889    bc.floatValue = enabled ? 1.0f : 0.0f;
2890
2891    EditorGUI.indentLevel -= 1;
2892  }
2893
2894  void DoGimmickZWriteAbomination() {
2895    MaterialProperty bc;
2896
2897    bc = FindProperty("_Gimmick_ZWrite_Abomination_Enable_Static");
2898    bool enabled = (bc.floatValue != 0.0);
2899    EditorGUI.BeginChangeCheck();
2900    enabled = Toggle("Zwrite abomination", enabled);
2901    EditorGUI.EndChangeCheck();
2902    bc.floatValue = enabled ? 1.0f : 0.0f;
2903    SetKeyword("_GIMMICK_ZWRITE_ABOMINATION", enabled);
2904
2905    if (!enabled) {
2906      return;
2907    }
2908
2909    EditorGUI.indentLevel += 1;
2910
2911    bc = FindProperty("_Gimmick_ZWrite_Abomination_Min_Hit_Dist");
2912    FloatProperty(bc, "Min hit dist");
2913    bc = FindProperty("_Gimmick_ZWrite_Abomination_March_Steps");
2914    FloatProperty(bc, "March steps");
2915    bc = FindProperty("_Gimmick_ZWrite_Abomination_Normal_Epsilon");
2916    FloatProperty(bc, "Normal epsilon");
2917    bc = FindProperty("_Gimmick_ZWrite_Abomination_Initial_Step_Size");
2918    FloatProperty(bc, "Initial step size");
2919    bc = FindProperty("_Gimmick_ZWrite_Abomination_Global_Scale");
2920    FloatProperty(bc, "Global scale");
2921    bc = FindProperty("_Gimmick_ZWrite_Abomination_Vertex_Expansion_Factor");
2922    FloatProperty(bc, "Vertex expansion factor");
2923    bc = FindProperty("_Gimmick_ZWrite_Abomination_Global_Offset");
2924    VectorProperty(bc, "Global offset");
2925
2926    bc = FindProperty("_Gimmick_ZWrite_Abomination_Body_Half_Height");
2927    FloatProperty(bc, "Body half height");
2928    bc = FindProperty("_Gimmick_ZWrite_Abomination_Body_Radius");
2929    FloatProperty(bc, "Body radius");
2930    bc = FindProperty("_Gimmick_ZWrite_Abomination_Denim_Radius");
2931    FloatProperty(bc, "Denim radius");
2932    bc = FindProperty("_Gimmick_ZWrite_Abomination_Denim_Half_Height");
2933    FloatProperty(bc, "Denim half height");
2934    bc = FindProperty("_Gimmick_ZWrite_Abomination_Denim_Center");
2935    VectorProperty(bc, "Denim center");
2936    bc = FindProperty("_Gimmick_ZWrite_Abomination_Denim_Strap_Theta");
2937    FloatProperty(bc, "Denim strap theta");
2938    bc = FindProperty("_Gimmick_ZWrite_Abomination_Denim_Strap_RA");
2939    FloatProperty(bc, "Denim strap RA");
2940    bc = FindProperty("_Gimmick_ZWrite_Abomination_Denim_Strap_RB");
2941    FloatProperty(bc, "Denim strap RB");
2942    bc = FindProperty("_Gimmick_ZWrite_Abomination_Denim_Strap_Z_Theta");
2943    FloatProperty(bc, "Denim strap z theta");
2944    bc = FindProperty("_Gimmick_ZWrite_Abomination_Denim_Strap_Center");
2945    VectorProperty(bc, "Denim strap center");
2946    bc = FindProperty("_Gimmick_ZWrite_Abomination_Lens_Radius");
2947    FloatProperty(bc, "Lens radius");
2948    bc = FindProperty("_Gimmick_ZWrite_Abomination_Lens_Depth");
2949    FloatProperty(bc, "Lens depth");
2950    bc = FindProperty("_Gimmick_ZWrite_Abomination_Lens_Thickness");
2951    FloatProperty(bc, "Lens thickness");
2952    bc = FindProperty("_Gimmick_ZWrite_Abomination_Lens_Strap_Height");
2953    FloatProperty(bc, "Lens strap height");
2954    bc = FindProperty("_Gimmick_ZWrite_Abomination_Pupil_Radius");
2955    FloatProperty(bc, "Pupil radius");
2956    bc = FindProperty("_Gimmick_ZWrite_Abomination_Eye_Center");
2957    VectorProperty(bc, "Eye center");
2958    bc = FindProperty("_Gimmick_ZWrite_Abomination_Arm_Radius");
2959    FloatProperty(bc, "Arm radius");
2960    bc = FindProperty("_Gimmick_ZWrite_Abomination_Arm_Half_Length");
2961    FloatProperty(bc, "Arm half length");
2962    bc = FindProperty("_Gimmick_ZWrite_Abomination_Arm_Center");
2963    VectorProperty(bc, "Arm center");
2964    bc = FindProperty("_Gimmick_ZWrite_Abomination_Leg_Radius");
2965    FloatProperty(bc, "Leg radius");
2966    bc = FindProperty("_Gimmick_ZWrite_Abomination_Leg_Half_Length");
2967    FloatProperty(bc, "Leg half length");
2968    bc = FindProperty("_Gimmick_ZWrite_Abomination_Leg_Center");
2969    VectorProperty(bc, "Leg center");
2970    bc = FindProperty("_Gimmick_ZWrite_Abomination_Mouth_Theta");
2971    FloatProperty(bc, "Mouth theta");
2972    bc = FindProperty("_Gimmick_ZWrite_Abomination_Mouth_RA");
2973    FloatProperty(bc, "Mouth RA");
2974    bc = FindProperty("_Gimmick_ZWrite_Abomination_Mouth_RB");
2975    FloatProperty(bc, "Mouth RB");
2976    bc = FindProperty("_Gimmick_ZWrite_Abomination_Mouth_Center");
2977    VectorProperty(bc, "Mouth center");
2978
2979    bc = FindProperty("_Gimmick_ZWrite_Abomination_Lens_Strap_Color");
2980    ColorProperty(bc, "Lens strap color");
2981    bc = FindProperty("_Gimmick_ZWrite_Abomination_Lens_Strap_Metallic");
2982    FloatProperty(bc, "Lens strap metallic");
2983    bc = FindProperty("_Gimmick_ZWrite_Abomination_Lens_Strap_Roughness");
2984    FloatProperty(bc, "Lens strap roughness");
2985    bc = FindProperty("_Gimmick_ZWrite_Abomination_Skin_Color");
2986    ColorProperty(bc, "Skin color");
2987    bc = FindProperty("_Gimmick_ZWrite_Abomination_Skin_Metallic");
2988    FloatProperty(bc, "Skin metallic");
2989    bc = FindProperty("_Gimmick_ZWrite_Abomination_Skin_Roughness");
2990    FloatProperty(bc, "Skin roughness");
2991    bc = FindProperty("_Gimmick_ZWrite_Abomination_Lens_Color");
2992    ColorProperty(bc, "Lens color");
2993    bc = FindProperty("_Gimmick_ZWrite_Abomination_Lens_Metallic");
2994    FloatProperty(bc, "Lens metallic");
2995    bc = FindProperty("_Gimmick_ZWrite_Abomination_Lens_Roughness");
2996    FloatProperty(bc, "Lens roughness");
2997    bc = FindProperty("_Gimmick_ZWrite_Abomination_Denim_Color");
2998    ColorProperty(bc, "Denim color");
2999    bc = FindProperty("_Gimmick_ZWrite_Abomination_Denim_Metallic");
3000    FloatProperty(bc, "Denim metallic");
3001    bc = FindProperty("_Gimmick_ZWrite_Abomination_Denim_Roughness");
3002    FloatProperty(bc, "Denim roughness");
3003
3004    EditorGUI.indentLevel -= 1;
3005  }
3006
3007
3008  void DoGimmickAurora() {
3009    MaterialProperty bc;
3010
3011    bc = FindProperty("_Gimmick_Aurora_Enable_Static");
3012    bool enabled = (bc.floatValue != 0.0);
3013    EditorGUI.BeginChangeCheck();
3014    enabled = Toggle("Aurora", enabled);
3015    EditorGUI.EndChangeCheck();
3016    bc.floatValue = enabled ? 1.0f : 0.0f;
3017    SetKeyword("_GIMMICK_AURORA", enabled);
3018
3019    if (!enabled) {
3020      return;
3021    }
3022    EditorGUI.indentLevel += 1;
3023    EditorGUI.indentLevel -= 1;
3024  }
3025
3026  void DoGimmickGerstnerWater() {
3027    MaterialProperty bc;
3028
3029    bc = FindProperty("_Gimmick_Gerstner_Water_Enable_Static");
3030    bool enabled = (bc.floatValue != 0.0);
3031    EditorGUI.BeginChangeCheck();
3032    enabled = Toggle("Water (gerstner)", enabled);
3033    EditorGUI.EndChangeCheck();
3034    bc.floatValue = enabled ? 1.0f : 0.0f;
3035    SetKeyword("_GIMMICK_GERSTNER_WATER", enabled);
3036
3037    if (!enabled) {
3038      return;
3039    }
3040    EditorGUI.indentLevel += 1;
3041
3042    bc = FindProperty("_Gimmick_Gerstner_Water_M");
3043    FloatProperty(bc, "M");
3044    int num_octaves = (int) Math.Floor((bc.floatValue-1)/4);
3045    SetKeyword("_GIMMICK_GERSTNER_WATER_OCTAVE_1", num_octaves >= 1);
3046
3047    bc = FindProperty("_Gimmick_Gerstner_Water_Color_Ramp");
3048    TexturePropertySingleLine(
3049        MakeLabel(bc, "Color ramp"),
3050        bc);
3051    SetKeyword("_GIMMICK_GERSTNER_WATER_COLOR_RAMP", bc.textureValue);
3052
3053    if (bc.textureValue) {
3054      EditorGUI.indentLevel += 1;
3055
3056      bc = FindProperty("_Gimmick_Gerstner_Water_Color_Ramp_Offset");
3057      FloatProperty(bc, "Offset");
3058      bc = FindProperty("_Gimmick_Gerstner_Water_Color_Ramp_Scale");
3059      FloatProperty(bc, "Scale");
3060      bc = FindProperty("_Gimmick_Gerstner_Water_Color_Ramp_Mask");
3061      VectorProperty(bc, "Mask (octave 0)");
3062      bc = FindProperty("_Gimmick_Gerstner_Water_Color_Ramp_Mask1");
3063      VectorProperty(bc, "Mask (octave 1)");
3064
3065      EditorGUI.indentLevel -= 1;
3066    }
3067
3068    {
3069      LabelField("Octave 0", EditorStyles.boldLabel);
3070      EditorGUI.indentLevel += 1;
3071      bc = FindProperty("_Gimmick_Gerstner_Water_a");
3072      VectorProperty(bc, "a");
3073      bc = FindProperty("_Gimmick_Gerstner_Water_p");
3074      VectorProperty(bc, "p");
3075      bc = FindProperty("_Gimmick_Gerstner_Water_k_x");
3076      VectorProperty(bc, "k_x");
3077      bc = FindProperty("_Gimmick_Gerstner_Water_k_y");
3078      VectorProperty(bc, "k_y");
3079      bc = FindProperty("_Gimmick_Gerstner_Water_t_f");
3080      VectorProperty(bc, "Time speed");
3081      EditorGUI.indentLevel -= 1;
3082    }
3083    if (num_octaves > 0) {
3084      LabelField("Octave 1", EditorStyles.boldLabel);
3085      EditorGUI.indentLevel += 1;
3086      bc = FindProperty("_Gimmick_Gerstner_Water_a1");
3087      VectorProperty(bc, "a");
3088      bc = FindProperty("_Gimmick_Gerstner_Water_p1");
3089      VectorProperty(bc, "p");
3090      bc = FindProperty("_Gimmick_Gerstner_Water_k_x1");
3091      VectorProperty(bc, "k_x");
3092      bc = FindProperty("_Gimmick_Gerstner_Water_k_y1");
3093      VectorProperty(bc, "k_y");
3094      bc = FindProperty("_Gimmick_Gerstner_Water_t_f1");
3095      VectorProperty(bc, "Time speed");
3096      EditorGUI.indentLevel -= 1;
3097    }
3098
3099    bc = FindProperty("_Gimmick_Gerstner_Water_h");
3100    FloatProperty(bc, "h");
3101    bc = FindProperty("_Gimmick_Gerstner_Water_g");
3102    FloatProperty(bc, "g");
3103    bc = FindProperty("_Gimmick_Gerstner_Water_Scale");
3104    VectorProperty(bc, "Scale");
3105    bc = FindProperty("_Gimmick_Gerstner_Water_Origin_Damping_Direction");
3106    FloatProperty(bc, "Origin damping direction");
3107
3108    EditorGUI.indentLevel -= 1;
3109  }
3110  
3111  // Discard unless camera is inside this box.
3112  void DoGimmickBoxDiscard() {
3113    MaterialProperty bc;
3114
3115    bc = FindProperty("_Gimmick_Box_Discard_Enable_Static");
3116    bool enabled = (bc.floatValue != 0.0);
3117    EditorGUI.BeginChangeCheck();
3118    enabled = Toggle("Box discard", enabled);
3119    EditorGUI.EndChangeCheck();
3120    bc.floatValue = enabled ? 1.0f : 0.0f;
3121    SetKeyword("_GIMMICK_BOX_DISCARD", enabled);
3122
3123    if (!enabled) {
3124      return;
3125    }
3126
3127    EditorGUI.indentLevel += 1;
3128
3129    bc = FindProperty("_Gimmick_Box_Discard_Corner_1");
3130    VectorProperty(bc, "Corner 1");
3131    bc = FindProperty("_Gimmick_Box_Discard_Corner_2");
3132    VectorProperty(bc, "Corner 2");
3133
3134    bc = FindProperty("_Gimmick_Box_Discard_Invert");
3135    enabled = (bc.floatValue != 0.0);
3136    EditorGUI.BeginChangeCheck();
3137    enabled = Toggle("Invert", enabled);
3138    EditorGUI.EndChangeCheck();
3139    bc.floatValue = enabled ? 1.0f : 0.0f;
3140
3141    EditorGUI.indentLevel -= 1;
3142  }
3143
3144  // Dim and desaturate colors. This is in no way comprehensive. Proceed with
3145  // utmost caution whenever creating effects for users with photosensitive
3146  // epilepsy.
3147  void DoGimmickEpilepsyMode() {
3148    MaterialProperty bc;
3149
3150    bc = FindProperty("_Gimmick_Epilepsy_Mode_Enable_Static");
3151    bool enabled = (bc.floatValue != 0.0);
3152    EditorGUI.BeginChangeCheck();
3153    enabled = Toggle("Epilepsy protection mode", enabled);
3154    EditorGUI.EndChangeCheck();
3155    bc.floatValue = enabled ? 1.0f : 0.0f;
3156    SetKeyword("_GIMMICK_EPILEPSY_MODE", enabled);
3157
3158    if (!enabled) {
3159      return;
3160    }
3161
3162    EditorGUI.indentLevel += 1;
3163
3164    bc = FindProperty("_Gimmick_Epilepsy_Mode_Enable_Dynamic");
3165    enabled = (bc.floatValue != 0.0);
3166    EditorGUI.BeginChangeCheck();
3167    enabled = Toggle("Enable (runtime switch)", enabled);
3168    EditorGUI.EndChangeCheck();
3169    bc.floatValue = enabled ? 1.0f : 0.0f;
3170
3171    bc = FindProperty("_Gimmick_Epilepsy_Mode_Luminance_Cutoff");
3172    RangeProperty(bc, "Luminance cutoff");
3173    bc = FindProperty("_Gimmick_Epilepsy_Mode_Saturation_Cutoff");
3174    RangeProperty(bc, "Saturation cutoff");
3175
3176    bc = FindProperty("_Gimmick_Epilepsy_Mode_Rolloff_Power");
3177    FloatProperty(bc, "Rolloff power");
3178
3179    EditorGUI.indentLevel -= 1;
3180  }
3181
3182  enum Lens00Mode {
3183    Bayer,
3184    InterleavedGradientNoise,
3185    SurfaceStableFractalDithering,
3186  }
3187
3188  void DoLens00() {
3189    MaterialProperty bc;
3190
3191    bc = FindProperty("_Gimmick_Lens_00_Enable_Static");
3192    bool enabled = (bc.floatValue != 0.0);
3193    EditorGUI.BeginChangeCheck();
3194    enabled = Toggle("Lens00", enabled);
3195    EditorGUI.EndChangeCheck();
3196    bc.floatValue = enabled ? 1.0f : 0.0f;
3197    SetKeyword("_GIMMICK_LENS_00", enabled);
3198
3199    if (!enabled) {
3200      return;
3201    }
3202
3203    EditorGUI.indentLevel += 1;
3204
3205    bc = FindProperty("_Gimmick_Lens_00_Enable_Frame_Counter");
3206    enabled = (bc.floatValue != 0.0);
3207    EditorGUI.BeginChangeCheck();
3208    enabled = Toggle("Frame counter", enabled);
3209    EditorGUI.EndChangeCheck();
3210    bc.floatValue = enabled ? 1.0f : 0.0f;
3211    SetKeyword("_GIMMICK_LENS_00_FRAME_COUNTER", enabled);
3212
3213    bc = FindProperty("_Gimmick_Lens_00_Subdivisions");
3214    FloatProperty(bc, "Quantization subdivisions");
3215
3216    if (enabled) {
3217      EditorGUI.indentLevel += 1;
3218      bc = FindProperty("_Gimmick_Lens_00_Frame_Counter_Speed");
3219      FloatProperty(bc, "Speed");
3220      EditorGUI.indentLevel -= 1;
3221    }
3222
3223
3224    bc = FindProperty("_Gimmick_Lens_00_Scale");
3225    FloatProperty(bc, "Scale");
3226
3227    bc = FindProperty("_Gimmick_Lens_00_Mode");
3228    Lens00Mode mode = (Lens00Mode) Math.Round(bc.floatValue);
3229    EditorGUI.BeginChangeCheck();
3230    mode = (Lens00Mode) EnumPopup(
3231        MakeLabel("Mode"), mode);
3232    EditorGUI.EndChangeCheck();
3233    bc.floatValue = (float) mode;
3234    SetKeyword("_GIMMICK_LENS_00_BAYER", mode == Lens00Mode.Bayer);
3235    SetKeyword("_GIMMICK_LENS_00_INTERLEAVED_GRADIENT_NOISE", mode == Lens00Mode.InterleavedGradientNoise);
3236    SetKeyword("_GIMMICK_LENS_00_SSFD", mode == Lens00Mode.SurfaceStableFractalDithering);
3237
3238    if (mode == Lens00Mode.SurfaceStableFractalDithering) {
3239      EditorGUI.indentLevel += 1;
3240      bc = FindProperty("_Gimmick_Lens_00_SSFD_Scale");
3241      FloatProperty(bc, "Scale");
3242      bc = FindProperty("_Gimmick_Lens_00_SSFD_Max_Fwidth");
3243      FloatProperty(bc, "Max fwidth");
3244      bc = FindProperty("_Gimmick_Lens_00_SSFD_Size_Factor");
3245      FloatProperty(bc, "Size factor");
3246      bc = FindProperty("_Gimmick_Lens_00_SSFD_Noise");
3247      TexturePropertySingleLine(MakeLabel(bc, "Noise"), bc);
3248      EditorGUI.indentLevel -= 1;
3249    }
3250
3251
3252    EditorGUI.indentLevel -= 1;
3253  }
3254
3255  void DoSurfaceStableFractalDithering() {
3256    MaterialProperty bc;
3257
3258    bc = FindProperty("_Surface_Stable_Fractal_Dithering_Enable_Static");
3259    bool enabled = (bc.floatValue != 0.0);
3260    EditorGUI.BeginChangeCheck();
3261    enabled = Toggle("Stable fractal dithering", enabled);
3262    EditorGUI.EndChangeCheck();
3263    bc.floatValue = enabled ? 1.0f : 0.0f;
3264    SetKeyword("_SURFACE_STABLE_FRACTAL_DITHERING", enabled);
3265
3266    if (!enabled) {
3267      return;
3268    }
3269
3270    EditorGUI.indentLevel += 1;
3271
3272    bc = FindProperty("_Surface_Stable_Fractal_Dithering_Enable_Dynamic");
3273    enabled = (bc.floatValue != 0.0);
3274    EditorGUI.BeginChangeCheck();
3275    enabled = Toggle("Enable (runtime switch)", enabled);
3276    EditorGUI.EndChangeCheck();
3277    bc.floatValue = enabled ? 1.0f : 0.0f;
3278
3279    bc = FindProperty("_Surface_Stable_Fractal_Dithering_Noise");
3280    TexturePropertySingleLine(MakeLabel(bc, "Noise"), bc);
3281    bc = FindProperty("_Surface_Stable_Fractal_Dithering_Scale");
3282    RangeProperty(bc, "Scale");
3283    bc = FindProperty("_Surface_Stable_Fractal_Dithering_Max_Fwidth");
3284    FloatProperty(bc, "Max fwidth");
3285    bc = FindProperty("_Surface_Stable_Fractal_Dithering_Size_Factor");
3286    FloatProperty(bc, "Size factor");
3287    bc = FindProperty("_Surface_Stable_Fractal_Dithering_Brightness_Factor");
3288    FloatProperty(bc, "Brightness factor");
3289    bc = FindProperty("_Surface_Stable_Fractal_Dithering_UV_Offset_R");
3290    VectorProperty(bc, "UV offset (r)");
3291    bc = FindProperty("_Surface_Stable_Fractal_Dithering_UV_Offset_G");
3292    VectorProperty(bc, "UV offset (g)");
3293    bc = FindProperty("_Surface_Stable_Fractal_Dithering_UV_Offset_B");
3294    VectorProperty(bc, "UV offset (b)");
3295
3296    EditorGUI.indentLevel -= 1;
3297  }
3298
3299  void DoGimmicks() {
3300    show_ui.Add(AddCollapsibleMenu("Gimmicks", "_Gimmicks"));
3301    EditorGUI.indentLevel += 1;
3302
3303    DoGimmickFlatColor();
3304    DoGimmickUVDomainWarping();
3305    DoGimmickQuantizeLocation();
3306    DoGimmickShearLocation();
3307    DoGimmickSpherizeLocation();
3308    DoGimmickEyes00();
3309    DoGimmickEyes01();
3310    DoGimmickEyes02();
3311    DoGimmickDownstairs2();
3312    DoGimmickHalo00();
3313    DoGimmickPixellate();
3314    DoGimmickTrochoid();
3315    DoGimmickFaceMeWorldY();
3316    DoGimmickRorschach();
3317    DoGimmickMirrorUVFlip();
3318    DoGimmickLetterGrid();
3319    DoGimmickLetterGrid2();
3320    DoGimmickAudiolinkChroma00();
3321    DoGimmickFog0();
3322    DoGimmickFog1();
3323    DoGimmickZWriteAbomination();
3324    DoGimmickAurora();
3325    DoGimmickGerstnerWater();
3326    DoGimmickBoxDiscard();
3327    DoClones();
3328    DoExplosion();
3329    DoGeoScroll();
3330    DoGimmickEpilepsyMode();
3331    DoLens00();
3332    DoSurfaceStableFractalDithering();
3333
3334    EditorGUI.indentLevel -= 1;
3335    show_ui.RemoveAt(show_ui.Count - 1);
3336  }
3337
3338  void DoMochieParams() {
3339    show_ui.Add(AddCollapsibleMenu("Mochie", "_Mochie"));
3340    EditorGUI.indentLevel += 1;
3341
3342    MaterialProperty bc;
3343
3344    bc = FindProperty("_WrappingFactor");
3345    RangeProperty(bc, "Wrapping factor");
3346    bc = FindProperty("_SpecularStrength");
3347    RangeProperty(bc, "Specular strength");
3348    bc = FindProperty("_FresnelStrength");
3349    RangeProperty(bc, "Fresnel strength");
3350
3351    bc = FindProperty("_UseFresnel");
3352    bool enabled = bc.floatValue > 1E-6;
3353    EditorGUI.BeginChangeCheck();
3354    enabled = Toggle("Use fresnel", enabled);
3355    EditorGUI.EndChangeCheck();
3356    bc.floatValue = enabled ? 1.0f : 0.0f;
3357
3358    MaterialProperty bct = FindProperty("_ReflectionStrengthTex");
3359    bc = FindProperty("_ReflectionStrength");
3360    TexturePropertySingleLine(
3361        MakeLabel(bct, "Ambient occlusion"),
3362        bct, bc);
3363    SetKeyword("_REFLECTION_STRENGTH_TEX", bct.textureValue);
3364
3365
3366    bc = FindProperty("_Enable_SSR");
3367    enabled = bc.floatValue > 1E-6;
3368    EditorGUI.BeginChangeCheck();
3369    enabled = Toggle("Enable SSR", enabled);
3370    EditorGUI.EndChangeCheck();
3371    bc.floatValue = enabled ? 1.0f : 0.0f;
3372    SetKeyword("SSR_ENABLED", enabled);
3373
3374    if (enabled) {
3375      EditorGUI.indentLevel += 1;
3376
3377      bc = FindProperty("_SSRStrength");
3378      FloatProperty(bc, "Strength");
3379
3380      bc = FindProperty("_SSRHeight");
3381      FloatProperty(bc, "Height");
3382
3383      bc = FindProperty("_SSR_Mask");
3384      TexturePropertySingleLine(
3385          MakeLabel(bc, "Mask"),
3386          bc);
3387      SetKeyword("SSR_MASK", bc.textureValue);
3388
3389      EditorGUI.indentLevel -= 1;
3390    } else {
3391      SetKeyword("SSR_MASK", false);
3392    }
3393
3394    EditorGUI.indentLevel -= 1;
3395    show_ui.RemoveAt(show_ui.Count - 1);
3396  }
3397
3398  enum RenderingMode {
3399    Opaque,
3400    Cutout,
3401    Fade,
3402    Transparent,
3403    TransClipping,
3404  }
3405
3406  enum CutoutMode {
3407    Cutoff,
3408    Stochastic,
3409    InterleavedGradientNoise,
3410    NoiseMask,
3411    SurfaceStableFractalDithering,
3412  }
3413
3414  // unity is made by fucking morons and they don't expose this so i'm
3415  // reimplementing it
3416  // ref: https://docs.unity3d.com/6000.0/Documentation/Manual/SL-ZTest.html
3417  enum ZTestMode {
3418    Disabled,
3419    Never,
3420    Less,
3421    Equal,
3422    LEqual,
3423    Greater,
3424    NotEqual,
3425    GEqual,
3426    Always
3427  }
3428
3429  void DoRendering() {
3430    show_ui.Add(AddCollapsibleMenu("Rendering", "_Rendering"));
3431    EditorGUI.indentLevel += 1;
3432
3433    RenderingMode mode = RenderingMode.Opaque;
3434    if (target.IsKeywordEnabled("_RENDERING_CUTOUT")) {
3435      mode = RenderingMode.Cutout;
3436    } else if (target.IsKeywordEnabled("_RENDERING_FADE")) {
3437      mode = RenderingMode.Fade;
3438    } else if (target.IsKeywordEnabled("_RENDERING_TRANSPARENT")) {
3439      mode = RenderingMode.Transparent;
3440    } else if (target.IsKeywordEnabled("_RENDERING_TRANSCLIPPING")) {
3441      mode = RenderingMode.TransClipping;
3442    }
3443
3444    MaterialProperty bc;
3445
3446    EditorGUI.BeginChangeCheck();
3447    mode = (RenderingMode) EnumPopup(
3448        MakeLabel("Rendering mode"), mode);
3449    BlendMode src_blend = BlendMode.One;
3450    BlendMode dst_blend = BlendMode.Zero;
3451    bool zwrite = false;
3452    EditorGUI.EndChangeCheck();
3453    RecordAction("Rendering mode");
3454
3455    bc = FindProperty("_Render_Queue_Offset");
3456    IntegerProperty(
3457        bc,
3458        "Render queue offset");
3459    int queue_offset = bc.intValue;
3460
3461    {
3462      SetKeyword("_RENDERING_CUTOUT", mode == RenderingMode.Cutout);
3463      SetKeyword("_RENDERING_FADE", mode == RenderingMode.Fade);
3464      SetKeyword("_RENDERING_TRANSPARENT", mode == RenderingMode.Transparent);
3465      SetKeyword("_RENDERING_TRANSCLIPPING", mode == RenderingMode.TransClipping);
3466
3467      RenderQueue queue = RenderQueue.Geometry;
3468      string render_type = "";
3469      switch (mode) {
3470        case RenderingMode.Opaque:
3471          queue = RenderQueue.Geometry;
3472          render_type = "";
3473          src_blend = BlendMode.One;
3474          dst_blend = BlendMode.Zero;
3475          zwrite = true;
3476          break;
3477        case RenderingMode.Cutout:
3478          queue = RenderQueue.AlphaTest;
3479          render_type = "TransparentCutout";
3480          src_blend = BlendMode.One;
3481          dst_blend = BlendMode.Zero;
3482          zwrite = true;
3483          break;
3484        case RenderingMode.Fade:
3485          queue = RenderQueue.Transparent;
3486          render_type = "Transparent";
3487          src_blend = BlendMode.SrcAlpha;
3488          dst_blend = BlendMode.OneMinusSrcAlpha;
3489          zwrite = false;
3490          break;
3491        case RenderingMode.Transparent:
3492          queue = RenderQueue.Transparent;
3493          render_type = "Transparent";
3494          src_blend = BlendMode.One;
3495          dst_blend = BlendMode.OneMinusSrcAlpha;
3496          zwrite = false;
3497          break;
3498        case RenderingMode.TransClipping:
3499          queue = RenderQueue.AlphaTest;
3500          render_type = "Transparent";
3501          src_blend = BlendMode.SrcAlpha;
3502          dst_blend = BlendMode.OneMinusSrcAlpha;
3503          zwrite = true;
3504          break;
3505      }
3506
3507      foreach (Material m in editor.targets) {
3508        m.renderQueue = ((int) queue) + queue_offset;
3509        m.SetOverrideTag("RenderType", render_type);
3510        m.SetInt("_SrcBlend", (int) src_blend);
3511        m.SetInt("_DstBlend", (int) dst_blend);
3512        m.SetInt("_ZWrite", zwrite ? 1 : 0);
3513      }
3514    }
3515
3516    if (mode == RenderingMode.Cutout) {
3517      EditorGUI.BeginChangeCheck();
3518      bc = FindProperty("_Cutout_Mode");
3519      CutoutMode cmode = (CutoutMode) Math.Round(bc.floatValue);
3520      cmode = (CutoutMode) EnumPopup(
3521          MakeLabel("Cutout mode"), cmode);
3522      EditorGUI.EndChangeCheck();
3523      bc.floatValue = (float) cmode;
3524      SetKeyword("_RENDERING_CUTOUT_STOCHASTIC", cmode == CutoutMode.Stochastic);
3525      SetKeyword("_RENDERING_CUTOUT_IGN", cmode == CutoutMode.InterleavedGradientNoise);
3526      SetKeyword("_RENDERING_CUTOUT_NOISE_MASK", cmode == CutoutMode.NoiseMask);
3527      SetKeyword("_RENDERING_CUTOUT_SSFD", cmode == CutoutMode.SurfaceStableFractalDithering);
3528
3529      EditorGUI.indentLevel += 1;
3530      {
3531        if (cmode == CutoutMode.Cutoff) {
3532          bc = FindProperty("_Alpha_Cutoff");
3533          ShaderProperty(bc, MakeLabel(bc));
3534        } else if (cmode == CutoutMode.NoiseMask) {
3535          bc = FindProperty("_Rendering_Cutout_Noise_Mask");
3536          TexturePropertySingleLine(
3537              MakeLabel(bc, "Noise mask"),
3538              bc);
3539        } else if (cmode == CutoutMode.InterleavedGradientNoise) {
3540          bc = FindProperty("_Rendering_Cutout_Ign_Seed");
3541          FloatProperty(bc, "Seed");
3542        } else if (cmode == CutoutMode.SurfaceStableFractalDithering) {
3543          bc = FindProperty("_Rendering_Cutout_SSFD_Scale");
3544          FloatProperty(bc, "Scale");
3545          bc = FindProperty("_Rendering_Cutout_SSFD_Max_Fwidth");
3546          FloatProperty(bc, "Max fwidth");
3547          bc = FindProperty("_Rendering_Cutout_SSFD_Noise");
3548          TexturePropertySingleLine(MakeLabel(bc, "Noise"), bc);
3549        }
3550
3551        bc = FindProperty("_Rendering_Cutout_Speed");
3552        FloatProperty(bc, "Speed (for stochastic methods)");
3553      }
3554      EditorGUI.indentLevel -= 1;
3555    }
3556
3557    bc = FindProperty("_Rendering_Cutout_Noise_Scale");
3558    FloatProperty(bc, "Cutout noise scale");
3559
3560    bc = FindProperty("_Frame_Counter_Enable_Static");
3561    bool enabled = bc.floatValue > 1E-6;
3562    EditorGUI.BeginChangeCheck();
3563    enabled = Toggle("Frame counter", enabled);
3564    EditorGUI.EndChangeCheck();
3565    bc.floatValue = enabled ? 1.0f : 0.0f;
3566    SetKeyword("_FRAME_COUNTER", enabled);
3567    if (enabled) {
3568      bc = FindProperty("_Frame_Counter");
3569      FloatProperty(bc, "Frame counter");
3570    }
3571
3572    bc = FindProperty("_Cull");
3573    UnityEngine.Rendering.CullMode cull_mode = (UnityEngine.Rendering.CullMode) bc.floatValue;
3574    EditorGUI.BeginChangeCheck();
3575    cull_mode = (UnityEngine.Rendering.CullMode) EnumPopup(
3576        MakeLabel("Culling mode"), cull_mode);
3577    if (EditorGUI.EndChangeCheck()) {
3578      RecordAction("Culling mode");
3579      bc.floatValue = (float) cull_mode;
3580    }
3581
3582    EditorGUI.BeginChangeCheck();
3583    bc = FindProperty("_ZTest");
3584    ZTestMode zmode = (ZTestMode) Math.Round(bc.floatValue);
3585    zmode = (ZTestMode) EnumPopup(
3586        MakeLabel("ZTest"), zmode);
3587    EditorGUI.EndChangeCheck();
3588    bc.floatValue = (float) zmode;
3589
3590    bc = FindProperty("_Discard_Enable_Static");
3591    enabled = bc.floatValue > 1E-6;
3592    EditorGUI.BeginChangeCheck();
3593    enabled = Toggle("Discard", enabled);
3594    EditorGUI.EndChangeCheck();
3595    bc.floatValue = enabled ? 1.0f : 0.0f;
3596    SetKeyword("_DISCARD", enabled);
3597    if (enabled) {
3598      EditorGUI.indentLevel += 1;
3599      bc = FindProperty("_Discard_Enable_Dynamic");
3600      enabled = bc.floatValue > 1E-6;
3601      EditorGUI.BeginChangeCheck();
3602      enabled = Toggle("Enable", enabled);
3603      EditorGUI.EndChangeCheck();
3604      bc.floatValue = enabled ? 1.0f : 0.0f;
3605      EditorGUI.indentLevel -= 1;
3606    }
3607
3608    bc = FindProperty("_Enable_Unity_Fog");
3609    enabled = bc.floatValue > 1E-6;
3610    EditorGUI.BeginChangeCheck();
3611    enabled = Toggle("Enable Unity fog", enabled);
3612    EditorGUI.EndChangeCheck();
3613    bc.floatValue = enabled ? 1.0f : 0.0f;
3614    SetKeyword("_UNITY_FOG", enabled);
3615
3616    LabelField("Stenciling", EditorStyles.boldLabel);
3617    for (int i = 0; i < 2; i++) {
3618      EditorGUI.indentLevel += 1;
3619
3620      string pass_str = "";
3621      switch (i) {
3622        case 0:
3623          pass_str = "Base";
3624          break;
3625        case 1:
3626          pass_str = "Outline";
3627          break;
3628      }
3629
3630      LabelField($"{pass_str} pass");
3631      {
3632        EditorGUI.indentLevel += 1;
3633        bc = FindProperty($"_Stencil_Ref_{pass_str}");
3634        FloatProperty(bc, "Ref");
3635
3636        bc = FindProperty($"_Stencil_Comp_{pass_str}");
3637        EditorGUI.BeginChangeCheck();
3638        UnityEngine.Rendering.CompareFunction stencil_comp =
3639          (UnityEngine.Rendering.CompareFunction) bc.floatValue;
3640        stencil_comp = (UnityEngine.Rendering.CompareFunction)
3641          EnumPopup(MakeLabel("Comp"), stencil_comp);
3642        EditorGUI.EndChangeCheck();
3643        RecordAction("Rendering mode");
3644        bc.floatValue = (float) stencil_comp;
3645
3646        bc = FindProperty($"_Stencil_Pass_Op_{pass_str}");
3647        EditorGUI.BeginChangeCheck();
3648        UnityEngine.Rendering.StencilOp stencil_op =
3649          (UnityEngine.Rendering.StencilOp) bc.floatValue;
3650        stencil_op = (UnityEngine.Rendering.StencilOp)
3651          EnumPopup(MakeLabel("Pass op"), stencil_op);
3652        EditorGUI.EndChangeCheck();
3653        RecordAction("Rendering mode");
3654        bc.floatValue = (float) stencil_op;
3655
3656        bc = FindProperty($"_Stencil_Fail_Op_{pass_str}");
3657        EditorGUI.BeginChangeCheck();
3658        stencil_op = (UnityEngine.Rendering.StencilOp) bc.floatValue;
3659        stencil_op = (UnityEngine.Rendering.StencilOp)
3660          EnumPopup(MakeLabel("Fail op"), stencil_op);
3661        EditorGUI.EndChangeCheck();
3662        RecordAction("Rendering mode");
3663        bc.floatValue = (float) stencil_op;
3664
3665        EditorGUI.indentLevel -= 1;
3666      }
3667      EditorGUI.indentLevel -= 1;
3668    }
3669    EditorGUI.indentLevel -= 1;
3670    show_ui.RemoveAt(show_ui.Count - 1);
3671  }
3672
3673  void DoLighting() {
3674    show_ui.Add(AddCollapsibleMenu("Lighting", "_Lighting"));
3675    EditorGUI.indentLevel += 1;
3676
3677    MaterialProperty bc;
3678
3679    bc = FindProperty("_Enable_Brightness_Clamp");
3680    bool brightness_clamp_enabled = bc.floatValue > 1E-6;
3681    EditorGUI.BeginChangeCheck();
3682    brightness_clamp_enabled = Toggle("Clamp brightness",
3683        brightness_clamp_enabled);
3684    EditorGUI.EndChangeCheck();
3685    bc.floatValue = brightness_clamp_enabled ? 1.0f : 0.0f;
3686    SetKeyword("_BRIGHTNESS_CLAMP", brightness_clamp_enabled);
3687    if (brightness_clamp_enabled) {
3688      EditorGUI.indentLevel += 1;
3689      bc = FindProperty("_Min_Brightness");
3690      RangeProperty(
3691          bc,
3692          "Min brightness");
3693
3694      bc = FindProperty("_Max_Brightness");
3695      RangeProperty(
3696          bc,
3697          "Max brightness");
3698      EditorGUI.indentLevel -= 1;
3699    }
3700
3701    bc = FindProperty("_Ambient_Occlusion");
3702    TexturePropertySingleLine(
3703        MakeLabel(bc, "Ambient occlusion"),
3704        bc);
3705    SetKeyword("_AMBIENT_OCCLUSION", bc.textureValue);
3706    if (bc.textureValue) {
3707      TextureScaleOffsetProperty(bc);
3708    }
3709
3710    if (bc.textureValue) {
3711      bc = FindProperty("_Ambient_Occlusion_Strength");
3712      RangeProperty(bc, "Ambient occlusion strength");
3713    }
3714
3715    bc = FindProperty("_Cubemap");
3716    TexturePropertySingleLine(
3717        MakeLabel(bc, "Cubemap"),
3718        bc);
3719    SetKeyword("_CUBEMAP", bc.textureValue);
3720
3721    if (bc.textureValue) {
3722      bc = FindProperty("_Cubemap_Limit_To_Metallic");
3723      bool cube_lim_enabled = bc.floatValue > 1E-6;
3724      EditorGUI.BeginChangeCheck();
3725      cube_lim_enabled = Toggle("Limit to metallic",
3726          cube_lim_enabled);
3727      EditorGUI.EndChangeCheck();
3728      bc.floatValue = cube_lim_enabled ? 1.0f : 0.0f;
3729    }
3730
3731    bc = FindProperty("_Lighting_Factor");
3732    RangeProperty(
3733        bc,
3734        "Lighting multiplier");
3735
3736    {
3737      EditorGUI.indentLevel += 1;
3738      bc = FindProperty("_Direct_Lighting_Factor");
3739      RangeProperty(
3740          bc,
3741          "Direct multiplier");
3742
3743      bc = FindProperty("_Vertex_Lighting_Factor");
3744      RangeProperty(
3745          bc,
3746          "Vertex light multiplier");
3747
3748      bc = FindProperty("_Indirect_Specular_Lighting_Factor");
3749      RangeProperty(
3750          bc,
3751          "Indirect specular multiplier");
3752
3753      bc = FindProperty("_Indirect_Specular_Lighting_Factor2");
3754      RangeProperty(
3755          bc,
3756          "Secondary ind. spec. multiplier");
3757
3758      bc = FindProperty("_Indirect_Diffuse_Lighting_Factor");
3759      RangeProperty(
3760          bc,
3761          "Indirect diffuse multiplier");
3762      EditorGUI.indentLevel -= 1;
3763    }
3764
3765    bc = FindProperty("_Reflection_Probe_Saturation");
3766    RangeProperty(
3767        bc,
3768        "Reflection probe saturation");
3769
3770    bc = FindProperty("_Shadow_Strength");
3771    RangeProperty(
3772        bc,
3773        "Shadows strength");
3774
3775    bc = FindProperty("_Global_Sample_Bias");
3776    FloatProperty(
3777        bc,
3778        "Global mipmap bias");
3779
3780    bc = FindProperty("_Proximity_Dimming_Enable_Static");
3781    bool enabled = bc.floatValue > 1E-6;
3782    EditorGUI.BeginChangeCheck();
3783    enabled = Toggle("Proximity dimming", enabled);
3784    EditorGUI.EndChangeCheck();
3785    bc.floatValue = enabled ? 1.0f : 0.0f;
3786    SetKeyword("_PROXIMITY_DIMMING", enabled);
3787
3788    if (enabled) {
3789      EditorGUI.indentLevel += 1;
3790
3791      bc = FindProperty("_Proximity_Dimming_Min_Dist");
3792      FloatProperty(bc, "Min distance");
3793
3794      bc = FindProperty("_Proximity_Dimming_Max_Dist");
3795      FloatProperty(bc, "Max distance");
3796
3797      bc = FindProperty("_Proximity_Dimming_Factor");
3798      FloatProperty(bc, "Dimming factor");
3799
3800      EditorGUI.indentLevel -= 1;
3801    }
3802
3803    bc = FindProperty("_LTCGI_Enabled");
3804    enabled = bc.floatValue > 1E-6;
3805    EditorGUI.BeginChangeCheck();
3806    enabled = Toggle("Enable LTCGI", enabled);
3807    EditorGUI.EndChangeCheck();
3808    bc.floatValue = enabled ? 1.0f : 0.0f;
3809    SetKeyword("_LTCGI", enabled);
3810
3811    if (enabled) {
3812      EditorGUI.indentLevel += 1;
3813
3814      bc = FindProperty("_LTCGI_Enabled_Dynamic");
3815      enabled = bc.floatValue > 1E-6;
3816      EditorGUI.BeginChangeCheck();
3817      enabled = Toggle("Enable (runtime switch)", enabled);
3818      EditorGUI.EndChangeCheck();
3819      bc.floatValue = enabled ? 1.0f : 0.0f;
3820
3821      bc = FindProperty("_LTCGI_SpecularColor");
3822      ColorProperty(bc, "Specular color (RGB)");
3823
3824      bc = FindProperty("_LTCGI_DiffuseColor");
3825      ColorProperty(bc, "Diffuse color (RGB)");
3826
3827      bc = FindProperty("_LTCGI_Strength");
3828      FloatProperty(bc, "LTCGI strength");
3829
3830      EditorGUI.indentLevel -= 1;
3831    }
3832
3833    bc = FindProperty("_Force_World_Lighting");
3834    enabled = bc.floatValue > 1E-6;
3835    EditorGUI.BeginChangeCheck();
3836    enabled = Toggle("Force world lighting", enabled);
3837    EditorGUI.EndChangeCheck();
3838    bc.floatValue = enabled ? 1.0f : 0.0f;
3839    SetKeyword("_FORCE_WORLD_LIGHTING", enabled);
3840
3841    bc = FindProperty("_Aces_Filmic_Enable_Static");
3842    enabled = bc.floatValue > 1E-6;
3843    EditorGUI.BeginChangeCheck();
3844    enabled = Toggle("Enable ACES filmic", enabled);
3845    EditorGUI.EndChangeCheck();
3846    bc.floatValue = enabled ? 1.0f : 0.0f;
3847    SetKeyword("_ACES_FILMIC", enabled);
3848
3849    EditorGUI.BeginChangeCheck();
3850    editor.LightmapEmissionProperty();
3851    if (EditorGUI.EndChangeCheck()) {
3852      foreach (Material m in editor.targets) {
3853        m.globalIlluminationFlags &=
3854          ~MaterialGlobalIlluminationFlags.EmissiveIsBlack;
3855      }
3856    }
3857
3858    EditorGUI.indentLevel -= 1;
3859    show_ui.RemoveAt(show_ui.Count - 1);
3860  }
3861
3862  void DoMain() {
3863    DoPBR();
3864    DoPBROverlay();
3865    DoClearcoat();
3866    DoDecal();
3867    DoEmission();
3868    DoShadingMode();
3869    DoMatcapRL();
3870    DoOutlines();
3871    DoGlitter();
3872    DoUVScroll();
3873    DoHueShift();
3874    DoGimmicks();
3875    DoMochieParams();
3876    DoLighting();
3877    DoRendering();
3878  }
3879}
3880