﻿#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using System.Linq;
using System.Reflection;
using System.Collections.Generic;

public class DopeSFXGUI231 : ShaderGUI
{
    private Font VrchatFont = (Font)Resources.Load(@"BankGothic");

    private BindingFlags bindingFlags = BindingFlags.Public |
                                        BindingFlags.NonPublic |
                                        BindingFlags.Instance |
                                        BindingFlags.Static;
    private MaterialProperty UFPS = null;
    private MaterialProperty DF = null;
    private MaterialProperty _fs = null;
    private MaterialProperty _fe = null;

    private MaterialProperty SM = null;
    private MaterialProperty SMCOLMODE = null;
    private MaterialProperty BGTWM = null;
    private MaterialProperty _outcol = null;
    private MaterialProperty _BGTCubeMap = null;
    private MaterialProperty _BGTCubeRotX = null;
    private MaterialProperty _BGTCubeRotY = null;
    private MaterialProperty _BGTCubeRotZ = null;
    private MaterialProperty _BGTScreenTex = null;
    private MaterialProperty _BGTWidth = null;
    private MaterialProperty _BGTHeight = null;
    private MaterialProperty _BGTScale = null;
    private MaterialProperty _BGTLR = null;
    private MaterialProperty _BGTUD = null;
    private MaterialProperty _BGTtrotfov = null;
    private MaterialProperty _BGTtrotLR = null;
    private MaterialProperty _BGTtrotUD = null;
    private MaterialProperty _BGTtrotX = null;
    private MaterialProperty _BGTtrotY = null;
    private MaterialProperty _BGTtrotZ = null;
    private MaterialProperty _BGTtblur = null;
    private MaterialProperty BGG = null;
    private MaterialProperty _BGColumns = null;
    private MaterialProperty _BGRows = null;
    private MaterialProperty _BGfps = null;
    private MaterialProperty _BGMoffset = null;

    private MaterialProperty CENTERING = null;
    private MaterialProperty _Dir = null;

    private MaterialProperty E = null;
    private MaterialProperty AUDIOLINK = null;
    private MaterialProperty _AudioLinkBand = null;
    private MaterialProperty _FogAudioLinkBand = null;
    private MaterialProperty _BlurDisplaceAudioLinkBand = null;
    private MaterialProperty _BlurAlphaAudioLinkBand = null;
    private MaterialProperty _GlitchAudioLinkBand = null;
    private MaterialProperty _ScreenSpaceImageAudioLinkBand = null;
    private MaterialProperty _ShakeAudioLinkBand = null;
    private MaterialProperty _RotatorAudioLinkBand = null;
    private MaterialProperty _ZoomAudioLinkBand = null;
    private MaterialProperty _PixAudioLinkBand = null;
    private MaterialProperty _WavesAudioLinkBand = null;
    private MaterialProperty _StretchAudioLinkBand = null;
    private MaterialProperty _CompressAudioLinkBand = null;
    private MaterialProperty _SharpDistortionAudioLinkBand = null;
    private MaterialProperty _DistortionAudioLinkBand = null;
    private MaterialProperty _EdgeGlowAudioLinkBand = null;
    private MaterialProperty _RaysAudioLinkBand = null;
    private MaterialProperty _HUEAudioLinkBand = null;
    private MaterialProperty _HSVColorSelectionAudioLinkBand = null;
    private MaterialProperty _FilmGrainAudioLinkBand = null;
    private MaterialProperty _SpeedEffectAudioLinkBand = null;
    private MaterialProperty _NoiseAudioLinkBand = null;
    private MaterialProperty _VignetteAudioLinkBand = null;
    private MaterialProperty _BarsAudioLinkBand = null;
    private MaterialProperty _LinesAudioLinkBand = null;

    private MaterialProperty SHAKE = null;
    private MaterialProperty _AmplitudeX = null;
    private MaterialProperty _AmplitudeY = null;
    private MaterialProperty _xsp = null;
    private MaterialProperty _ysp = null;
    private MaterialProperty _Totalamp = null;
    private MaterialProperty _shroundness = null;

    private MaterialProperty MOVE = null;
    private MaterialProperty _MoveX = null;
    private MaterialProperty _MoveY = null;
    private MaterialProperty _MoveXY = null;
    private MaterialProperty _MoveYX = null;

    private MaterialProperty ROTATOR = null;
    private MaterialProperty _Totalrotamp = null;
    private MaterialProperty _rotampX = null;
    private MaterialProperty _rotspeedX = null;
    private MaterialProperty _rotoffsetX = null;
    private MaterialProperty _roffsetspeedX = null;
    private MaterialProperty _rotampY = null;
    private MaterialProperty _rotspeedY = null;
    private MaterialProperty _rotoffsetY = null;
    private MaterialProperty _roffsetspeedY = null;
    private MaterialProperty _rotamp = null;
    private MaterialProperty _rotspeed = null;
    private MaterialProperty _rotoffset = null;
    private MaterialProperty _roffsetspeed = null;
    private MaterialProperty _rotMoveX = null;
    private MaterialProperty _rotMoveY = null;
    private MaterialProperty _rotMoveXY = null;
    private MaterialProperty _rotMoveYX = null;

    private MaterialProperty ZOOM = null;
    private MaterialProperty _Zoom = null;
    private MaterialProperty _ZoomSpeed = null;
    private MaterialProperty _ZoomUpper = null;
    private MaterialProperty _ZoomLower = null;

    private MaterialProperty PIX = null;
    private MaterialProperty PIXAUTO = null;
    private MaterialProperty _pix = null;
    private MaterialProperty _pixmasktype = null;
    private MaterialProperty _pixmaskvalue = null;

    private MaterialProperty FISHEYE = null;
    private MaterialProperty _fZoom = null;
    private MaterialProperty _faspectfix = null;

    private MaterialProperty KDS = null;
    private MaterialProperty _kSteps = null;
    private MaterialProperty _kGlow = null;
    private MaterialProperty _kGlowA = null;
    private MaterialProperty _Kaleidoscope = null;
    private MaterialProperty _kAngle = null;
    private MaterialProperty _kScale = null;
    private MaterialProperty _kSpeed1 = null;
    private MaterialProperty _kSpeed2 = null;
    private MaterialProperty _kOffset1 = null;
    private MaterialProperty _kOffset2 = null;

    private MaterialProperty SHOCKWAVE = null;
    private MaterialProperty _swscale = null;
    private MaterialProperty _swspeed = null;
    private MaterialProperty _swmo = null;
    private MaterialProperty _swpow = null;
    private MaterialProperty _swthickness = null;

    private MaterialProperty SWIRL = null;
    private MaterialProperty _srad = null;
    private MaterialProperty _sangle = null;
    private MaterialProperty _sspeed = null;
    private MaterialProperty _sspeedtile = null;
    private MaterialProperty _sspeedoffset = null;

    private MaterialProperty SHARPDISTORTION = null;
    private MaterialProperty _SharpDistortionX = null;
    private MaterialProperty _SharpDistortionY = null;
    private MaterialProperty _SharpDistortionR = null;
    private MaterialProperty _SharpDistortionTotal = null;
    private MaterialProperty _SharpDistortioncount = null;
    private MaterialProperty _SharpDistortionRotate = null;
    private MaterialProperty _SharpDistortionRotateSpeed = null;

    private MaterialProperty WAVES = null;
    private MaterialProperty _Waves = null;
    private MaterialProperty _WavesPower = null;
    private MaterialProperty _WavesSpeed = null;

    private MaterialProperty STRETCH = null;
    private MaterialProperty _stretchX = null;
    private MaterialProperty _stretchY = null;
    private MaterialProperty COMPRESS = null;
    private MaterialProperty _compressX = null;
    private MaterialProperty _compressY = null;

    private MaterialProperty WD = null;
    private MaterialProperty _dpower = null;
    private MaterialProperty _dtile = null;
    private MaterialProperty _dspeed = null;

    private MaterialProperty CUTTING = null;
    private MaterialProperty _CutTotal = null;
    private MaterialProperty _CutTopX = null;
    private MaterialProperty _CutBotX = null;
    private MaterialProperty _CutTopN = null;
    private MaterialProperty _CutBotN = null;
    private MaterialProperty _CutRot = null;

    private MaterialProperty GLITCH = null;
    private MaterialProperty _gsamples = null;
    private MaterialProperty _blocksize = null;
    private MaterialProperty _glitchoffset = null;
    private MaterialProperty _coloffset = null;
    private MaterialProperty _gtotal = null;
    private MaterialProperty _gspeed = null;

    private MaterialProperty RGB = null;
    private MaterialProperty _rgboffs = null;
    private MaterialProperty _rgboffsR = null;
    private MaterialProperty _rgboffsB = null;
    private MaterialProperty _rgbrotspeed = null;
    private MaterialProperty _rgbrotoffs = null;
    private MaterialProperty _TotalampRGB = null;
    private MaterialProperty _TotalampR = null;
    private MaterialProperty _AmplitudeRX = null;
    private MaterialProperty _xspR = null;
    private MaterialProperty _AmplitudeRY = null;
    private MaterialProperty _yspR = null;
    private MaterialProperty _TotalampG = null;
    private MaterialProperty _AmplitudeGX = null;
    private MaterialProperty _xspG = null;
    private MaterialProperty _AmplitudeGY = null;
    private MaterialProperty _yspG = null;
    private MaterialProperty _TotalampB = null;
    private MaterialProperty _AmplitudeBX = null;
    private MaterialProperty _xspB = null;
    private MaterialProperty _AmplitudeBY = null;
    private MaterialProperty _yspB = null;

    private MaterialProperty BLUR = null;
    private MaterialProperty CHRBLUR = null;
    private MaterialProperty _samples = null;
    private MaterialProperty _ds = null;
    private MaterialProperty _falloff = null;
    private MaterialProperty _blurnoise = null;
    private MaterialProperty _rotationds = null;
    private MaterialProperty _rotationsp = null;
    private MaterialProperty _bluralpha = null;
    private MaterialProperty FALLOFFC = null;
    private MaterialProperty _blurHSpeed = null;
    private MaterialProperty _blurHOffset = null;
    private MaterialProperty _blurSM = null;
    private MaterialProperty _ChrColor1 = null;
    private MaterialProperty _ChrColor2 = null;
    private MaterialProperty _ChrColor3 = null;

    private MaterialProperty EDGEGLOW = null;
    private MaterialProperty EGUV = null;
    private MaterialProperty _egoffset = null;
    private MaterialProperty _egpow = null;
    private MaterialProperty _egcol = null;
    private MaterialProperty _egdistortion = null;
    private MaterialProperty _egbgcol = null;
    private MaterialProperty _saturationeg = null;

    private MaterialProperty _egmasktype = null;
    private MaterialProperty _egmaskvalue = null;

    private MaterialProperty EGSHAKE = null;
    private MaterialProperty _egAmplitudeX = null;
    private MaterialProperty _egAmplitudeY = null;
    private MaterialProperty _egxsp = null;
    private MaterialProperty _egysp = null;
    private MaterialProperty _egTotalamp = null;

    private MaterialProperty EGHUE = null;
    private MaterialProperty _EGhue = null;
    private MaterialProperty _EGhueo = null;
    private MaterialProperty _EGhuespeed = null;

    private MaterialProperty EGMOVE = null;
    private MaterialProperty _egMoveX = null;
    private MaterialProperty _egMoveY = null;
    private MaterialProperty _egMoveXY = null;
    private MaterialProperty _egMoveYX = null;

    private MaterialProperty EGFISHEYE = null;
    private MaterialProperty _egfZoom = null;
    private MaterialProperty _egfaspectfix = null;

    private MaterialProperty EGDISTORTION = null;
    private MaterialProperty _egdpower = null;
    private MaterialProperty _egdtile = null;
    private MaterialProperty _egdspeed = null;

    private MaterialProperty UFPASS = null;
    private MaterialProperty _rays = null;
    private MaterialProperty _rayscontrast = null;

    private MaterialProperty SPEEDEFFECT = null;
    private MaterialProperty SPEEDEFFECTUV = null;
    private MaterialProperty _SpeedEffectRounding = null;
    private MaterialProperty _SpeedEffectColor = null;
    private MaterialProperty _SpeedEffectAlpha = null;
    private MaterialProperty _SpeedEffectFade = null;
    private MaterialProperty _SpeedEffectFadeRange = null;
    private MaterialProperty _SpeedEffectLineWidth = null;
    private MaterialProperty _SpeedEffectManualOffset = null;
    private MaterialProperty _SpeedEffectSpeed = null;
    private MaterialProperty _SpeedEffectLength = null;
    private MaterialProperty _SpeedEffectTile = null;

    private MaterialProperty FOGM = null;
    private MaterialProperty DFOG = null;
    private MaterialProperty _DFogTile = null;
    private MaterialProperty _FogSpeed = null;
    private MaterialProperty _FogSmooth = null;
    private MaterialProperty _FogOffset = null;
    private MaterialProperty _FogColor = null;
    private MaterialProperty _FogAlpha = null;

    private MaterialProperty HUE = null;
    private MaterialProperty _HUEa = null;
    private MaterialProperty _ofsorc = null;
    private MaterialProperty _TileHue = null;
    private MaterialProperty _HUE = null;
    private MaterialProperty _HUESpeed = null;
    private MaterialProperty OBC = null;

    private MaterialProperty COLSEL = null;
    private MaterialProperty _Colsela = null;
    private MaterialProperty _TargetColor = null;
    private MaterialProperty _HueRange = null;
    private MaterialProperty _SaturationRange = null;
    private MaterialProperty _LightnessRange = null;
    private MaterialProperty _HueSmoothRange = null;
    private MaterialProperty _SaturationSmoothRange = null;
    private MaterialProperty _LightnessSmoothRange = null;

    private MaterialProperty COLOR_GRADING = null;
    private MaterialProperty _Colorm = null;
    private MaterialProperty _brightness = null;
    private MaterialProperty _Colort = null;
    private MaterialProperty _transitiontoColor = null;
    private MaterialProperty _HDR = null;
    private MaterialProperty _HDRMultiplyer = null;
    private MaterialProperty _contrast = null;
    private MaterialProperty _saturation = null;
    private MaterialProperty _invert = null;

    private MaterialProperty SST = null;
    private MaterialProperty WM = null;
    private MaterialProperty _ScreenTex = null;
    private MaterialProperty _Tint = null;
    private MaterialProperty _TexAlpha = null;
    private MaterialProperty _Width = null;
    private MaterialProperty _Height = null;
    private MaterialProperty _Scale = null;
    private MaterialProperty _LR = null;
    private MaterialProperty _UD = null;
    private MaterialProperty _trfov = null;
    private MaterialProperty _trotX = null;
    private MaterialProperty _trotY = null;
    private MaterialProperty _trotZ = null;
    private MaterialProperty _trLR = null;
    private MaterialProperty _trUD = null;
    private MaterialProperty _tblur = null;

    private MaterialProperty SSG = null;
    private MaterialProperty _Columns = null;
    private MaterialProperty _Rows = null;
    private MaterialProperty _fps = null;
    private MaterialProperty _Moffset = null;

    private MaterialProperty FILMGRAIN = null;
    private MaterialProperty FILMGRAINUV = null;
    private MaterialProperty _fgcol = null;
    private MaterialProperty _fga = null;
    private MaterialProperty _fglinesp = null;
    private MaterialProperty _fgslinesp = null;
    private MaterialProperty _fgnfp = null;
    private MaterialProperty _fgrt = null;
    private MaterialProperty _fgt = null;
    private MaterialProperty _fgds = null;

    private MaterialProperty NOISE = null;
    private MaterialProperty _Noise = null;
    private MaterialProperty _Noisep = null;
    private MaterialProperty _Noisebl = null;
    private MaterialProperty _Noiseblsp = null;
    private MaterialProperty _Noisecol = null;
    private MaterialProperty NOISEB = null;

    private MaterialProperty VBORDER = null;

    private MaterialProperty VIGNETTE = null;
    private MaterialProperty VIGNETTEUV = null;
    private MaterialProperty _Vignette = null;
    private MaterialProperty _Vignettesmtf = null;
    private MaterialProperty _Vignetter = null;
    private MaterialProperty _Vignetteround = null;
    private MaterialProperty _Vignettebl = null;
    private MaterialProperty _Vignetteblsp = null;
    private MaterialProperty _Vignettecol = null;
    private MaterialProperty VGBGM = null;
	private MaterialProperty _VGTScreenTex = null;
    private MaterialProperty _VGTtblur = null;
    private MaterialProperty VGTWM = null;
	private MaterialProperty _VGTWidth = null;
	private MaterialProperty _VGTHeight = null;
    private MaterialProperty _VGTScale = null;
	private MaterialProperty _VGTLR = null;
	private MaterialProperty _VGTUD = null;
    private MaterialProperty _VGTtrotfov = null;
    private MaterialProperty _VGTtrotLR = null;
    private MaterialProperty _VGTtrotUD = null;
    private MaterialProperty _VGTtrotX = null;
    private MaterialProperty _VGTtrotY = null;
    private MaterialProperty _VGTtrotZ = null;
    private MaterialProperty VGG = null;
    private MaterialProperty _VGGColumns = null;
    private MaterialProperty _VGGRows = null;
    private MaterialProperty _VGGfps = null;
    private MaterialProperty _VGGMoffset = null;

    private MaterialProperty BB = null;
    private MaterialProperty BBUV = null;
    private MaterialProperty _barsx = null;
    private MaterialProperty _barsy = null;
    private MaterialProperty _smb = null;
    private MaterialProperty _smbx = null;
    private MaterialProperty _smby = null;
    private MaterialProperty BBR = null;
    private MaterialProperty _BTotalrotamp = null;
    private MaterialProperty _BrotampX = null;
    private MaterialProperty _BrotspeedX = null;
    private MaterialProperty _BrotoffsetX = null;
    private MaterialProperty _BroffsetspeedX = null;
    private MaterialProperty _BrotampY = null;
    private MaterialProperty _BrotspeedY = null;
    private MaterialProperty _BrotoffsetY = null;
    private MaterialProperty _BroffsetspeedY = null;
    private MaterialProperty _BrotampZ = null;
    private MaterialProperty _BrotspeedZ = null;
    private MaterialProperty _BrotoffsetZ = null;
    private MaterialProperty _BroffsetspeedZ = null;
    private MaterialProperty _bbcol = null;
    private MaterialProperty BBGM = null;
    private MaterialProperty BBTWM = null;
	private MaterialProperty _BBTScreenTex = null;
	private MaterialProperty _BBTWidth = null;
	private MaterialProperty _BBTHeight = null;
    private MaterialProperty _BBTScale = null;
	private MaterialProperty _BBTLR = null;
	private MaterialProperty _BBTUD = null;
    private MaterialProperty _BBTtrotfov = null;
    private MaterialProperty _BBTtrotLR = null;
    private MaterialProperty _BBTtrotUD = null;
	private MaterialProperty _BBTtrotX = null;
    private MaterialProperty _BBTtrotY = null;
    private MaterialProperty _BBTtrotZ = null;
    private MaterialProperty _BBTtblur = null;
    private MaterialProperty BBG = null;
    private MaterialProperty _BBGColumns = null;
    private MaterialProperty _BBGRows = null;
    private MaterialProperty _BBGfps = null;
    private MaterialProperty _BBGMoffset = null;

    private MaterialProperty LINES = null;
    private MaterialProperty LINESUV = null;
    private MaterialProperty _lines = null;
    private MaterialProperty _linesc = null;
    private MaterialProperty _liness = null;
    private MaterialProperty _linesr = null;
    private MaterialProperty _linescol = null;


    private MaterialProperty DITHER = null;
    private MaterialProperty _ditherluma = null;
    private MaterialProperty _Dither = null;

    private MaterialProperty _Stencil = null;
    private MaterialProperty _ReadMask = null;
    private MaterialProperty _WriteMask = null;
    private MaterialProperty _StencilComp = null;
    private MaterialProperty _StencilOp = null;
    private MaterialProperty _StencilFail = null;
    private MaterialProperty _StencilZFail = null;

    private MaterialProperty _UseCustomQueue = null;
    private MaterialProperty _Queue = null;

    MaterialEditor editor = null;
    bool m_FirstTimeApply = true;
    List<ParticleSystemRenderer> m_RenderersUsingThisMaterial = new List<ParticleSystemRenderer>();

    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
    {
        editor = materialEditor; Material material; Shader shader; PrepareGUI(properties, out material, out shader);

        DrawBanner(shader.name.Split('/').Last(), "Open Discord", "https://discord.gg/2AtRJbT2JJ");

        DrawHeader("Renderer and Main Settings");
        EditorGUILayout.BeginVertical("GroupBox");
        DrawMainSettings(material);
        DrawGrabTexSettings(material);
        DrawCentering(material);
        DrawStencil(material);
        DrawOrder(material);
        DrawAudioLink(material);
        DrawQueue(material);
        EditorGUILayout.EndVertical();

        DrawHeader("Post Processing");
        EditorGUILayout.BeginVertical("GroupBox");
        DrawShake(material);
        DrawMove(material);
        DrawRotator(material);
        DrawZoom(material);
        DrawFisheye(material);
        DrawKaleidoscope(material);
        DrawShockwave(material);
        DrawPixelation(material);
        DrawSwirl(material);
        DrawWaves(material);
        DrawStretch(material);
        DrawCompress(material);
        DrawSharpDistortion(material);
        DrawDistortion(material);
        DrawGlitch(material);
        DrawCutting(material);
        DrawRGBOptions(material);
        DrawBlur(material);
        DrawEdgeGlow(material);
        DrawRays(material);
        DrawFog(material);
        DrawHUE(material);
        DrawHSVcs(material);
        DrawColorGrading(material);
        DrawScreenSpaceTex(material);
        DrawSpeedEffect(material);
        DrawFilmGrain(material);
        DrawNoise(material);
        DrawVignette(material);
        DrawBars(material);
        DrawLines(material);
        DrawDither(material);
        EditorGUILayout.EndVertical();

        DrawBanner("Patreon", "Open Patreon", "https://www.patreon.com/dopestuff");

        DrawCredits();
    }

    private void DrawMainSettings(Material material)
    {
        MakeFoldout(material, "_MainSettingsGUI", "Main Settings");
        if (material.GetInt("_MainSettingsGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(UFPS, MakeLabel(UFPS));
            if (material.GetInt("UFPS") == 1 && m_FirstTimeApply)
            {
                CacheRenderersUsingThisMaterial(material);
                m_FirstTimeApply = false;
            }
            EditorGUILayout.EndVertical();

            EditorGUI.BeginDisabledGroup(material.GetInt("UFPS") == 0);
            EditorGUILayout.BeginVertical(GUI.skin.box);
            DoConfigureRendererArea(material);
            EditorGUILayout.EndVertical();
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(DF, MakeLabel(DF));

            EditorGUI.BeginDisabledGroup(material.GetInt("DF") == 2);

            editor.ShaderProperty(_fs, MakeLabel(_fs));
            editor.ShaderProperty(_fe, MakeLabel(_fe));

            EditorGUI.EndDisabledGroup();

            EditorGUILayout.EndVertical();

            if (material.GetInt("E") == 0)
            {
                editor.ShaderProperty(E, MakeLabel(E));
            }
        }
    }

    private void DrawGrabTexSettings(Material material)
    {
        MakeFoldout(material, "_GrabTexSettingsGUI", "Grab Texture Settings");
        if (material.GetInt("_GrabTexSettingsGUI") == 1)
        {
            if (material.GetInt("KDS") == 1)
            {
                EditorGUILayout.HelpBox("Screen mode selection disabled with enabled Kaleidoscope", MessageType.Info, true);
            }
            EditorGUI.BeginDisabledGroup(material.GetInt("KDS") == 1);
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(SM, MakeLabel(SM));
            EditorGUILayout.EndVertical();
            if (material.GetInt("SM") == 2)
            {
                EditorGUILayout.BeginVertical(GUI.skin.box);
                editor.ShaderProperty(SMCOLMODE, MakeLabel(SMCOLMODE));
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical(GUI.skin.box);
                if (material.GetInt("SMCOLMODE") == 0)
                {
                    editor.ShaderProperty(_outcol, MakeLabel(_outcol));
                }
                else if (material.GetInt("SMCOLMODE") == 1)
                {
                    DrawTexture(_BGTScreenTex, _outcol);
                    editor.ShaderProperty(_BGTtblur, MakeLabel(_BGTtblur));
                    EditorGUILayout.EndVertical();

                    EditorGUILayout.BeginVertical(GUI.skin.box);
                    editor.ShaderProperty(BGTWM, MakeLabel(BGTWM));
                    editor.ShaderProperty(_BGTWidth, MakeLabel(_BGTWidth));
                    editor.ShaderProperty(_BGTHeight, MakeLabel(_BGTHeight));
                    editor.ShaderProperty(_BGTScale, MakeLabel(_BGTScale));
                    editor.ShaderProperty(_BGTLR, MakeLabel(_BGTLR));
                    editor.ShaderProperty(_BGTUD, MakeLabel(_BGTUD));
                    EditorGUILayout.EndVertical();
                    EditorGUILayout.BeginVertical(GUI.skin.box);
                    editor.ShaderProperty(_BGTtrotX, MakeLabel(_BGTtrotX));
                    editor.ShaderProperty(_BGTtrotY, MakeLabel(_BGTtrotY));
                    editor.ShaderProperty(_BGTtrotZ, MakeLabel(_BGTtrotZ));
                    editor.ShaderProperty(_BGTtrotfov, MakeLabel(_BGTtrotfov));
                    editor.ShaderProperty(_BGTtrotLR, MakeLabel(_BGTtrotLR));
                    editor.ShaderProperty(_BGTtrotUD, MakeLabel(_BGTtrotUD));
                    EditorGUILayout.EndVertical();

                    EditorGUILayout.BeginVertical(GUI.skin.box);
                    editor.ShaderProperty(BGG, MakeLabel(BGG));
                    if (material.GetInt("BGG") == 1)
                    {
                        editor.ShaderProperty(_BGColumns, MakeLabel(_BGColumns));
                        editor.ShaderProperty(_BGRows, MakeLabel(_BGRows));
                        editor.ShaderProperty(_BGfps, MakeLabel(_BGfps));
                        editor.ShaderProperty(_BGMoffset, MakeLabel(_BGMoffset));
                    }
                }
                else if (material.GetInt("SMCOLMODE") == 2)
                {
                    DrawTexture(_BGTCubeMap, _outcol);
                    editor.ShaderProperty(_BGTtblur, MakeLabel(_BGTtblur));
                    EditorGUILayout.EndVertical();
                    EditorGUILayout.BeginVertical(GUI.skin.box);
                    editor.ShaderProperty(_BGTCubeRotX, MakeLabel(_BGTCubeRotX));
                    editor.ShaderProperty(_BGTCubeRotY, MakeLabel(_BGTCubeRotY));
                    editor.ShaderProperty(_BGTCubeRotZ, MakeLabel(_BGTCubeRotZ));
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUI.EndDisabledGroup();
        }
    }

    private void DrawCentering(Material material)
    {
        MakeFoldout(material, "_CenteringGUI", "Centering Renderer");
        if (material.GetInt("_CenteringGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(CENTERING, MakeLabel(CENTERING));
            editor.ShaderProperty(_Dir, MakeLabel(_Dir));
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawStencil(Material material)
    {
        MakeFoldout(material, "_StencilGUI", "Stencil");
        if (material.GetInt("_StencilGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_Stencil, MakeLabel(_Stencil));
            editor.ShaderProperty(_ReadMask, MakeLabel(_ReadMask));
            editor.ShaderProperty(_WriteMask, MakeLabel(_WriteMask));
            editor.ShaderProperty(_StencilComp, MakeLabel(_StencilComp));
            editor.ShaderProperty(_StencilOp, MakeLabel(_StencilOp));
            editor.ShaderProperty(_StencilFail , MakeLabel(_StencilFail ));
            editor.ShaderProperty(_StencilZFail, MakeLabel(_StencilZFail));
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawOrder(Material material)
    {
        MakeFoldout(material, "_OrderGUI", "Order");
        if (material.GetInt("_OrderGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(VBORDER, MakeLabel(VBORDER));
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawAudioLink(Material material)
    {
        MakeFoldout(material, "_AudioLinkGUI", "Audio Link");
        if (material.GetInt("_AudioLinkGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            material.SetInt("AUDIOLINK", EditorGUILayout.Popup(AUDIOLINK.displayName, material.GetInt("AUDIOLINK"), new string[] {"DISABLED", "ENABLED GLOBAL", "ENABLED LOCAL"}));
            EditorGUI.BeginDisabledGroup(material.GetInt("AUDIOLINK") != 1);
            editor.ShaderProperty(_AudioLinkBand, MakeLabel(_AudioLinkBand));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawQueue(Material material)
    {
        MakeFoldout(material, "_QueueGUI", "Render Queue");
        if (material.GetInt("_QueueGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_UseCustomQueue, MakeLabel(_UseCustomQueue));
            EditorGUI.BeginDisabledGroup(material.GetInt("_UseCustomQueue") == 0);
            editor.ShaderProperty(_Queue, MakeLabel(_Queue));
            if (material.GetInt("_UseCustomQueue") == 1)
            {
                material.renderQueue = Mathf.Clamp(material.GetInt("_Queue"), 0, int.MaxValue); //2147483647
            }
            EditorGUI.EndDisabledGroup();
            if (material.GetInt("_UseCustomQueue") == 0)
            {
                material.renderQueue = -1;
                material.SetInt("_Queue", 4000);
            }
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawShake(Material material)
    {
        MakeFoldout(material, "_ShakeGUI", SHAKE, editor);
        if (material.GetInt("_ShakeGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_Totalamp, MakeLabel(_Totalamp));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_AmplitudeX, MakeLabel(_AmplitudeX));
            editor.ShaderProperty(_AmplitudeY, MakeLabel(_AmplitudeY));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_xsp, MakeLabel(_xsp));
            editor.ShaderProperty(_ysp, MakeLabel(_ysp));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_shroundness, MakeLabel(_shroundness));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.BeginDisabledGroup(material.GetInt("AUDIOLINK") != 2);
            editor.ShaderProperty(_ShakeAudioLinkBand, MakeLabel(_ShakeAudioLinkBand));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawMove(Material material)
    {
        MakeFoldout(material, "_MoveGUI", MOVE, editor);
        if (material.GetInt("_MoveGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_MoveX, MakeLabel(_MoveX));
            editor.ShaderProperty(_MoveY, MakeLabel(_MoveY));
            editor.ShaderProperty(_MoveXY, MakeLabel(_MoveXY));
            editor.ShaderProperty(_MoveYX, MakeLabel(_MoveYX));
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawRotator(Material material)
    {
        MakeFoldout(material, "_RotatorGUI", ROTATOR, editor);
        if (material.GetInt("_RotatorGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_Totalrotamp, MakeLabel(_Totalrotamp));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_rotampX, MakeLabel(_rotampX));
	        editor.ShaderProperty(_rotspeedX, MakeLabel(_rotspeedX));
	        editor.ShaderProperty(_rotoffsetX, MakeLabel(_rotoffsetX));
	        editor.ShaderProperty(_roffsetspeedX, MakeLabel(_roffsetspeedX));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
	        editor.ShaderProperty(_rotampY, MakeLabel(_rotampY));
	        editor.ShaderProperty(_rotspeedY, MakeLabel(_rotspeedY));
	        editor.ShaderProperty(_rotoffsetY, MakeLabel(_rotoffsetY));
	        editor.ShaderProperty(_roffsetspeedY, MakeLabel(_roffsetspeedY));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_rotamp, MakeLabel(_rotamp));
            editor.ShaderProperty(_rotspeed, MakeLabel(_rotspeed));
            editor.ShaderProperty(_rotoffset, MakeLabel(_rotoffset));
            editor.ShaderProperty(_roffsetspeed, MakeLabel(_roffsetspeed));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_rotMoveX, MakeLabel(_rotMoveX));
            editor.ShaderProperty(_rotMoveY, MakeLabel(_rotMoveY));
            editor.ShaderProperty(_rotMoveXY, MakeLabel(_rotMoveXY));
            editor.ShaderProperty(_rotMoveYX, MakeLabel(_rotMoveYX));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.BeginDisabledGroup(material.GetInt("AUDIOLINK") != 2);
            editor.ShaderProperty(_RotatorAudioLinkBand, MakeLabel(_RotatorAudioLinkBand));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawZoom(Material material)
    {
        MakeFoldoutEnum(material, "_ZoomGUI", ZOOM, editor);
        if (material.GetInt("_ZoomGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_Zoom, MakeLabel(_Zoom));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_ZoomSpeed, MakeLabel(_ZoomSpeed));
            EditorGUI.BeginDisabledGroup(material.GetFloat("_ZoomSpeed") == 0.0f);
            editor.ShaderProperty(_ZoomUpper, MakeLabel(_ZoomUpper));
            editor.ShaderProperty(_ZoomLower, MakeLabel(_ZoomLower));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.BeginDisabledGroup(material.GetInt("AUDIOLINK") != 2);
            editor.ShaderProperty(_ZoomAudioLinkBand, MakeLabel(_ZoomAudioLinkBand));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawFisheye(Material material)
    {
        MakeFoldout(material, "_FisheyeGUI", FISHEYE, editor);
        if (material.GetInt("_FisheyeGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_fZoom, MakeLabel(_fZoom));
            editor.ShaderProperty(_faspectfix, MakeLabel(_faspectfix));
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawKaleidoscope(Material material)
    {
        MakeFoldoutEnum(material, "_KaleidoscopeGUI", KDS, editor);
        if (material.GetInt("_KaleidoscopeGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_Kaleidoscope, MakeLabel(_Kaleidoscope));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_kSteps, MakeLabel(_kSteps));
            editor.ShaderProperty(_kAngle, MakeLabel(_kAngle));
            editor.ShaderProperty(_kScale, MakeLabel(_kScale));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_kSpeed1, MakeLabel(_kSpeed1));
            editor.ShaderProperty(_kSpeed2, MakeLabel(_kSpeed2));
            editor.ShaderProperty(_kOffset1, MakeLabel(_kOffset1));
            editor.ShaderProperty(_kOffset2, MakeLabel(_kOffset2));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_kGlow, MakeLabel(_kGlow));
            editor.ShaderProperty(_kGlowA, MakeLabel(_kGlowA));
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawShockwave(Material material)
    {
        MakeFoldoutEnum(material, "_ShockwaveGUI", SHOCKWAVE, editor);
        if (material.GetInt("_ShockwaveGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_swpow, MakeLabel(_swpow));
            editor.ShaderProperty(_swscale, MakeLabel(_swscale));
            editor.ShaderProperty(_swthickness, MakeLabel(_swthickness));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_swspeed, MakeLabel(_swspeed));
            editor.ShaderProperty(_swmo, MakeLabel(_swmo));
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawPixelation(Material material)
    {
        MakeFoldoutEnum(material, "_PixelationGUI", PIX, editor);
        if (material.GetInt("_PixelationGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_pix, MakeLabel(_pix));
            editor.ShaderProperty(PIXAUTO, MakeLabel(PIXAUTO));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_pixmasktype, MakeLabel(_pixmasktype));
            editor.ShaderProperty(_pixmaskvalue, MakeLabel(_pixmaskvalue));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.BeginDisabledGroup(material.GetInt("AUDIOLINK") != 2);
            editor.ShaderProperty(_PixAudioLinkBand, MakeLabel(_PixAudioLinkBand));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawSwirl(Material material)
    {
        MakeFoldout(material, "_SwirlGUI", SWIRL, editor);
        if (material.GetInt("_SwirlGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_srad, MakeLabel(_srad));
            editor.ShaderProperty(_sangle, MakeLabel(_sangle));
            editor.ShaderProperty(_sspeed, MakeLabel(_sspeed));
            editor.ShaderProperty(_sspeedtile, MakeLabel(_sspeedtile));
            editor.ShaderProperty(_sspeedoffset, MakeLabel(_sspeedoffset));
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawSharpDistortion(Material material)
    {
        MakeFoldoutEnum(material, "_SharpDistortionGUI", SHARPDISTORTION, editor);
        if (material.GetInt("_SharpDistortionGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_SharpDistortionTotal, MakeLabel(_SharpDistortionTotal));
            editor.ShaderProperty(_SharpDistortioncount, MakeLabel(_SharpDistortioncount));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_SharpDistortionR, MakeLabel(_SharpDistortionR));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_SharpDistortionX, MakeLabel(_SharpDistortionX));
            editor.ShaderProperty(_SharpDistortionY, MakeLabel(_SharpDistortionY));
            editor.ShaderProperty(_SharpDistortionRotate, MakeLabel(_SharpDistortionRotate));
            editor.ShaderProperty(_SharpDistortionRotateSpeed, MakeLabel(_SharpDistortionRotateSpeed));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.BeginDisabledGroup(material.GetInt("AUDIOLINK") != 2);
            editor.ShaderProperty(_SharpDistortionAudioLinkBand, MakeLabel(_SharpDistortionAudioLinkBand));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawWaves(Material material)
    {
        MakeFoldout(material, "_WavesGUI", WAVES, editor);
        if (material.GetInt("_WavesGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_Waves, MakeLabel(_Waves));
            editor.ShaderProperty(_WavesPower, MakeLabel(_WavesPower));
            editor.ShaderProperty(_WavesSpeed, MakeLabel(_WavesSpeed));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.BeginDisabledGroup(material.GetInt("AUDIOLINK") != 2);
            editor.ShaderProperty(_WavesAudioLinkBand, MakeLabel(_WavesAudioLinkBand));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawStretch(Material material)
    {
        MakeFoldout(material, "_StretchGUI", STRETCH, editor);
        if (material.GetInt("_StretchGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_stretchX, MakeLabel(_stretchX));
            editor.ShaderProperty(_stretchY, MakeLabel(_stretchY));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.BeginDisabledGroup(material.GetInt("AUDIOLINK") != 2);
            editor.ShaderProperty(_StretchAudioLinkBand, MakeLabel(_StretchAudioLinkBand));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawCompress(Material material)
    {
        MakeFoldout(material, "_CompressGUI", COMPRESS, editor);
        if (material.GetInt("_CompressGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_compressX, MakeLabel(_compressX));
            editor.ShaderProperty(_compressY, MakeLabel(_compressY));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.BeginDisabledGroup(material.GetInt("AUDIOLINK") != 2);
            editor.ShaderProperty(_CompressAudioLinkBand, MakeLabel(_CompressAudioLinkBand));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawDistortion(Material material)
    {
        MakeFoldoutEnum(material, "_WDGUI", WD, editor);
        if (material.GetInt("_WDGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_dpower, MakeLabel(_dpower));
            editor.ShaderProperty(_dtile, MakeLabel(_dtile));
            editor.ShaderProperty(_dspeed, MakeLabel(_dspeed));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.BeginDisabledGroup(material.GetInt("AUDIOLINK") != 2);
            editor.ShaderProperty(_DistortionAudioLinkBand, MakeLabel(_DistortionAudioLinkBand));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawGlitch(Material material)
    {
        MakeFoldoutEnum(material, "_GlitchGUI", GLITCH, editor);
        if (material.GetInt("_GlitchGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_gtotal, MakeLabel(_gtotal));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_gspeed, MakeLabel(_gspeed));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_gsamples, MakeLabel(_gsamples));
            editor.ShaderProperty(_blocksize, MakeLabel(_blocksize));
            editor.ShaderProperty(_glitchoffset, MakeLabel(_glitchoffset));
            editor.ShaderProperty(_coloffset, MakeLabel(_coloffset));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.BeginDisabledGroup(material.GetInt("AUDIOLINK") != 2);
            editor.ShaderProperty(_GlitchAudioLinkBand, MakeLabel(_GlitchAudioLinkBand));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawCutting(Material material)
    {
        MakeFoldout(material, "_CuttingGUI", CUTTING, editor);
        if (material.GetInt("_CuttingGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_CutTotal, MakeLabel(_CutTotal));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_CutTopX, MakeLabel(_CutTopX));
            editor.ShaderProperty(_CutBotX, MakeLabel(_CutBotX));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_CutTopN, MakeLabel(_CutTopN));
            editor.ShaderProperty(_CutBotN, MakeLabel(_CutBotN));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_CutRot, MakeLabel(_CutRot));
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawRGBOptions(Material material)
    {
        MakeFoldoutEnum(material, "_RGBSplitGUI", RGB, editor);
        if (material.GetInt("_RGBSplitGUI") >= 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_rgboffs, MakeLabel(_rgboffs));
            editor.ShaderProperty(_rgboffsR, MakeLabel(_rgboffsR));
            editor.ShaderProperty(_rgboffsB, MakeLabel(_rgboffsB));
            editor.ShaderProperty(_rgbrotspeed, MakeLabel(_rgbrotspeed));
            editor.ShaderProperty(_rgbrotoffs, MakeLabel(_rgbrotoffs));
            EditorGUILayout.EndVertical();

            EditorGUI.BeginDisabledGroup(material.GetInt("RGB") != 2);

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_TotalampRGB, MakeLabel(_TotalampRGB));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_TotalampR, MakeLabel(_TotalampR));
            editor.ShaderProperty(_AmplitudeRX, MakeLabel(_AmplitudeRX));
            editor.ShaderProperty(_AmplitudeRY, MakeLabel(_AmplitudeRY));
            editor.ShaderProperty(_xspR, MakeLabel(_xspR));
            editor.ShaderProperty(_yspR, MakeLabel(_yspR));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_TotalampG, MakeLabel(_TotalampG));
            editor.ShaderProperty(_AmplitudeGX, MakeLabel(_AmplitudeGX));
            editor.ShaderProperty(_AmplitudeGY, MakeLabel(_AmplitudeGY));
            editor.ShaderProperty(_xspG, MakeLabel(_xspG));
            editor.ShaderProperty(_yspG, MakeLabel(_yspG));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_TotalampB, MakeLabel(_TotalampB));
            editor.ShaderProperty(_AmplitudeBX, MakeLabel(_AmplitudeBX));
            editor.ShaderProperty(_AmplitudeBY, MakeLabel(_AmplitudeBY));
            editor.ShaderProperty(_xspB, MakeLabel(_xspB));
            editor.ShaderProperty(_yspB, MakeLabel(_yspB));
            EditorGUILayout.EndVertical();
            
            EditorGUI.EndDisabledGroup();
        }
    }

    private void DrawBlur(Material material)
    {
        MakeFoldoutEnum(material, "_BlursGUI", BLUR, editor);
        if (material.GetInt("_BlursGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(CHRBLUR, MakeLabel(CHRBLUR));
            if (material.GetInt("CENTERING") == 1)
            {
                editor.ShaderProperty(FALLOFFC, MakeLabel(FALLOFFC, "Falloff works only on game object center"));
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_samples, MakeLabel(_samples));
            EditorGUILayout.EndVertical();
            if (material.GetInt("_samples") >= 128)
            {
                EditorGUILayout.HelpBox("Many blur samples can cause fps drops!", MessageType.Warning, true);
            }

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_ds, MakeLabel(_ds));
            editor.ShaderProperty(_falloff, MakeLabel(_falloff));
            editor.ShaderProperty(_blurnoise, MakeLabel(_blurnoise));
            EditorGUILayout.EndVertical();

            EditorGUI.BeginDisabledGroup(material.GetInt("BLUR") == 2);
            
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_rotationds, MakeLabel(_rotationds));
            editor.ShaderProperty(_rotationsp, MakeLabel(_rotationsp));
            EditorGUILayout.EndVertical();

            EditorGUI.EndDisabledGroup();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_bluralpha, MakeLabel(_bluralpha));
            if (material.GetInt("CHRBLUR") == 1)
            {
                editor.ShaderProperty(_ChrColor1, MakeLabel(_ChrColor1));
                editor.ShaderProperty(_ChrColor2, MakeLabel(_ChrColor2));
                editor.ShaderProperty(_ChrColor3, MakeLabel(_ChrColor3));
            }
            else if (material.GetInt("CHRBLUR") == 2)
            {
                editor.ShaderProperty(_blurHSpeed, MakeLabel(_blurHSpeed));
                editor.ShaderProperty(_blurHOffset, MakeLabel(_blurHOffset));
                editor.ShaderProperty(_blurSM, MakeLabel(_blurSM));
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.BeginDisabledGroup(material.GetInt("AUDIOLINK") != 2);
            editor.ShaderProperty(_BlurDisplaceAudioLinkBand, MakeLabel(_BlurDisplaceAudioLinkBand));
            editor.ShaderProperty(_BlurAlphaAudioLinkBand, MakeLabel(_BlurAlphaAudioLinkBand));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawEdgeGlow(Material material)
    {
        MakeFoldout(material, "_EGGUI", EDGEGLOW, editor);
        if (material.GetInt("_EGGUI") == 1)
        {
            if (material.GetInt("UFPASS") != 1)
            {
                EdgeGlow(material);
            }
            else
            {
                EditorGUILayout.HelpBox("Moved to Rays", MessageType.Info, true);
            }
        }
    }

    private void EdgeGlow(Material material)
    {
        EditorGUILayout.BeginVertical(GUI.skin.box);
        editor.ShaderProperty(_egoffset, MakeLabel(_egoffset));
        editor.ShaderProperty(_egpow, MakeLabel(_egpow));
        editor.ShaderProperty(_egcol, MakeLabel(_egcol));
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical(GUI.skin.box);
        editor.ShaderProperty(_egbgcol, MakeLabel(_egbgcol));
        editor.ShaderProperty(_saturationeg, MakeLabel(_saturationeg));
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical(GUI.skin.box);
        editor.ShaderProperty(_egmasktype, MakeLabel(_egmasktype));
        editor.ShaderProperty(_egmaskvalue, MakeLabel(_egmaskvalue));
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical(GUI.skin.box);
        editor.ShaderProperty(EGUV, MakeLabel(EGUV));
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical(GUI.skin.box);
        editor.ShaderProperty(_egdistortion, MakeLabel(_egdistortion));
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical(GUI.skin.box);
        editor.ShaderProperty(EGHUE, MakeLabel(EGHUE));
        if (material.GetInt("EGHUE") == 1)
        {
            editor.ShaderProperty(_EGhue, MakeLabel(_EGhue));
            editor.ShaderProperty(_EGhueo, MakeLabel(_EGhueo));
            editor.ShaderProperty(_EGhuespeed, MakeLabel(_EGhuespeed));
        }
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical(GUI.skin.box);
        editor.ShaderProperty(EGMOVE, MakeLabel(EGMOVE));
        if (material.GetInt("EGMOVE") == 1)
        {
            editor.ShaderProperty(_egMoveX, MakeLabel(_egMoveX));
            editor.ShaderProperty(_egMoveY, MakeLabel(_egMoveY));
            editor.ShaderProperty(_egMoveXY, MakeLabel(_egMoveXY));
            editor.ShaderProperty(_egMoveYX, MakeLabel(_egMoveYX));
        }
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical(GUI.skin.box);
        editor.ShaderProperty(EGSHAKE, MakeLabel(EGSHAKE));
        if (material.GetInt("EGSHAKE") == 1)
        {
            editor.ShaderProperty(_egAmplitudeX, MakeLabel(_egAmplitudeX));
            editor.ShaderProperty(_egAmplitudeY, MakeLabel(_egAmplitudeY));
            editor.ShaderProperty(_egxsp, MakeLabel(_egxsp));
            editor.ShaderProperty(_egysp, MakeLabel(_egysp));
            editor.ShaderProperty(_egTotalamp, MakeLabel(_egTotalamp));
        }
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical(GUI.skin.box);
        editor.ShaderProperty(EGFISHEYE, MakeLabel(EGFISHEYE));
        if (material.GetInt("EGFISHEYE") == 1)
        {
            editor.ShaderProperty(_egfZoom, MakeLabel(_egfZoom));
            editor.ShaderProperty(_egfaspectfix, MakeLabel(_egfaspectfix));
        }
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical(GUI.skin.box);
        editor.ShaderProperty(EGDISTORTION, MakeLabel(EGDISTORTION));
        if (material.GetInt("EGDISTORTION") == 1)
        {
            editor.ShaderProperty(_egdpower, MakeLabel(_egdpower));
            editor.ShaderProperty(_egdtile, MakeLabel(_egdtile));
            editor.ShaderProperty(_egdspeed, MakeLabel(_egdspeed));
        }
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical(GUI.skin.box);
        EditorGUI.BeginDisabledGroup(material.GetInt("AUDIOLINK") != 2);
        editor.ShaderProperty(_EdgeGlowAudioLinkBand, MakeLabel(_EdgeGlowAudioLinkBand));
        EditorGUI.EndDisabledGroup();
        EditorGUILayout.EndVertical();
    }

    private void DrawRays(Material material)
    {
        MakeFoldoutEnum(material, "_RaysGUI", UFPASS, editor);
        if (material.GetInt("_RaysGUI") == 1)
        {
            EditorGUILayout.HelpBox("1. Enable Radial Blur for make effect working!", MessageType.Info, true);
            EditorGUILayout.HelpBox("2. Blur displace should be 1.0 for better result!", MessageType.Info, true);
            if (material.GetInt("UFPASS") == 2)
            {
                EditorGUILayout.BeginVertical(GUI.skin.box);
                editor.ShaderProperty(_rays, MakeLabel(_rays));
                editor.ShaderProperty(_rayscontrast, MakeLabel(_rayscontrast));
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical(GUI.skin.box);
                EditorGUI.BeginDisabledGroup(material.GetInt("AUDIOLINK") != 2);
                editor.ShaderProperty(_RaysAudioLinkBand, MakeLabel(_RaysAudioLinkBand));
                EditorGUI.EndDisabledGroup();
                EditorGUILayout.EndVertical();
            }
            else if (material.GetInt("UFPASS") == 1)
            {
                material.SetInt("EDGEGLOW", 1);
                EdgeGlow(material);
            }
        }
    }

    private void DrawFog(Material material)
    {
        MakeFoldoutEnum(material, "_FogGUI", FOGM, editor);
        if (material.GetInt("_FogGUI") == 1)
        {
            EditorGUILayout.HelpBox("Fog required Depth Light Prefab on scene", MessageType.Warning, true);
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_FogColor, MakeLabel(_FogColor));
            editor.ShaderProperty(_FogAlpha, MakeLabel(_FogAlpha));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_FogOffset, MakeLabel(_FogOffset));
            editor.ShaderProperty(_FogSmooth, MakeLabel(_FogSmooth));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(DFOG, MakeLabel(DFOG));
            EditorGUI.BeginDisabledGroup(material.GetInt("DFOG") != 1);
            editor.ShaderProperty(_DFogTile, MakeLabel(_DFogTile));
            editor.ShaderProperty(_FogSpeed, MakeLabel(_FogSpeed));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.BeginDisabledGroup(material.GetInt("AUDIOLINK") != 2);
            editor.ShaderProperty(_FogAudioLinkBand, MakeLabel(_FogAudioLinkBand));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawHUE(Material material)
    {
        MakeFoldoutEnum(material, "_HueGUI", HUE, editor);
        if (material.GetInt("_HueGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_HUEa, MakeLabel(_HUEa));
            editor.ShaderProperty(_ofsorc, MakeLabel(_ofsorc));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_TileHue, MakeLabel(_TileHue));
            editor.ShaderProperty(_HUE, MakeLabel(_HUE));
            editor.ShaderProperty(_HUESpeed, MakeLabel(_HUESpeed));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(OBC, MakeLabel(OBC));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.BeginDisabledGroup(material.GetInt("AUDIOLINK") != 2);
            editor.ShaderProperty(_HUEAudioLinkBand, MakeLabel(_HUEAudioLinkBand));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawHSVcs(Material material)
    {
        MakeFoldout(material, "_HSVcsGUI", COLSEL, editor);
        if (material.GetInt("_HSVcsGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_Colsela, MakeLabel(_Colsela));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_TargetColor, MakeLabel(_TargetColor));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_HueRange, MakeLabel(_HueRange));
            editor.ShaderProperty(_SaturationRange, MakeLabel(_SaturationRange));
            editor.ShaderProperty(_LightnessRange, MakeLabel(_LightnessRange));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_HueSmoothRange, MakeLabel(_HueSmoothRange));
            editor.ShaderProperty(_SaturationSmoothRange, MakeLabel(_SaturationSmoothRange));
            editor.ShaderProperty(_LightnessSmoothRange, MakeLabel(_LightnessSmoothRange));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.BeginDisabledGroup(material.GetInt("AUDIOLINK") != 2);
            editor.ShaderProperty(_HSVColorSelectionAudioLinkBand, MakeLabel(_HSVColorSelectionAudioLinkBand));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawColorGrading(Material material)
    {
        MakeFoldout(material, "_CGGUI", COLOR_GRADING, editor);
        if (material.GetInt("_CGGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_Colorm, MakeLabel(_Colorm));
            editor.ShaderProperty(_brightness, MakeLabel(_brightness ));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_Colort, MakeLabel(_Colort));
            editor.ShaderProperty(_transitiontoColor, MakeLabel(_transitiontoColor));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_HDR, MakeLabel(_HDR));
            editor.ShaderProperty(_HDRMultiplyer, MakeLabel(_HDRMultiplyer));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_contrast, MakeLabel(_contrast));
            editor.ShaderProperty(_saturation, MakeLabel(_saturation));
            editor.ShaderProperty(_invert, MakeLabel(_invert));
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawScreenSpaceTex(Material material)
    {
        MakeFoldoutEnum(material, "_SSTGUI", SST, editor);
        if (material.GetInt("_SSTGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            DrawTexture(_ScreenTex, _Tint);
            editor.ShaderProperty(_TexAlpha, MakeLabel(_TexAlpha));
            editor.ShaderProperty(_tblur, MakeLabel(_tblur));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(WM, MakeLabel(WM));
            editor.ShaderProperty(_Width, MakeLabel(_Width));
            editor.ShaderProperty(_Height, MakeLabel(_Height));
            editor.ShaderProperty(_Scale, MakeLabel(_Scale));
            editor.ShaderProperty(_LR, MakeLabel(_LR));
            editor.ShaderProperty(_UD, MakeLabel(_UD));
            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_trotX, MakeLabel(_trotX));
            editor.ShaderProperty(_trotY, MakeLabel(_trotY));
            editor.ShaderProperty(_trotZ, MakeLabel(_trotZ));
            editor.ShaderProperty(_trfov, MakeLabel(_trfov));
            editor.ShaderProperty(_trLR, MakeLabel(_trLR));
            editor.ShaderProperty(_trUD, MakeLabel(_trUD));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(SSG, MakeLabel(SSG));
            if (material.GetInt("SSG") == 1)
            {
                editor.ShaderProperty(_Columns, MakeLabel(_Columns));
                editor.ShaderProperty(_Rows, MakeLabel(_Rows));
                editor.ShaderProperty(_fps, MakeLabel(_fps));
                editor.ShaderProperty(_Moffset, MakeLabel(_Moffset));
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.BeginDisabledGroup(material.GetInt("AUDIOLINK") != 2);
            editor.ShaderProperty(_ScreenSpaceImageAudioLinkBand, MakeLabel(_ScreenSpaceImageAudioLinkBand));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawSpeedEffect(Material material)
    {
        MakeFoldout(material, "_SpeedEffectGUI", SPEEDEFFECT, editor);
        if (material.GetInt("_SpeedEffectGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(SPEEDEFFECTUV, MakeLabel(SPEEDEFFECTUV));
            editor.ShaderProperty(_SpeedEffectRounding, MakeLabel(_SpeedEffectRounding));
            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_SpeedEffectColor, MakeLabel(_SpeedEffectColor));
            editor.ShaderProperty(_SpeedEffectAlpha, MakeLabel(_SpeedEffectAlpha));
            editor.ShaderProperty(_SpeedEffectFade, MakeLabel(_SpeedEffectFade));
            editor.ShaderProperty(_SpeedEffectFadeRange, MakeLabel(_SpeedEffectFadeRange));
            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_SpeedEffectManualOffset, MakeLabel(_SpeedEffectManualOffset));
            editor.ShaderProperty(_SpeedEffectSpeed, MakeLabel(_SpeedEffectSpeed));
            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_SpeedEffectLength, MakeLabel(_SpeedEffectLength));
            editor.ShaderProperty(_SpeedEffectTile, MakeLabel(_SpeedEffectTile));
            editor.ShaderProperty(_SpeedEffectLineWidth, MakeLabel(_SpeedEffectLineWidth));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.BeginDisabledGroup(material.GetInt("AUDIOLINK") != 2);
            editor.ShaderProperty(_SpeedEffectAudioLinkBand, MakeLabel(_SpeedEffectAudioLinkBand));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawFilmGrain(Material material)
    {
        MakeFoldout(material, "_FilmGrainGUI", FILMGRAIN, editor);
        if (material.GetInt("_FilmGrainGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(FILMGRAINUV, MakeLabel(FILMGRAINUV));
            editor.ShaderProperty(_fgcol, MakeLabel(_fgcol));
            editor.ShaderProperty(_fga, MakeLabel(_fga));
            editor.ShaderProperty(_fglinesp , MakeLabel(_fglinesp ));
            editor.ShaderProperty(_fgslinesp, MakeLabel(_fgslinesp));
            editor.ShaderProperty(_fgnfp, MakeLabel(_fgnfp));
            editor.ShaderProperty(_fgrt, MakeLabel(_fgrt));
            editor.ShaderProperty(_fgt, MakeLabel(_fgt));
            editor.ShaderProperty(_fgds, MakeLabel(_fgds));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.BeginDisabledGroup(material.GetInt("AUDIOLINK") != 2);
            editor.ShaderProperty(_FilmGrainAudioLinkBand, MakeLabel(_FilmGrainAudioLinkBand));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawNoise(Material material)
    {
        MakeFoldoutEnum(material, "_NoiseGUI", NOISE, editor);
        if (material.GetInt("_NoiseGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_Noise, MakeLabel(_Noise));
            editor.ShaderProperty(_Noisep, MakeLabel(_Noisep));
            editor.ShaderProperty(_Noisecol, MakeLabel(_Noisecol));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(NOISEB, MakeLabel(NOISEB));

            EditorGUI.BeginDisabledGroup(material.GetInt("NOISEB") != 2);
            editor.ShaderProperty(_Noisebl, MakeLabel(_Noisebl));
            editor.ShaderProperty(_Noiseblsp, MakeLabel(_Noiseblsp));
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.BeginDisabledGroup(material.GetInt("AUDIOLINK") != 2);
            editor.ShaderProperty(_NoiseAudioLinkBand, MakeLabel(_NoiseAudioLinkBand));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawVignette(Material material)
    {
        MakeFoldout(material, "_VignetteGUI", VIGNETTE, editor);
        if (material.GetInt("_VignetteGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_Vignette, MakeLabel(_Vignette));
            editor.ShaderProperty(_Vignettesmtf, MakeLabel(_Vignettesmtf));
            editor.ShaderProperty(_Vignetter, MakeLabel(_Vignetter));
            editor.ShaderProperty(_Vignetteround, MakeLabel(_Vignetteround));
            EditorGUILayout.EndVertical();
            
            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.BeginDisabledGroup(material.GetFloat("_Vignettesmtf") == 0);
            editor.ShaderProperty(_Vignettebl, MakeLabel(_Vignettebl));
            editor.ShaderProperty(_Vignetteblsp, MakeLabel(_Vignetteblsp));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(VIGNETTEUV, MakeLabel(VIGNETTEUV));
            EditorGUILayout.EndVertical();
            
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(VGBGM, MakeLabel(VGBGM));
            if (material.GetInt("VGBGM") == 1)
            {
                DrawTexture(_VGTScreenTex, _Vignettecol);
                editor.ShaderProperty(_VGTtblur, MakeLabel(_VGTtblur));
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical(GUI.skin.box);
                editor.ShaderProperty(VGTWM, MakeLabel(VGTWM));
                editor.ShaderProperty(_VGTWidth, MakeLabel(_VGTWidth));
                editor.ShaderProperty(_VGTHeight, MakeLabel(_VGTHeight));
                editor.ShaderProperty(_VGTScale, MakeLabel(_VGTScale));
                editor.ShaderProperty(_VGTLR, MakeLabel(_VGTLR));
                editor.ShaderProperty(_VGTUD, MakeLabel(_VGTUD));
                editor.ShaderProperty(_VGTtrotX, MakeLabel(_VGTtrotX));
                editor.ShaderProperty(_VGTtrotY, MakeLabel(_VGTtrotY));
                editor.ShaderProperty(_VGTtrotZ, MakeLabel(_VGTtrotZ));
                editor.ShaderProperty(_VGTtrotfov, MakeLabel(_VGTtrotfov));
                editor.ShaderProperty(_VGTtrotLR, MakeLabel(_VGTtrotLR));
                editor.ShaderProperty(_VGTtrotUD, MakeLabel(_VGTtrotUD));
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical(GUI.skin.box);
                editor.ShaderProperty(VGG, MakeLabel(VGG));
                if (material.GetInt("VGG") == 1)
                {
                    editor.ShaderProperty(_VGGColumns, MakeLabel(_VGGColumns));
                    editor.ShaderProperty(_VGGRows, MakeLabel(_VGGRows));
                    editor.ShaderProperty(_VGGfps, MakeLabel(_VGGfps));
                    editor.ShaderProperty(_VGGMoffset, MakeLabel(_VGGMoffset));
                }
            }
            else
            {
                editor.ShaderProperty(_Vignettecol, MakeLabel(_Vignettecol));
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.BeginDisabledGroup(material.GetInt("AUDIOLINK") != 2);
            editor.ShaderProperty(_VignetteAudioLinkBand, MakeLabel(_VignetteAudioLinkBand));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawBars(Material material)
    {
        MakeFoldoutEnum(material, "_BarsGUI", BB, editor);
        if (material.GetInt("_BarsGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_barsx, MakeLabel(_barsx));
            editor.ShaderProperty(_barsy, MakeLabel(_barsy));
            if (material.GetInt("BB") == 2)
            {
                editor.ShaderProperty(_smbx, MakeLabel(_smbx));
                editor.ShaderProperty(_smby, MakeLabel(_smby));
            }
            else
            {
                editor.ShaderProperty(_smb, MakeLabel(_smb));
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(BBUV, MakeLabel(BBUV));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(BBGM, MakeLabel(BBGM));
            if (material.GetInt("BBGM") == 1)
            {
                DrawTexture(_BBTScreenTex, _bbcol);
                editor.ShaderProperty(_BBTtblur, MakeLabel(_BBTtblur));
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical(GUI.skin.box);
                editor.ShaderProperty(BBTWM, MakeLabel(BBTWM));
                editor.ShaderProperty(_BBTWidth, MakeLabel(_BBTWidth));
                editor.ShaderProperty(_BBTHeight, MakeLabel(_BBTHeight));
                editor.ShaderProperty(_BBTScale, MakeLabel(_BBTScale));
                editor.ShaderProperty(_BBTLR, MakeLabel(_BBTLR));
                editor.ShaderProperty(_BBTUD, MakeLabel(_BBTUD));
                EditorGUILayout.EndVertical();
                EditorGUILayout.BeginVertical(GUI.skin.box);
                editor.ShaderProperty(_BBTtrotX, MakeLabel(_BBTtrotX));
                editor.ShaderProperty(_BBTtrotY, MakeLabel(_BBTtrotY));
                editor.ShaderProperty(_BBTtrotZ, MakeLabel(_BBTtrotZ));
                editor.ShaderProperty(_BBTtrotfov, MakeLabel(_BBTtrotfov));
                editor.ShaderProperty(_BBTtrotLR, MakeLabel(_BBTtrotLR));
                editor.ShaderProperty(_BBTtrotUD, MakeLabel(_BBTtrotUD));
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical(GUI.skin.box);
                editor.ShaderProperty(BBG, MakeLabel(BBG)); 
                if (material.GetInt("BBG") == 1)
                {
                    editor.ShaderProperty(_BBGColumns, MakeLabel(_BBGColumns));
                    editor.ShaderProperty(_BBGRows, MakeLabel(_BBGRows));
                    editor.ShaderProperty(_BBGfps, MakeLabel(_BBGfps));
                    editor.ShaderProperty(_BBGMoffset, MakeLabel(_BBGMoffset));
                }
            }
            else
            {
                editor.ShaderProperty(_bbcol, MakeLabel(_bbcol));
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(BBR, MakeLabel(BBR));
            EditorGUILayout.EndVertical();
            if (material.GetInt("BBR") == 1)
            {
                EditorGUILayout.BeginVertical(GUI.skin.box);
                editor.ShaderProperty(_BTotalrotamp, MakeLabel(_BTotalrotamp));
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical(GUI.skin.box);
                editor.ShaderProperty(_BrotampX, MakeLabel(_BrotampX));
                editor.ShaderProperty(_BrotspeedX, MakeLabel(_BrotspeedX));
                editor.ShaderProperty(_BrotoffsetX, MakeLabel(_BrotoffsetX));
                editor.ShaderProperty(_BroffsetspeedX, MakeLabel(_BroffsetspeedX));
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical(GUI.skin.box);
                editor.ShaderProperty(_BrotampY, MakeLabel(_BrotampY));
                editor.ShaderProperty(_BrotspeedY, MakeLabel(_BrotspeedY));
                editor.ShaderProperty(_BrotoffsetY, MakeLabel(_BrotoffsetY));
                editor.ShaderProperty(_BroffsetspeedY, MakeLabel(_BroffsetspeedY));
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical(GUI.skin.box);
                editor.ShaderProperty(_BrotampZ, MakeLabel(_BrotampZ));
                editor.ShaderProperty(_BrotspeedZ, MakeLabel(_BrotspeedZ));
                editor.ShaderProperty(_BrotoffsetZ, MakeLabel(_BrotoffsetZ));
                editor.ShaderProperty(_BroffsetspeedZ, MakeLabel(_BroffsetspeedZ));
                EditorGUILayout.EndVertical();
            }

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.BeginDisabledGroup(material.GetInt("AUDIOLINK") != 2);
            editor.ShaderProperty(_BarsAudioLinkBand, MakeLabel(_BarsAudioLinkBand));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawLines(Material material)
    {
        MakeFoldout(material, "_LinesGUI", LINES, editor);
        if (material.GetInt("_LinesGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(LINESUV, MakeLabel(LINESUV));
            editor.ShaderProperty(_lines, MakeLabel(_lines));
            editor.ShaderProperty(_linesc, MakeLabel(_linesc));
            editor.ShaderProperty(_liness, MakeLabel(_liness));
            editor.ShaderProperty(_linesr, MakeLabel(_linesr));
            editor.ShaderProperty(_linescol, MakeLabel(_linescol));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.BeginDisabledGroup(material.GetInt("AUDIOLINK") != 2);
            editor.ShaderProperty(_LinesAudioLinkBand, MakeLabel(_LinesAudioLinkBand));
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();
        }
    }

    private void DrawDither(Material material)
    {
        MakeFoldoutEnum(material, "_DitherGUI", DITHER, editor);
        if (material.GetInt("_DitherGUI") == 1)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            editor.ShaderProperty(_ditherluma, MakeLabel(_ditherluma));
            editor.ShaderProperty(_Dither, MakeLabel(_Dither));
            EditorGUILayout.EndVertical();
        }
    }

    private void PrepareGUI(MaterialProperty[] properties, out Material material, out Shader shader)
    {
        material = editor.target as Material;
        shader = material.shader;

        //Thanks Xiexe
        foreach (var property in GetType().GetFields(bindingFlags))
        {
            if (property.FieldType == typeof(MaterialProperty))
            {
                try { property.SetValue(this, FindProperty(property.Name, properties)); } catch { }
            }
        }
        //
        SetKeywords(material);
        material.SetInt("E", 1);
    }

    static void SetKeywords(Material material)
    {
        SetKeyword(material, "GRAIN", material.GetInt("AUDIOLINK") > 0);
    }

    static void SetKeyword(Material m, string k, bool s)
    {
        if (s)
            m.EnableKeyword(k);
        else
            m.DisableKeyword(k);
    }

    private void DrawHeader(string header)
    {
        GUILayout.Label(header, new GUIStyle { font = VrchatFont, fontSize = 18, fontStyle = FontStyle.Italic, alignment = TextAnchor.MiddleCenter });
    }

    private void DrawTexture(MaterialProperty tex, MaterialProperty prop = null)
    {
        GUILayout.Space(3);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(2);
        editor.TexturePropertySingleLine(MakeLabel(tex), tex, prop);
        EditorGUILayout.EndHorizontal();
    }

    private void DrawBanner(string MainText, string OtherText, string URL)
    {
        GUIStyle OtherStyle = new GUIStyle { font = VrchatFont, alignment = TextAnchor.LowerRight, fontSize = 12, padding = new RectOffset(0, 1, 0, 1) };
        OtherStyle.normal.textColor = new Color(0.9f, 0.9f, 0.9f);

        GUIStyle MainStyle = new GUIStyle { font = VrchatFont, alignment = TextAnchor.MiddleCenter, fontSize = 18, padding = new RectOffset(0, 1, 0, 1) };
        MainStyle.normal.textColor = new Color(1.0f, 1.0f, 1.0f);

        EditorGUILayout.BeginVertical("GroupBox");
        Rect BannerRect = GUILayoutUtility.GetRect(0, int.MaxValue, 35, 35);
        EditorGUI.DrawRect(BannerRect, new Color(0.0f, 0.0f, 0.0f));
        EditorGUI.LabelField(BannerRect, OtherText, OtherStyle);
        EditorGUI.LabelField(BannerRect, MainText, MainStyle);
        if (GUI.Button(BannerRect, string.Empty, new GUIStyle()))
        {
            Application.OpenURL(URL);
        }
        EditorGUILayout.EndVertical();
    }

    private static GUIContent MakeLabel(MaterialProperty property, string tip = null)
    {
        GUIContent staticLabel = new GUIContent { text = property.displayName, tooltip = "Property name is " + property.name + (tip != null ? "\n" + tip : string.Empty) };
        return staticLabel;
    }

    private static Rect TogglePos(Rect rect,  MaterialProperty property)
    {
        Rect TogglePos = EditorGUILayout.GetControlRect(true, 0);
        TogglePos.x = rect.xMax - 19;
        TogglePos.height = MaterialEditor.GetDefaultPropertyHeight(property);
        TogglePos.width = 15;
        return TogglePos;
    }

    private static Rect EnumPos(Rect rect, MaterialProperty property)
    {
        Rect EnumPos = EditorGUILayout.GetControlRect(true, 0);
        EnumPos.y = rect.yMin + 2;
        EnumPos.x = rect.xMax - 102;
        EnumPos.height = MaterialEditor.GetDefaultPropertyHeight(property);
        EnumPos.width = 100;
        return EnumPos;
    }

    private void MakeFoldout(Material material, string foldout, MaterialProperty property, MaterialEditor editor) //Foldout with interactable toggle
    {
        Rect Field = EditorGUILayout.BeginHorizontal("Button");
        GUILayout.Space(10);
        material.SetInt(foldout, EditorGUILayout.Foldout(material.GetInt(foldout) > 0, property.displayName, true) ? 1 : 0);
        editor.ShaderProperty(TogglePos(Field, property), property, string.Empty);
        EditorGUILayout.EndHorizontal();
    }

    private void MakeFoldoutEnum(Material material, string foldout, MaterialProperty property, MaterialEditor editor) //Foldout with Enum
    {
        Rect Field = EditorGUILayout.BeginHorizontal("Button");
        GUILayout.Space(10);
        material.SetInt(foldout, EditorGUILayout.Foldout(material.GetInt(foldout) > 0, property.displayName, true) ? 1 : 0);
        editor.ShaderProperty(EnumPos(Field, property), property, string.Empty);
        EditorGUILayout.EndHorizontal();
    }

    private void MakeFoldout(Material material, string foldout, string name) //Foldout
    {
        EditorGUILayout.BeginHorizontal("Button");
        GUILayout.Space(10);
        material.SetInt(foldout, EditorGUILayout.Foldout(material.GetInt(foldout) > 0, name, true) ? 1 : 0);
        EditorGUILayout.EndHorizontal();
    }

    private void DrawCredits()
    {
        GUIStyle TextStyle = new GUIStyle { font = VrchatFont, fontSize = 15, fontStyle = FontStyle.Italic };

        EditorGUILayout.BeginVertical("GroupBox");
        GUILayout.Label("If you did not get this", TextStyle);
        GUILayout.Space(2);
        GUILayout.Label("shader via patreon subscription", TextStyle);
        GUILayout.Space(2);
        GUILayout.Label("you're not allowed to have it", TextStyle);
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical("GroupBox");
        GUILayout.Label("Shader by:", TextStyle);
        GUILayout.Space(2);
        GUILayout.Label("Doppelgänger#8376", TextStyle);
        GUILayout.Space(6);
        GUILayout.Label("Thanks for help with editor:", TextStyle);
        GUILayout.Space(2);
        GUILayout.Label("Bkp#8336", TextStyle);
        EditorGUILayout.EndVertical();
    }

    void CacheRenderersUsingThisMaterial(Material material)
    {
        m_RenderersUsingThisMaterial.Clear();
        ParticleSystemRenderer[] renderers = Resources.FindObjectsOfTypeAll(typeof(ParticleSystemRenderer)) as ParticleSystemRenderer[];
        foreach (ParticleSystemRenderer renderer in renderers)
        {
            var go = renderer.gameObject;
            if (go.hideFlags == HideFlags.NotEditable || go.hideFlags == HideFlags.HideAndDontSave)
                continue;
            if (renderer.sharedMaterial == material)
                m_RenderersUsingThisMaterial.Add(renderer);
        }
    }

    void DoConfigureRendererArea(Material material)
    {
        List<ParticleSystemVertexStream> streams = new List<ParticleSystemVertexStream>();
        
        streams.Add(ParticleSystemVertexStream.Position);
        streams.Add(ParticleSystemVertexStream.Color);
        streams.Add(ParticleSystemVertexStream.Center);

        if (GUILayout.Button(EditorGUIUtility.TrTextContent("Configure Particle Systems Renderer"), EditorStyles.miniButton))
        {
            Undo.RecordObjects(m_RenderersUsingThisMaterial.Where(r => r != null).ToArray(), L10n.Tr("Configure Particle Systems Renderer from material"));
            foreach (ParticleSystemRenderer renderer in m_RenderersUsingThisMaterial)
            {
                if (renderer != null)
                {
                    renderer.SetActiveVertexStreams(streams);
                    renderer.renderMode = ParticleSystemRenderMode.Mesh;
                    renderer.mesh = Resources.GetBuiltinResource<Mesh>("Cube.fbx");
                }
            }
        }

        string Errors = string.Empty;
        List<ParticleSystemVertexStream> rendererStreams = new List<ParticleSystemVertexStream>();
        foreach (ParticleSystemRenderer renderer in m_RenderersUsingThisMaterial)
        {
            if (renderer != null)
            {
                renderer.GetActiveVertexStreams(rendererStreams);
                bool streamsValid = rendererStreams.SequenceEqual(streams);
                bool rendererModeValid = renderer.renderMode == ParticleSystemRenderMode.Mesh;
                bool meshValid = renderer.mesh == Resources.GetBuiltinResource<Mesh>("Cube.fbx");
                if (!streamsValid || !rendererModeValid || !meshValid)
                    Errors += renderer.name + "\n";
            }
        }
        if (Errors != string.Empty)
        {
            EditorGUILayout.HelpBox("The following Particle Systems using this material with incorrect Renderer:\n" + Errors + "Use the Configure Particle Systems Renderer to fix this", MessageType.Error, true);
        }
    }
}
#endif