Decompiled source of ShaderPlayground v0.5.2

plugins/YenRex/ShaderPlayground.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using PurrLobby;
using PurrNet;
using PurrNet.Packing;
using PurrNet.Transports;
using PurrNet.Utils;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: InternalsVisibleTo("ShaderPlayground.Tests")]
[assembly: AssemblyCompany("ShaderPlayground")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.5.2.0")]
[assembly: AssemblyInformationalVersion("0.5.2")]
[assembly: AssemblyProduct("ShaderPlayground")]
[assembly: AssemblyTitle("ShaderPlayground")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.5.2.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace ShaderPlayground
{
	internal static class HostClientSyncPolicy
	{
		internal enum ClientHandshakeState
		{
			Disconnected,
			AwaitHelloAck,
			AwaitSnapshot,
			Synced,
			Stale
		}

		internal enum SnapshotValidationResult
		{
			Apply,
			Duplicate,
			Stale,
			Gap,
			SessionMismatch,
			Invalid
		}

		internal const float HostKeepaliveIntervalSeconds = 7f;

		internal const float HostQuietPeriodAfterCommitSeconds = 3f;

		internal const float HostRequestMinIntervalSeconds = 0.75f;

		internal const float ClientHelloRetryInitialSeconds = 0.9f;

		internal const float ClientHelloRetryMaxSeconds = 6f;

		internal const float ClientStateRequestIntervalSeconds = 2.25f;

		internal const float ClientStaleAfterSeconds = 12f;

		internal static bool ShouldHostSendKeepalive(bool isHost, float now, float nextKeepaliveAt, float lastCommitAt, out float nextAt)
		{
			nextAt = nextKeepaliveAt;
			if (!isHost || now < nextKeepaliveAt)
			{
				return false;
			}
			nextAt = now + 7f;
			if (lastCommitAt > 0f)
			{
				return !(now - lastCommitAt < 3f);
			}
			return true;
		}

		internal static bool ShouldClientSendHello(ClientHandshakeState state, float now, float nextHelloAt)
		{
			if (state == ClientHandshakeState.AwaitHelloAck)
			{
				return now >= nextHelloAt;
			}
			return false;
		}

		internal static bool ShouldClientSendStateRequest(ClientHandshakeState state, float now, float nextRequestAt)
		{
			if (state == ClientHandshakeState.AwaitSnapshot || state == ClientHandshakeState.Stale)
			{
				return now >= nextRequestAt;
			}
			return false;
		}

		internal static bool ShouldMarkClientStale(ClientHandshakeState state, float now, float lastSnapshotAcceptedAt)
		{
			if (state == ClientHandshakeState.Synced && lastSnapshotAcceptedAt > 0f)
			{
				return now - lastSnapshotAcceptedAt >= 12f;
			}
			return false;
		}

		internal static float NextHelloRetryInterval(float current)
		{
			if (current <= 0f)
			{
				return 0.9f;
			}
			return Math.Min(6f, Math.Max(0.9f, current * 1.7f));
		}

		internal static bool ShouldAllowHostRequestResponse(ref float lastHandledAt, float now)
		{
			if (lastHandledAt > 0f && now - lastHandledAt < 0.75f)
			{
				return false;
			}
			lastHandledAt = now;
			return true;
		}

		internal static SnapshotValidationResult ClassifySnapshot(string sessionEpoch, long revision, string stateHash, string acceptedSessionEpoch, long acceptedRevision, string acceptedStateHash)
		{
			if (string.IsNullOrWhiteSpace(sessionEpoch) || string.IsNullOrWhiteSpace(stateHash) || revision < 0)
			{
				return SnapshotValidationResult.Invalid;
			}
			if (!string.IsNullOrEmpty(acceptedSessionEpoch) && !string.Equals(sessionEpoch, acceptedSessionEpoch, StringComparison.Ordinal))
			{
				return SnapshotValidationResult.SessionMismatch;
			}
			if (acceptedRevision >= 0)
			{
				if (revision == acceptedRevision && string.Equals(stateHash, acceptedStateHash, StringComparison.Ordinal))
				{
					return SnapshotValidationResult.Duplicate;
				}
				if (revision <= acceptedRevision)
				{
					return SnapshotValidationResult.Stale;
				}
				if (revision > acceptedRevision + 1)
				{
					return SnapshotValidationResult.Gap;
				}
			}
			return SnapshotValidationResult.Apply;
		}
	}
	[BepInPlugin("io.damon.ontogether.shaderplayground", "ShaderPlayground", "0.5.2")]
	[BepInProcess("OnTogether.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		private enum UiTab
		{
			Core,
			Effects,
			Experimental,
			World,
			AdvancedColor,
			Quality,
			Presets,
			Tools
		}

		private enum PresetKind
		{
			Clean,
			Noir,
			Stormfront,
			NightTime,
			DreamyStyle,
			PitchBlack
		}

		private enum WeatherMood
		{
			Clear,
			Golden,
			Overcast,
			Storm,
			Dream
		}

		private enum Msg : byte
		{
			Hello = 1,
			HelloAck,
			StateRequest,
			StateSnapshot
		}

		[Serializable]
		private sealed class NetworkPayloadV1
		{
			public byte[] Data = Array.Empty<byte>();
		}

		[Serializable]
		private sealed class HelloV2
		{
			public int ProtocolVersion;

			public ulong ClientPlayerId;

			public string ClientNonce = string.Empty;

			public int CapabilityMask;

			public string PluginVersion = string.Empty;

			public string Reason = string.Empty;
		}

		[Serializable]
		private sealed class HelloAckV2
		{
			public int ProtocolVersion;

			public string ClientNonce = string.Empty;

			public string SessionEpoch = string.Empty;

			public ulong HostPlayerId;

			public int HostCapabilityMask;

			public long CurrentRevision;

			public string StateHash = string.Empty;

			public string SentAtUtc = string.Empty;
		}

		[Serializable]
		private sealed class StateRequestV2
		{
			public int ProtocolVersion;

			public string SessionEpoch = string.Empty;

			public long WantRevision;

			public string Reason = string.Empty;
		}

		[Serializable]
		private sealed class StateSnapshotV2
		{
			public int ProtocolVersion;

			public string SessionEpoch = string.Empty;

			public long Revision;

			public string StateHash = string.Empty;

			public ProfileStateV1? State;

			public ProfileStateV1? Profile;

			public ProfileStateV1? ProfileState;

			public string StateJson = string.Empty;

			public string ProfileJson = string.Empty;

			public string Reason = string.Empty;

			public string SentAtUtc = string.Empty;
		}

		[Serializable]
		private sealed class StateSnapshotCompatV1
		{
			public int ProtocolVersion;

			public string SessionEpoch = string.Empty;

			public long Revision;

			public string StateHash = string.Empty;

			public ProfileStateV1? State;

			public ProfileStateV1? Profile;

			public ProfileStateV1? ProfileState;

			public string StateJson = string.Empty;

			public string ProfileJson = string.Empty;

			public string Reason = string.Empty;

			public string SentAtUtc = string.Empty;
		}

		[Serializable]
		private sealed class ProfileStateV1
		{
			public int ProtocolVersion;

			public long Revision;

			public bool MasterEnabled;

			public bool EnableShaderPass;

			public int QualityTier;

			public bool C;

			public float Ci;

			public bool D;

			public float Di;

			public bool K;

			public float Ki;

			public bool H;

			public float Hi;

			public float Hs;

			public bool S;

			public float Si;

			public bool V;

			public float Vi;

			public bool Pr;

			public float Pri;

			public bool Px;

			public float Pxi;

			public bool Cs;

			public float Csi;

			public bool Dt;

			public float Dti;

			public float LensCx;

			public float LensCy;

			public bool Mb;

			public float Mbi;

			public bool Df;

			public float Dfi;

			public bool Ab;

			public float Abi;

			public bool Hf;

			public float Hfi;

			public float Hfs;

			public float Hfa;

			public bool Kw;

			public float Kwi;

			public float Kwr;

			public bool Sc;

			public float Sci;

			public float Sch;

			public float Scr;

			public float Scs;

			public bool Rb;

			public float Rbi;

			public bool Ld;

			public float Ldi;

			public bool Rn;

			public float Rni;

			public bool Ca;

			public float Cai;

			public bool Gd;

			public float Gdi;

			public bool Fg;

			public float Fgi;

			public bool Gl;

			public float Gli;

			public bool Vf;

			public float Vfi;

			public float Vfd;

			public float Vfh;

			public bool Lb;

			public float Lbi;

			public bool HypnosisEnabled;

			public int HypnosisPreset;

			public float HypnosisIntensity;

			public float HypnosisSpeed;

			public float HypnosisWarpAmount;

			public float HypnosisSpiralAmount;

			public float HypnosisColorBlend;

			public bool Sky;

			public float SkyI;

			public float SkyExposure;

			public float SkyHue;

			public float SkyColorBlend;

			public int SkyboxIndex;

			public float SunIntensity;

			public float SunTemp;

			public float SunR;

			public float SunG;

			public float SunB;

			public float SunBlend;

			public int Tm;

			public bool Wb;

			public float WbTemp;

			public float WbTint;

			public bool Lgg;

			public float Lift;

			public float Gamma;

			public float Gain;

			public bool St;

			public float StSr;

			public float StSg;

			public float StSb;

			public float StHr;

			public float StHg;

			public float StHb;

			public float StBal;

			public bool Clouds;

			public float CloudD;

			public bool Weather;

			public int WeatherMode;

			public float WeatherStrength;

			public bool Water;

			public float WaterClarity;

			public float WaterWave;

			public int AaPreset;

			public float CasSharp;

			public string Reason = string.Empty;

			public string SentAtUtc = string.Empty;
		}

		[Serializable]
		private sealed class SessionVisualProfileV1
		{
			public string Label = "Balanced";

			public long Revision;

			public string LastUpdatedUtc = string.Empty;

			public bool SessionColorLabEnabled = true;

			public float SessionColorStrength = 0.08f;

			public bool BloomEnabled = true;

			public float BloomIntensity = 0.25f;

			public float BloomScatter = 0.6f;

			public bool ColorGradingEnabled = true;

			public float Contrast = 6f;

			public float Saturation = 5f;

			public float HueShift;

			public bool VignetteEnabled = true;

			public float VignetteIntensity = 0.08f;

			public bool ChromaticAberrationEnabled;

			public float ChromaticAberrationIntensity = 0.03f;

			public bool LensDistortionEnabled;

			public float LensDistortionIntensity;

			public bool DepthOfFieldEnabled;

			public bool MotionBlurEnabled;

			public float MotionBlurIntensity = 0.07f;

			public static SessionVisualProfileV1 CreateBalancedPreset()
			{
				return new SessionVisualProfileV1
				{
					Label = "Balanced",
					Revision = 1L,
					LastUpdatedUtc = DateTime.UtcNow.ToString("O"),
					SessionColorLabEnabled = true,
					SessionColorStrength = 0.08f,
					BloomEnabled = true,
					BloomIntensity = 0.25f,
					BloomScatter = 0.6f,
					ColorGradingEnabled = true,
					Contrast = 6f,
					Saturation = 5f,
					HueShift = 0f,
					VignetteEnabled = true,
					VignetteIntensity = 0.08f,
					ChromaticAberrationEnabled = false,
					ChromaticAberrationIntensity = 0.03f,
					LensDistortionEnabled = false,
					LensDistortionIntensity = 0f,
					DepthOfFieldEnabled = false,
					MotionBlurEnabled = false,
					MotionBlurIntensity = 0.07f
				};
			}
		}

		private readonly struct Env
		{
			public byte MessageType { get; }

			public ulong SenderPlayerId { get; }

			public string Json { get; }

			public Env(byte t, ulong s, string j)
			{
				MessageType = t;
				SenderPlayerId = s;
				Json = j;
			}
		}

		private readonly struct EffectSlot
		{
			public string Name { get; }

			public Func<bool> GetEnabled { get; }

			public Func<float> GetIntensity { get; }

			public EffectSlot(string name, Func<bool> getEnabled, Func<float> getIntensity)
			{
				Name = name;
				GetEnabled = getEnabled;
				GetIntensity = getIntensity;
			}
		}

		private static class Codec
		{
			public static byte[] Encode(byte t, ulong s, string j)
			{
				byte[] bytes = Encoding.UTF8.GetBytes(j ?? string.Empty);
				if (bytes.Length > 65536)
				{
					throw new InvalidOperationException("payload too large");
				}
				using MemoryStream memoryStream = new MemoryStream();
				using BinaryWriter binaryWriter = new BinaryWriter(memoryStream, Encoding.UTF8, leaveOpen: true);
				binaryWriter.Write((byte)1);
				binaryWriter.Write(t);
				binaryWriter.Write(s);
				binaryWriter.Write(bytes.Length);
				binaryWriter.Write(bytes);
				binaryWriter.Flush();
				return memoryStream.ToArray();
			}

			public static bool TryDecode(byte[] d, out Env e)
			{
				e = default(Env);
				if (d == null || d.Length < 14)
				{
					return false;
				}
				try
				{
					using MemoryStream memoryStream = new MemoryStream(d, writable: false);
					using BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8, leaveOpen: true);
					if (binaryReader.ReadByte() != 1)
					{
						return false;
					}
					byte t = binaryReader.ReadByte();
					ulong s = binaryReader.ReadUInt64();
					int num = binaryReader.ReadInt32();
					if (num < 0 || num > 65536)
					{
						return false;
					}
					if (num > memoryStream.Length - memoryStream.Position)
					{
						return false;
					}
					byte[] array = binaryReader.ReadBytes(num);
					if (array.Length != num)
					{
						return false;
					}
					e = new Env(t, s, Encoding.UTF8.GetString(array));
					return true;
				}
				catch
				{
					return false;
				}
			}
		}

		private const string PluginGuid = "io.damon.ontogether.shaderplayground";

		private const string PluginName = "ShaderPlayground";

		private const string PluginVersion = "0.5.2";

		private const int ProtocolVersion = 4;

		private const int SessionVisualProtocolVersion = 1;

		private const int MaxPayloadBytes = 65536;

		private const float RuntimeVolumePriority = 12000f;

		private const int CapabilityHypnosisPack = 1;

		private const int CapabilitySyncHandshakeV2 = 2;

		private const float FisheyeIntensityMax = 0.1f;

		private const float GlitchIntensityMax = 0.1f;

		private const float BreathingIntensityMax = 0.05f;

		private static readonly string[] SkyboxStyleLabels = new string[2] { "Original", "Black" };

		private static readonly Color UiCream = new Color(0.99f, 0.96f, 0.89f, 1f);

		private static readonly Color UiInk = new Color(0.13f, 0.13f, 0.13f, 1f);

		private static readonly Color UiSubtleInk = new Color(0.24f, 0.24f, 0.24f, 1f);

		private static readonly Color UiSectionFill = new Color(1f, 0.98f, 0.92f, 1f);

		private static readonly Color UiTabInactive = new Color(0.92f, 0.84f, 0.73f, 0.96f);

		private static readonly Color UiTabActiveLighten = new Color(1f, 1f, 1f, 0.22f);

		private static readonly Color UiButtonPrimary = new Color(0.66f, 0.9f, 0.81f, 0.98f);

		private static readonly Color UiButtonSecondary = new Color(1f, 0.83f, 0.71f, 0.98f);

		private static readonly Color UiButtonPressed = new Color(0.93f, 0.76f, 0.65f, 0.98f);

		private static readonly Color[] UiTabAccents = (Color[])(object)new Color[8]
		{
			new Color(0.95f, 0.87f, 0.73f, 0.98f),
			new Color(1f, 0.83f, 0.71f, 0.98f),
			new Color(0.66f, 0.9f, 0.81f, 0.98f),
			new Color(0.75f, 0.88f, 0.9f, 0.98f),
			new Color(0.8f, 0.89f, 0.95f, 0.98f),
			new Color(0.84f, 0.89f, 0.99f, 0.98f),
			new Color(0.95f, 0.88f, 0.75f, 0.98f),
			new Color(0.92f, 0.82f, 0.88f, 0.98f)
		};

		private static readonly int ShaderTempRtId = Shader.PropertyToID("_ShaderPlaygroundTemp");

		private static readonly int ShaderPixelRtId = Shader.PropertyToID("_ShaderPlaygroundPixel");

		private static readonly string[] WaterKeywords = new string[5] { "water", "ocean", "river", "lake", "sea" };

		private static readonly string[] SkyKeywords = new string[3] { "sky", "atmo", "horizon" };

		private static readonly string[] CloudKeywords = new string[3] { "cloud", "mist", "fog" };

		private static readonly string[] SurfaceKeywords = new string[21]
		{
			"terrain", "ground", "rock", "stone", "sand", "soil", "dirt", "floor", "wall", "road",
			"wood", "concrete", "cliff", "mountain", "bark", "grass", "leaf", "foliage", "nature", "prop",
			"mesh"
		};

		private static readonly string[] CharacterKeywords = new string[12]
		{
			"player", "avatar", "character", "npc", "head", "body", "arm", "leg", "shirt", "pants",
			"shoe", "hair"
		};

		private static readonly string[] WaterSignatureProperties = new string[11]
		{
			"_WaterColor", "_ShallowColor", "_DeepColor", "_WaveStrength", "_WaveScale", "_WaveSpeed", "_FoamAmount", "_FoamIntensity", "_RefractionStrength", "_GerstnerStrength",
			"_ShoreFoam"
		};

		private static readonly string[] CloudSignatureProperties = new string[8] { "_CloudDensity", "_CloudOpacity", "_CloudCoverage", "_Cloudiness", "_CloudColor", "_CloudShadowColor", "_CloudSoftness", "_CloudDetail" };

		private static readonly string[] WaterSurfaceColorProperties = new string[7] { "_BaseColor", "_Color", "_WaterColor", "_ShallowColor", "_MainColor", "_TintColor", "_SurfaceColor" };

		private static readonly string[] WaterDeepColorProperties = new string[4] { "_DeepColor", "_DepthColor", "_AbsorptionColor", "_UnderwaterColor" };

		private static readonly string[] WaterFoamColorProperties = new string[3] { "_FoamColor", "_EdgeColor", "_FoamTint" };

		private static readonly string[] WaterWaveStrengthProperties = new string[6] { "_WaveStrength", "_WaveAmount", "_WaveAmplitude", "_GerstnerStrength", "_DistortionStrength", "_FlowStrength" };

		private static readonly string[] WaterWaveScaleProperties = new string[5] { "_WaveScale", "_WaveLength", "_RippleScale", "_DetailScale", "_Tiling" };

		private static readonly string[] WaterWaveSpeedProperties = new string[4] { "_WaveSpeed", "_FlowSpeed", "_DistortionSpeed", "_GerstnerSpeed" };

		private static readonly string[] WaterNormalStrengthProperties = new string[4] { "_NormalScale", "_BumpScale", "_NormalStrength", "_DetailNormalScale" };

		private static readonly string[] WaterSmoothnessProperties = new string[2] { "_Smoothness", "_Glossiness" };

		private static readonly string[] WaterRefractionProperties = new string[4] { "_RefractionStrength", "_Distortion", "_RefractionAmount", "_GrabPassDistortion" };

		private static readonly string[] WaterFoamAmountProperties = new string[5] { "_FoamAmount", "_FoamIntensity", "_FoamStrength", "_ShoreFoam", "_EdgeFoam" };

		private static readonly string[] WaterEmissionColorProperties = new string[3] { "_EmissionColor", "_SpecColor", "_ReflectionColor" };

		private static readonly string[] WaterEmissionStrengthProperties = new string[3] { "_EmissionStrength", "_Emission", "_SpecularIntensity" };

		private static readonly string[] CloudColorProperties = new string[6] { "_BaseColor", "_Color", "_Tint", "_CloudColor", "_MainColor", "_CloudLightColor" };

		private static readonly string[] CloudShadowColorProperties = new string[3] { "_CloudShadowColor", "_ShadowColor", "_CloudDarkColor" };

		private static readonly string[] CloudDensityProperties = new string[6] { "_Density", "_CloudDensity", "_CloudCoverage", "_Cloudiness", "_LayerDensity", "_DetailDensity" };

		private static readonly string[] CloudOpacityProperties = new string[4] { "_Opacity", "_CloudOpacity", "_Alpha", "_CloudAlpha" };

		private static readonly string[] CloudSoftnessProperties = new string[3] { "_Softness", "_CloudSoftness", "_Feather" };

		private static readonly string[] CloudDetailProperties = new string[3] { "_DetailStrength", "_DetailAmount", "_CloudDetail" };

		private static readonly string[] SkyColorProperties = new string[7] { "_Tint", "_SkyTint", "_Color", "_BaseColor", "_HorizonColor", "_ZenithColor", "_MainColor" };

		private static readonly string[] SkyExposureProperties = new string[5] { "_Exposure", "_SkyExposure", "_Intensity", "_Brightness", "_AtmosphereThickness" };

		private static readonly string[] CausticsStrengthProperties = new string[4] { "_CausticsStrength", "_CausticStrength", "_CausticsAmount", "_CausticAmount" };

		private static readonly string[] CausticsSpeedProperties = new string[4] { "_CausticsSpeed", "_CausticSpeed", "_FlowSpeed", "_DistortionSpeed" };

		private static readonly string[] CausticsScaleProperties = new string[5] { "_CausticsScale", "_CausticScale", "_WaveScale", "_RippleScale", "_DetailScale" };

		private static readonly string[] CausticsEmissionColorProperties = new string[4] { "_EmissionColor", "_GlowColor", "_SpecColor", "_RimColor" };

		private static readonly string[] CausticsEmissionStrengthProperties = new string[5] { "_Emission", "_EmissionStrength", "_EmissionIntensity", "_Glow", "_GlowStrength" };

		private static readonly string[] CausticsUvScrollProperties = new string[6] { "_BaseMap", "_MainTex", "_DetailMap", "_DetailAlbedoMap", "_BumpMap", "_NormalMap" };

		private static readonly string[] SurfaceSignatureProperties = new string[7] { "_BaseColor", "_Color", "_MainTex", "_BaseMap", "_BumpMap", "_Metallic", "_Smoothness" };

		private ConfigEntry<KeyCode> _toggleWindowKey;

		private ConfigEntry<bool> _ignoreHotkeysWhenTyping;

		private ConfigEntry<bool> _enableOtApiIntegration;

		private ConfigEntry<bool> _masterEnabled;

		private ConfigEntry<bool> _syncEnabled;

		private ConfigEntry<bool> _localOnlyMode;

		private ConfigEntry<bool> _acceptHostSync;

		private ConfigEntry<bool> _enableSessionVisualBridgeSync;

		private ConfigEntry<bool> _applySessionVisualBridgeLocally;

		private ConfigEntry<bool> _showNotifications;

		private ConfigEntry<float> _notificationMinIntervalSeconds;

		private ConfigEntry<bool> _respectSessionVisualLabOwnership;

		private ConfigEntry<bool> _windowVisibleConfig;

		private ConfigEntry<bool> _enableShaderPass;

		private ConfigEntry<bool> _forceVolumeFallback;

		private ConfigEntry<int> _qualityTier;

		private ConfigEntry<bool> _crtEnabled;

		private ConfigEntry<float> _crtIntensity;

		private ConfigEntry<bool> _dreamEnabled;

		private ConfigEntry<float> _dreamIntensity;

		private ConfigEntry<bool> _comicEnabled;

		private ConfigEntry<float> _comicIntensity;

		private ConfigEntry<bool> _heatwaveEnabled;

		private ConfigEntry<float> _heatwaveIntensity;

		private ConfigEntry<float> _heatwaveSpeed;

		private ConfigEntry<bool> _noirEnabled;

		private ConfigEntry<float> _noirIntensity;

		private ConfigEntry<bool> _vaporEnabled;

		private ConfigEntry<float> _vaporIntensity;

		private ConfigEntry<bool> _posterizeEnabled;

		private ConfigEntry<float> _posterizeIntensity;

		private ConfigEntry<bool> _pixelateEnabled;

		private ConfigEntry<float> _pixelateIntensity;

		private ConfigEntry<bool> _chromaticSplitEnabled;

		private ConfigEntry<float> _chromaticSplitIntensity;

		private ConfigEntry<bool> _ditherEnabled;

		private ConfigEntry<float> _ditherIntensity;

		private ConfigEntry<float> _lensCenterX;

		private ConfigEntry<float> _lensCenterY;

		private ConfigEntry<bool> _motionBlurEnabled;

		private ConfigEntry<float> _motionBlurIntensity;

		private ConfigEntry<bool> _depthOfFieldEnabled;

		private ConfigEntry<float> _depthOfFieldIntensity;

		private ConfigEntry<bool> _anamorphicBloomEnabled;

		private ConfigEntry<float> _anamorphicBloomIntensity;

		private ConfigEntry<bool> _halftoneEnabled;

		private ConfigEntry<float> _halftoneIntensity;

		private ConfigEntry<float> _halftoneDotSize;

		private ConfigEntry<float> _halftoneAngle;

		private ConfigEntry<bool> _kuwaharaEnabled;

		private ConfigEntry<float> _kuwaharaIntensity;

		private ConfigEntry<float> _kuwaharaRadius;

		private ConfigEntry<bool> _selectiveColorEnabled;

		private ConfigEntry<float> _selectiveColorIntensity;

		private ConfigEntry<float> _selectiveColorHue;

		private ConfigEntry<float> _selectiveColorRange;

		private ConfigEntry<float> _selectiveColorSoftness;

		private ConfigEntry<bool> _radialBlurEnabled;

		private ConfigEntry<float> _radialBlurIntensity;

		private ConfigEntry<bool> _lensDirtEnabled;

		private ConfigEntry<float> _lensDirtIntensity;

		private ConfigEntry<bool> _rainOnLensEnabled;

		private ConfigEntry<float> _rainOnLensIntensity;

		private ConfigEntry<bool> _causticsOverlayEnabled;

		private ConfigEntry<float> _causticsOverlayIntensity;

		private ConfigEntry<bool> _godrayFakeEnabled;

		private ConfigEntry<float> _godrayFakeIntensity;

		private ConfigEntry<bool> _filmGateEnabled;

		private ConfigEntry<float> _filmGateIntensity;

		private ConfigEntry<bool> _glitchPackEnabled;

		private ConfigEntry<float> _glitchPackIntensity;

		private ConfigEntry<bool> _volumetricFogTintEnabled;

		private ConfigEntry<float> _volumetricFogTintIntensity;

		private ConfigEntry<float> _volumetricFogTintDensity;

		private ConfigEntry<float> _volumetricFogTintHue;

		private ConfigEntry<bool> _lutBlendEnabled;

		private ConfigEntry<float> _lutBlendAmount;

		private ConfigEntry<string> _lutPathA;

		private ConfigEntry<string> _lutPathB;

		private ConfigEntry<bool> _hypnosisEnabled;

		private ConfigEntry<int> _hypnosisPreset;

		private ConfigEntry<float> _hypnosisIntensity;

		private ConfigEntry<float> _hypnosisSpeed;

		private ConfigEntry<float> _hypnosisWarpAmount;

		private ConfigEntry<float> _hypnosisSpiralAmount;

		private ConfigEntry<float> _hypnosisColorBlend;

		private ConfigEntry<bool> _enhancedSkyEnabled;

		private ConfigEntry<float> _skyIntensity;

		private ConfigEntry<float> _skyExposure;

		private ConfigEntry<float> _skyHueShift;

		private ConfigEntry<float> _skyColorBlend;

		private ConfigEntry<int> _skyboxMaterialIndex;

		private ConfigEntry<float> _sunIntensityMultiplier;

		private ConfigEntry<float> _sunTemperature;

		private ConfigEntry<float> _sunColorR;

		private ConfigEntry<float> _sunColorG;

		private ConfigEntry<float> _sunColorB;

		private ConfigEntry<float> _sunColorBlend;

		private ConfigEntry<int> _tonemappingMode;

		private ConfigEntry<bool> _whiteBalanceEnabled;

		private ConfigEntry<float> _whiteBalanceTemperature;

		private ConfigEntry<float> _whiteBalanceTint;

		private ConfigEntry<bool> _liftGammaGainEnabled;

		private ConfigEntry<float> _liftAmount;

		private ConfigEntry<float> _gammaAmount;

		private ConfigEntry<float> _gainAmount;

		private ConfigEntry<bool> _splitToningEnabled;

		private ConfigEntry<float> _splitShadowsR;

		private ConfigEntry<float> _splitShadowsG;

		private ConfigEntry<float> _splitShadowsB;

		private ConfigEntry<float> _splitHighlightsR;

		private ConfigEntry<float> _splitHighlightsG;

		private ConfigEntry<float> _splitHighlightsB;

		private ConfigEntry<float> _splitToningBalance;

		private ConfigEntry<bool> _cloudLayersEnabled;

		private ConfigEntry<float> _cloudDensity;

		private ConfigEntry<bool> _weatherSystemEnabled;

		private ConfigEntry<int> _weatherMode;

		private ConfigEntry<float> _weatherStrength;

		private ConfigEntry<bool> _waterOverrideEnabled;

		private ConfigEntry<float> _waterClarity;

		private ConfigEntry<float> _waterWaveStrength;

		private ConfigEntry<int> _antiAliasingPreset;

		private ConfigEntry<float> _casSharpening;

		private ConfigEntry<bool> _scannerLogOnSceneLoad;

		private ConfigEntry<string> _savedProfileJson;

		private ConfigEntry<bool> _debugMode;

		private ConfigEntry<float> _debugTelemetryIntervalSeconds;

		private ConfigEntry<bool> _enableBuiltInSyncLog;

		private ConfigEntry<bool> _syncLogToBepInEx;

		private ConfigEntry<bool> _syncLogIncludeKeepalive;

		private ConfigEntry<bool> _strictSnapshotHashValidation;

		private bool _showWindow;

		private Rect _windowRect = new Rect(80f, 60f, 640f, 700f);

		private Vector2 _scroll;

		private Vector2 _syncLogScroll;

		private UiTab _activeTab;

		private GUIStyle? _menuTitleStyle;

		private GUIStyle? _subtitleStyle;

		private GUIStyle? _bodyLabelStyle;

		private GUIStyle? _windowStyle;

		private GUIStyle? _tabStyle;

		private GUIStyle? _actionBtnStyle;

		private GUIStyle? _sectionStyle;

		private GUIStyle? _subCardStyle;

		private GUIStyle? _sectionHeaderStyle;

		private GUIStyle? _subCardHeaderStyle;

		private GUIStyle? _buttonStyle;

		private GUIStyle? _secondaryButtonStyle;

		private GUIStyle? _tabInactiveStyle;

		private GUIStyle[]? _tabActiveStyles;

		private GUIStyle? _sliderTrackStyle;

		private GUIStyle? _sliderThumbStyle;

		private GUIStyle? _toggleStyle;

		private GUIStyle? _valueLabelStyle;

		private GUIStyle? _textFieldStyle;

		private Texture2D? _panelTexture;

		private Texture2D? _sectionTexture;

		private Texture2D? _buttonTexture;

		private Texture2D? _buttonSecondaryTexture;

		private Texture2D? _buttonPressedTexture;

		private Texture2D? _tabInactiveTexture;

		private Texture2D? _tabInactiveHoverTexture;

		private Texture2D[]? _tabActiveTextures;

		private Texture2D? _subCardTexture;

		private Texture2D? _sliderTrackTexture;

		private Texture2D? _sliderThumbTexture;

		private Texture2D? _sliderThumbHoverTexture;

		private Texture2D? _sliderThumbActiveTexture;

		private Texture2D? _textFieldTexture;

		private Texture2D? _textFieldFocusedTexture;

		private NetworkManager? _network;

		private HostClientSyncPolicy.ClientHandshakeState _clientSyncState;

		private string _clientSyncStatusReason = "disconnected";

		private string _pendingHelloNonce = string.Empty;

		private string _activeSessionEpoch = string.Empty;

		private string _hostSessionEpoch = string.Empty;

		private string _hostSessionEpochFingerprint = string.Empty;

		private string _lastAcceptedStateHash = string.Empty;

		private ulong _expectedHostSenderId;

		private ulong _expectedHostSteamId;

		private long _revision = 1L;

		private long _lastAcceptedRevision = -1L;

		private long _lastSessionVisualBridgeRevision = -1L;

		private float _nextHelloAt;

		private float _helloRetryIntervalSeconds = 0.9f;

		private float _nextStateRequestAt;

		private float _nextHostKeepaliveAt;

		private float _lastHostCommitAt;

		private float _lastSnapshotAcceptedAt;

		private float _nextHostIdentityRefreshAt;

		private float _nextUnsyncedNotifyAt;

		private float _nextPacketSenderMismatchLogAt;

		private HostClientSyncPolicy.ClientHandshakeState _lastUnsyncedNotifiedState;

		private string _lastUnsyncedNotifiedReason = string.Empty;

		private bool _shaderHealthy = true;

		private bool _warnedFallback;

		private float _nextNotifyAt;

		private Type? _rejoinBridgeType;

		private MethodInfo? _rejoinBridgePublishMethod;

		private float _nextRejoinBridgeResolveAt;

		private Type? _smartCheckinBridgeType;

		private MethodInfo? _smartCheckinBridgePublishMethod;

		private float _nextSmartCheckinBridgeResolveAt;

		private Type? _fishingBridgeType;

		private MethodInfo? _fishingBridgePublishMethod;

		private float _nextFishingBridgeResolveAt;

		private Type? _chalkboardBridgeType;

		private MethodInfo? _chalkboardBridgePublishMethod;

		private float _nextChalkboardBridgeResolveAt;

		private Type? _sessionVisualLabBridgeType;

		private MethodInfo? _sessionVisualLabBridgePublishMethod;

		private float _nextSessionVisualLabBridgeResolveAt;

		private float _nextSceneSuspendNotifyAt;

		private float _nextSceneScanAt;

		private float _nextWaterApplyAt;

		private float _nextAaApplyAt;

		private float _nextDebugTelemetryAt;

		private DateTime _lastWeatherSelectionDateUtc = DateTime.MinValue;

		private WeatherMood _activeWeatherMood;

		private readonly Dictionary<Material, Material> _materialBaselines = new Dictionary<Material, Material>();

		private readonly Dictionary<string, int> _shaderCounts = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);

		private readonly List<string> _scanSummaryLines = new List<string>();

		private readonly List<Renderer> _scanRenderers = new List<Renderer>();

		private readonly HashSet<Material> _touchedMaterials = new HashSet<Material>();

		private readonly Dictionary<ulong, int> _clientCapabilityMasks = new Dictionary<ulong, int>();

		private readonly Dictionary<ulong, string> _clientHelloNonces = new Dictionary<ulong, string>();

		private readonly Dictionary<ulong, float> _lastRequestHandledAtByPlayer = new Dictionary<ulong, float>();

		private readonly List<string> _syncEventLog = new List<string>();

		private string _lastSyncEvent = "none";

		private bool _renderBaselineCaptured;

		private Color _baseFogColor;

		private bool _baseFogEnabled;

		private float _baseFogDensity;

		private FogMode _baseFogMode;

		private AmbientMode _baseAmbientMode;

		private Color _baseAmbientSkyColor;

		private Color _baseAmbientEquatorColor;

		private Color _baseAmbientGroundColor;

		private Material? _baseSkyboxMaterial;

		private Material? _runtimeSkyboxMaterial;

		private Material? _runtimeSkyboxSource;

		private Material? _starsSkyboxMaterial;

		private Material? _whiteSkyboxMaterial;

		private Texture2D? _starsSkyTexture;

		private Light? _baseSunLight;

		private Color _baseSunColor;

		private float _baseSunIntensity;

		private float _baseSunTemperature = 6500f;

		private UniversalRenderPipelineAsset? _baseUrpAsset;

		private float _baseUrpRenderScale = 1f;

		private bool _renderScaleBaselineCaptured;

		private Volume? _volume;

		private VolumeProfile? _profile;

		private Bloom? _bloom;

		private ColorAdjustments? _color;

		private Vignette? _vignette;

		private ChromaticAberration? _chroma;

		private LensDistortion? _lens;

		private FilmGrain? _grain;

		private MotionBlur? _motionBlur;

		private DepthOfField? _depthOfField;

		private Tonemapping? _tonemapping;

		private WhiteBalance? _whiteBalance;

		private LiftGammaGain? _liftGammaGain;

		private SplitToning? _splitToning;

		private ColorLookup? _colorLookup;

		private Texture2D? _lutTextureA;

		private Texture2D? _lutTextureB;

		private Texture2D? _lutRuntimeBlendTexture;

		private Texture2D? _posterizeLutTexture;

		private Texture2D? _selectiveColorLutTexture;

		private Texture2D? _generatedLensDirtTexture;

		private Texture2D? _halftoneOverlayTexture;

		private Texture2D? _glitchScanlineTexture;

		private string _lutLoadedPathA = string.Empty;

		private string _lutLoadedPathB = string.Empty;

		private string _lutPathAUi = string.Empty;

		private string _lutPathBUi = string.Empty;

		private bool _lutDirty = true;

		private float _lutLastBlendApplied = -1f;

		private int _posterizeLutLevels = -1;

		private float _selectiveColorLastIntensity = -1f;

		private float _selectiveColorLastHue = -1f;

		private float _selectiveColorLastRange = -1f;

		private float _selectiveColorLastSoftness = -1f;

		private int _selectiveColorLastPosterizeLevels = -1;

		private Material? _shaderMaterial;

		private CommandBuffer? _shaderPassBuffer;

		private readonly List<EffectSlot> _effectStack = new List<EffectSlot>();

		private bool _otApiReady;

		private bool _otApiRegistered;

		private float _nextOtApiRetryAt;

		private Type? _otApiType;

		private Type? _otArgType;

		private Type? _otArgEnumType;

		private Type? _otCfgLinkType;

		private Type? _otAuxTimingType;

		private object? _otDepot;

		private MethodInfo? _otCreateDepotMethod;

		private MethodInfo? _otAddCfgMethod;

		private MethodInfo? _otNotifyMethod;

		private int _otApiRegisteredControlCount;

		private static readonly string[] UiTabLabels = new string[8] { "⚙\nCore", "✨\nEffects", "\ud83e\uddea\nExperimental", "\ud83c\udf0d\nWorld", "\ud83c\udfa8\nAdvanced", "⭐\nQuality", "\ud83d\udcbf\nPresets", "\ud83d\udee0\nTools" };

		public static ManualLogSource Log = null;

		private static Plugin? _instance;

		private void Awake()
		{
			_instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			_toggleWindowKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Input", "ToggleWindowKey", (KeyCode)291, "Toggle ShaderPlayground UI.");
			_ignoreHotkeysWhenTyping = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "IgnoreHotkeysWhenTyping", true, "If true, function-key menu hotkeys are ignored while a text input field is focused.");
			_enableOtApiIntegration = ((BaseUnityPlugin)this).Config.Bind<bool>("Integration", "EnableOtApiIntegration", true, "Enable otAPI controls if otAPI is installed.");
			_masterEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "MasterEnabled", true, "Master enable.");
			_syncEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "SyncEnabled", true, "Enable profile sync.");
			_localOnlyMode = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "LocalOnlyMode", false, "Disable sync and run local-only.");
			_acceptHostSync = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AcceptHostSync", true, "Allow host to override this client's shader profile.");
			_enableSessionVisualBridgeSync = ((BaseUnityPlugin)this).Config.Bind<bool>("Legacy.SessionVisualBridge", "EnableSyncBridge", false, "Legacy bridge path (disabled by default).");
			_applySessionVisualBridgeLocally = ((BaseUnityPlugin)this).Config.Bind<bool>("Legacy.SessionVisualBridge", "ApplyLocallyWhenSessionVisualLabMissing", false, "Legacy bridge path (disabled by default).");
			_showNotifications = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "ShowNotifications", true, "Show notifications.");
			_notificationMinIntervalSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "NotificationMinIntervalSeconds", 1.25f, "Min seconds between notifications.");
			_respectSessionVisualLabOwnership = ((BaseUnityPlugin)this).Config.Bind<bool>("Legacy.SessionVisualBridge", "RespectSessionVisualLabOwnership", false, "Legacy ownership guard (disabled by default).");
			_windowVisibleConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "WindowVisible", false, "Persisted state for ShaderPlayground settings window.");
			_enableShaderPass = ((BaseUnityPlugin)this).Config.Bind<bool>("Runtime", "EnableShaderPass", true, "Enable fullscreen shader path.");
			_forceVolumeFallback = ((BaseUnityPlugin)this).Config.Bind<bool>("Runtime", "ForceVolumeFallback", false, "Force fallback volume mode.");
			_qualityTier = ((BaseUnityPlugin)this).Config.Bind<int>("Runtime", "QualityTier", 1, "0 low, 1 medium, 2 high.");
			_crtEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.CRTVHS", "Enabled", true, "Enable Fisheye.");
			_crtIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.CRTVHS", "Intensity", 0.06f, "Fisheye intensity.");
			_dreamEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.DreamBloom", "Enabled", false, "Enable Dream Bloom.");
			_dreamIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.DreamBloom", "Intensity", 0.45f, "Dream intensity.");
			_comicEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.ComicSketch", "Enabled", false, "Enable Comic/Sketch.");
			_comicIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.ComicSketch", "Intensity", 0.4f, "Comic intensity.");
			_heatwaveEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.Heatwave", "Enabled", false, "Enable Breathing.");
			_heatwaveIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Heatwave", "Intensity", 0.028f, "Breathing intensity.");
			_heatwaveSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Heatwave", "Speed", 1f, "Heatwave speed.");
			_noirEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.Noir", "Enabled", false, "Enable cinematic noir grade.");
			_noirIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Noir", "Intensity", 0.45f, "Noir intensity.");
			_vaporEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.Vapor", "Enabled", false, "Enable neon/vapor look.");
			_vaporIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Vapor", "Intensity", 0.4f, "Vapor intensity.");
			_posterizeEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.Posterize", "Enabled", false, "Enable posterize color quantization.");
			_posterizeIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Posterize", "Intensity", 0.35f, "Posterize intensity.");
			_pixelateEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.Pixelate", "Enabled", false, "Enable pixelate retro scaling.");
			_pixelateIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Pixelate", "Intensity", 0.25f, "Pixelate strength.");
			_chromaticSplitEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.ChromaticSplit", "Enabled", false, "Enable RGB split.");
			_chromaticSplitIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.ChromaticSplit", "Intensity", 0.25f, "Chromatic split intensity.");
			_ditherEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.Dither", "Enabled", false, "Enable stylized dither grain.");
			_ditherIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Dither", "Intensity", 0.2f, "Dither intensity.");
			_lensCenterX = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.LensDistortion", "CenterX", 0.5f, "Lens distortion center X (supports off-screen).");
			_lensCenterY = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.LensDistortion", "CenterY", 0.5f, "Lens distortion center Y (supports off-screen).");
			_motionBlurEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.MotionBlur", "Enabled", false, "Enable Motion Blur.");
			_motionBlurIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.MotionBlur", "Intensity", 0.2f, "Motion Blur intensity.");
			_depthOfFieldEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.DepthOfField", "Enabled", false, "Enable Depth of Field.");
			_depthOfFieldIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.DepthOfField", "Intensity", 0.35f, "Depth of Field intensity.");
			_anamorphicBloomEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.Experimental", "AnamorphicBloomEnabled", false, "Enable Experimental Anamorphic Bloom (horizontal cinematic streak style).");
			_anamorphicBloomIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Experimental", "AnamorphicBloomIntensity", 0.35f, "Experimental Anamorphic Bloom intensity.");
			_halftoneEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.Experimental", "HalftoneEnabled", false, "Enable Experimental Halftone comic dots.");
			_halftoneIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Experimental", "HalftoneIntensity", 0.35f, "Experimental Halftone amount.");
			_halftoneDotSize = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Experimental", "HalftoneDotSize", 1.25f, "Experimental Halftone dot size.");
			_halftoneAngle = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Experimental", "HalftoneAngle", 45f, "Experimental Halftone angle in degrees.");
			_kuwaharaEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.Experimental", "KuwaharaEnabled", false, "Enable Experimental Kuwahara/Oil Paint smoothing.");
			_kuwaharaIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Experimental", "KuwaharaIntensity", 0.35f, "Experimental Kuwahara/Oil Paint amount.");
			_kuwaharaRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Experimental", "KuwaharaRadius", 2f, "Experimental Kuwahara/Oil Paint radius.");
			_selectiveColorEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.Experimental", "SelectiveColorEnabled", false, "Enable Experimental Selective Color.");
			_selectiveColorIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Experimental", "SelectiveColorIntensity", 0.75f, "Selective Color desaturation amount for out-of-range hues.");
			_selectiveColorHue = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Experimental", "SelectiveColorHue", 0f, "Selective Color target hue in degrees (0..360).");
			_selectiveColorRange = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Experimental", "SelectiveColorRange", 35f, "Selective Color hue range in degrees.");
			_selectiveColorSoftness = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Experimental", "SelectiveColorSoftness", 0.25f, "Selective Color edge softness.");
			_radialBlurEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.Experimental", "RadialBlurEnabled", false, "Enable Experimental Radial Blur.");
			_radialBlurIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Experimental", "RadialBlurIntensity", 0.35f, "Radial Blur intensity.");
			_lensDirtEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.Experimental", "LensDirtEnabled", false, "Enable Experimental Lens Dirt overlay via bloom.");
			_lensDirtIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Experimental", "LensDirtIntensity", 0.35f, "Lens Dirt intensity.");
			_rainOnLensEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.Experimental", "RainOnLensEnabled", false, "Enable Experimental Rain-on-Lens.");
			_rainOnLensIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Experimental", "RainOnLensIntensity", 0.35f, "Rain-on-Lens intensity.");
			_causticsOverlayEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.Experimental", "CausticsOverlayEnabled", false, "Enable Experimental Caustics Overlay on world surfaces.");
			_causticsOverlayIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Experimental", "CausticsOverlayIntensity", 0.35f, "Caustics Overlay intensity.");
			_godrayFakeEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.Experimental", "GodrayFakeEnabled", false, "Enable Experimental Godray Fake (cheap sun-direction screen rays).");
			_godrayFakeIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Experimental", "GodrayFakeIntensity", 0.35f, "Godray Fake intensity.");
			_filmGateEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.Experimental", "FilmGateEnabled", false, "Enable Experimental Film Gate (letterbox + subtle jitter + grain).");
			_filmGateIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Experimental", "FilmGateIntensity", 0.35f, "Film Gate intensity.");
			_glitchPackEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.Experimental", "GlitchPackEnabled", false, "Enable Experimental Glitch Pack (scanline jitter + channel jumps + digital tearing).");
			_glitchPackIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Experimental", "GlitchPackIntensity", 0.04f, "Glitch Pack intensity.");
			_volumetricFogTintEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.Experimental", "VolumetricFogTintEnabled", false, "Enable Experimental Volumetric Fog Tint.");
			_volumetricFogTintIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Experimental", "VolumetricFogTintIntensity", 0.35f, "Volumetric Fog Tint color intensity.");
			_volumetricFogTintDensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Experimental", "VolumetricFogTintDensity", 0.4f, "Volumetric Fog Tint density shaping amount.");
			_volumetricFogTintHue = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Experimental", "VolumetricFogTintHue", 210f, "Volumetric Fog Tint hue in degrees (0..360).");
			_lutBlendEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.Experimental", "LutBlendEnabled", false, "Enable Experimental Color LUT Blend.");
			_lutBlendAmount = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.Experimental", "LutBlendAmount", 0f, "Color LUT blend amount between LUT A (0) and LUT B (1).");
			_lutPathA = ((BaseUnityPlugin)this).Config.Bind<string>("Effects.Experimental", "LutPathA", string.Empty, "Filesystem path to LUT A (PNG/JPG).");
			_lutPathB = ((BaseUnityPlugin)this).Config.Bind<string>("Effects.Experimental", "LutPathB", string.Empty, "Filesystem path to LUT B (PNG/JPG).");
			_hypnosisEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Effects.DreamyHypnosis", "Enabled", false, "Enable Dreamy Hypnosis pack.");
			_hypnosisPreset = ((BaseUnityPlugin)this).Config.Bind<int>("Effects.DreamyHypnosis", "Preset", 1, "0 Custom, 1 Lullaby, 2 Float, 3 Deep Hypnosis.");
			_hypnosisIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.DreamyHypnosis", "Intensity", 0.35f, "Master hypnosis intensity (no-flicker).");
			_hypnosisSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.DreamyHypnosis", "Speed", 0.22f, "Hypnosis motion speed (clamped low for comfort).");
			_hypnosisWarpAmount = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.DreamyHypnosis", "WarpAmount", 0.32f, "DreamWarp strength.");
			_hypnosisSpiralAmount = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.DreamyHypnosis", "SpiralAmount", 0.28f, "Vignette spiral strength.");
			_hypnosisColorBlend = ((BaseUnityPlugin)this).Config.Bind<float>("Effects.DreamyHypnosis", "ColorBlend", 0.45f, "Soft chromatic drift blend.");
			_enhancedSkyEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("World.Sky", "Enabled", true, "Enable sky and lighting overhaul.");
			_skyIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("World.Sky", "Intensity", 0.7f, "Sky/lighting strength.");
			_skyExposure = ((BaseUnityPlugin)this).Config.Bind<float>("World.Sky", "Exposure", 1f, "Skybox exposure multiplier.");
			_skyHueShift = ((BaseUnityPlugin)this).Config.Bind<float>("World.Sky", "HueShift", 0f, "Sky hue shift in degrees (-180 to 180).");
			_skyColorBlend = ((BaseUnityPlugin)this).Config.Bind<float>("World.Sky", "ColorBlend", 0f, "How strongly hue shift applies to sky/fog/ambient.");
			_skyboxMaterialIndex = ((BaseUnityPlugin)this).Config.Bind<int>("World.Sky", "MaterialIndex", 0, "Selected skybox material index.");
			_sunIntensityMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("World.Sun", "IntensityMultiplier", 1f, "Sun intensity multiplier.");
			_sunTemperature = ((BaseUnityPlugin)this).Config.Bind<float>("World.Sun", "Temperature", 6500f, "Sun color temperature.");
			_sunColorR = ((BaseUnityPlugin)this).Config.Bind<float>("World.Sun", "ColorR", 1f, "Sun color red channel.");
			_sunColorG = ((BaseUnityPlugin)this).Config.Bind<float>("World.Sun", "ColorG", 0.97f, "Sun color green channel.");
			_sunColorB = ((BaseUnityPlugin)this).Config.Bind<float>("World.Sun", "ColorB", 0.9f, "Sun color blue channel.");
			_sunColorBlend = ((BaseUnityPlugin)this).Config.Bind<float>("World.Sun", "ColorBlend", 0f, "Blend amount for custom sun color.");
			_tonemappingMode = ((BaseUnityPlugin)this).Config.Bind<int>("AdvancedColor.Tonemapping", "Mode", 0, "0 Off, 1 Neutral, 2 ACES.");
			_whiteBalanceEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("AdvancedColor.WhiteBalance", "Enabled", false, "Enable WhiteBalance override.");
			_whiteBalanceTemperature = ((BaseUnityPlugin)this).Config.Bind<float>("AdvancedColor.WhiteBalance", "Temperature", 0f, "WhiteBalance temperature (-100..100).");
			_whiteBalanceTint = ((BaseUnityPlugin)this).Config.Bind<float>("AdvancedColor.WhiteBalance", "Tint", 0f, "WhiteBalance tint (-100..100).");
			_liftGammaGainEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("AdvancedColor.LiftGammaGain", "Enabled", false, "Enable Lift/Gamma/Gain override.");
			_liftAmount = ((BaseUnityPlugin)this).Config.Bind<float>("AdvancedColor.LiftGammaGain", "Lift", 0f, "Lift amount (-1..1).");
			_gammaAmount = ((BaseUnityPlugin)this).Config.Bind<float>("AdvancedColor.LiftGammaGain", "Gamma", 1f, "Gamma amount (0..2).");
			_gainAmount = ((BaseUnityPlugin)this).Config.Bind<float>("AdvancedColor.LiftGammaGain", "Gain", 1f, "Gain amount (0..2).");
			_splitToningEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("AdvancedColor.SplitToning", "Enabled", false, "Enable split toning (separate shadow/highlight tints).");
			_splitShadowsR = ((BaseUnityPlugin)this).Config.Bind<float>("AdvancedColor.SplitToning", "ShadowsR", 0.5f, "Split toning shadows red channel (0..1).");
			_splitShadowsG = ((BaseUnityPlugin)this).Config.Bind<float>("AdvancedColor.SplitToning", "ShadowsG", 0.5f, "Split toning shadows green channel (0..1).");
			_splitShadowsB = ((BaseUnityPlugin)this).Config.Bind<float>("AdvancedColor.SplitToning", "ShadowsB", 0.5f, "Split toning shadows blue channel (0..1).");
			_splitHighlightsR = ((BaseUnityPlugin)this).Config.Bind<float>("AdvancedColor.SplitToning", "HighlightsR", 0.5f, "Split toning highlights red channel (0..1).");
			_splitHighlightsG = ((BaseUnityPlugin)this).Config.Bind<float>("AdvancedColor.SplitToning", "HighlightsG", 0.5f, "Split toning highlights green channel (0..1).");
			_splitHighlightsB = ((BaseUnityPlugin)this).Config.Bind<float>("AdvancedColor.SplitToning", "HighlightsB", 0.5f, "Split toning highlights blue channel (0..1).");
			_splitToningBalance = ((BaseUnityPlugin)this).Config.Bind<float>("AdvancedColor.SplitToning", "Balance", 0f, "Split toning balance (-100..100).");
			_cloudLayersEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("World.Clouds", "Enabled", true, "Enable multi-layer cloud look adjustments.");
			_cloudDensity = ((BaseUnityPlugin)this).Config.Bind<float>("World.Clouds", "Density", 0.65f, "Cloud density/intensity.");
			_weatherSystemEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("World.Weather", "Enabled", true, "Enable daily weather mood selection.");
			_weatherMode = ((BaseUnityPlugin)this).Config.Bind<int>("World.Weather", "Mode", 0, "0 Auto daily, 1 Clear, 2 Golden, 3 Overcast, 4 Storm, 5 Dream.");
			_weatherStrength = ((BaseUnityPlugin)this).Config.Bind<float>("World.Weather", "Strength", 0.7f, "Weather mood strength.");
			_waterOverrideEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("World.Water", "Enabled", true, "Enable runtime water material override.");
			_waterClarity = ((BaseUnityPlugin)this).Config.Bind<float>("World.Water", "Clarity", 0.68f, "Water clarity and tint strength.");
			_waterWaveStrength = ((BaseUnityPlugin)this).Config.Bind<float>("World.Water", "WaveStrength", 0.62f, "Water wave/normal strength.");
			_antiAliasingPreset = ((BaseUnityPlugin)this).Config.Bind<int>("ImageQuality", "AntiAliasingPreset", 2, "0 Off, 1 FXAA, 2 SMAA, 3 TAA, 4 CAS-style.");
			_casSharpening = ((BaseUnityPlugin)this).Config.Bind<float>("ImageQuality", "CasSharpening", 0.35f, "CAS-style sharpening strength.");
			_scannerLogOnSceneLoad = ((BaseUnityPlugin)this).Config.Bind<bool>("Tools", "ShaderScannerLogOnSceneLoad", true, "Log material/shader scanner output on scene load.");
			_savedProfileJson = ((BaseUnityPlugin)this).Config.Bind<string>("Presets", "SavedProfileJson", string.Empty, "Saved custom preset JSON.");
			_debugMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "DebugMode", false, "Emit debug telemetry for runtime state, camera/post-processing, and sync ownership.");
			_debugTelemetryIntervalSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Debug", "DebugTelemetryIntervalSeconds", 5f, "Seconds between periodic debug telemetry logs.");
			_enableBuiltInSyncLog = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableBuiltInSyncLog", true, "Keep an in-game rolling sync/handshake event log.");
			_syncLogToBepInEx = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "SyncLogToBepInEx", true, "Write handshake/sync events to BepInEx log.");
			_syncLogIncludeKeepalive = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "SyncLogIncludeKeepalive", false, "Include keepalive snapshots in built-in sync log.");
			_strictSnapshotHashValidation = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "StrictSnapshotHashValidation", false, "When true (and DebugMode=true), reject host snapshots on hash mismatch. Default false for compatibility.");
			_lutPathAUi = _lutPathA.Value ?? string.Empty;
			_lutPathBUi = _lutPathB.Value ?? string.Empty;
			_showWindow = _windowVisibleConfig.Value;
			ClampEffectRanges();
			BuildEffectStack();
			RenderPipelineManager.endCameraRendering += OnEndCameraRendering;
			SceneManager.sceneLoaded += OnSceneLoaded;
			((MonoBehaviour)this).StartCoroutine(HookLoop());
			_nextOtApiRetryAt = Time.unscaledTime + 1f;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"ShaderPlayground loaded (0.5.2)");
		}

		private void OnDestroy()
		{
			_instance = null;
			RenderPipelineManager.endCameraRendering -= OnEndCameraRendering;
			SceneManager.sceneLoaded -= OnSceneLoaded;
			UnhookNetwork();
			DestroyVolume();
			RestoreMaterialBaselines();
			RestoreRenderBaseline();
			RestoreRenderScaleBaseline();
			if ((Object)(object)_shaderMaterial != (Object)null)
			{
				Object.Destroy((Object)(object)_shaderMaterial);
			}
			_shaderMaterial = null;
			CommandBuffer? shaderPassBuffer = _shaderPassBuffer;
			if (shaderPassBuffer != null)
			{
				shaderPassBuffer.Release();
			}
			_shaderPassBuffer = null;
			if ((Object)(object)_starsSkyboxMaterial != (Object)null)
			{
				Object.Destroy((Object)(object)_starsSkyboxMaterial);
			}
			if ((Object)(object)_whiteSkyboxMaterial != (Object)null)
			{
				Object.Destroy((Object)(object)_whiteSkyboxMaterial);
			}
			if ((Object)(object)_starsSkyTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_starsSkyTexture);
			}
			_starsSkyboxMaterial = null;
			_whiteSkyboxMaterial = null;
			_starsSkyTexture = null;
			DestroyLutTextures();
			if ((Object)(object)_generatedLensDirtTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_generatedLensDirtTexture);
			}
			_generatedLensDirtTexture = null;
			if ((Object)(object)_halftoneOverlayTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_halftoneOverlayTexture);
			}
			_halftoneOverlayTexture = null;
			if ((Object)(object)_glitchScanlineTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_glitchScanlineTexture);
			}
			_glitchScanlineTexture = null;
			if ((Object)(object)_panelTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_panelTexture);
			}
			if ((Object)(object)_sectionTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_sectionTexture);
			}
			if ((Object)(object)_buttonTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_buttonTexture);
			}
			if ((Object)(object)_buttonSecondaryTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_buttonSecondaryTexture);
			}
			if ((Object)(object)_buttonPressedTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_buttonPressedTexture);
			}
			if ((Object)(object)_tabInactiveTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_tabInactiveTexture);
			}
			if ((Object)(object)_tabInactiveHoverTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_tabInactiveHoverTexture);
			}
			if ((Object)(object)_subCardTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_subCardTexture);
			}
			if ((Object)(object)_sliderTrackTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_sliderTrackTexture);
			}
			if ((Object)(object)_sliderThumbTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_sliderThumbTexture);
			}
			if ((Object)(object)_sliderThumbHoverTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_sliderThumbHoverTexture);
			}
			if ((Object)(object)_sliderThumbActiveTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_sliderThumbActiveTexture);
			}
			if ((Object)(object)_textFieldTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_textFieldTexture);
			}
			if ((Object)(object)_textFieldFocusedTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_textFieldFocusedTexture);
			}
			if (_tabActiveTextures == null)
			{
				return;
			}
			for (int i = 0; i < _tabActiveTextures.Length; i++)
			{
				if ((Object)(object)_tabActiveTextures[i] != (Object)null)
				{
					Object.Destroy((Object)(object)_tabActiveTextures[i]);
				}
			}
		}

		private IEnumerator HookLoop()
		{
			while (true)
			{
				TryHookNetwork();
				yield return (object)new WaitForSeconds(1f);
			}
		}

		private void OnSceneLoaded(Scene _, LoadSceneMode __)
		{
			TryHookNetwork();
			_nextSceneScanAt = 0f;
			_nextWaterApplyAt = 0f;
			_nextAaApplyAt = 0f;
			_lastWeatherSelectionDateUtc = DateTime.MinValue;
			RefreshSkyboxMaterialOptions();
			if (_scannerLogOnSceneLoad.Value)
			{
				RunMaterialScanner(logToConsole: true);
			}
			else
			{
				RunMaterialScanner(logToConsole: false);
			}
			RefreshSkyboxMaterialOptions();
			HandleSyncLifecycleReset("scene-load");
		}

		private void Update()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(_toggleWindowKey.Value) && CanUseMenuHotkey())
			{
				_showWindow = !_showWindow;
				_windowVisibleConfig.Value = _showWindow;
			}
			if (_windowVisibleConfig.Value != _showWindow)
			{
				_showWindow = _windowVisibleConfig.Value;
			}
			if (_enableOtApiIntegration.Value && (!_otApiReady || !_otApiRegistered) && Time.unscaledTime >= _nextOtApiRetryAt)
			{
				_nextOtApiRetryAt = Time.unscaledTime + 10f;
				TryInitializeOtApi();
			}
			bool flag = IsSceneSuspendedForVisualOverrides();
			if (_masterEnabled.Value && !flag)
			{
				if (Time.unscaledTime >= _nextSceneScanAt)
				{
					_nextSceneScanAt = Time.unscaledTime + 6f;
					RunMaterialScanner(logToConsole: false);
				}
				if (Time.unscaledTime >= _nextAaApplyAt)
				{
					_nextAaApplyAt = Time.unscaledTime + 2f;
					ApplyAntiAliasingPresetToActiveCameras();
				}
				if (Time.unscaledTime >= _nextWaterApplyAt)
				{
					float num = (_causticsOverlayEnabled.Value ? 1.5f : 0.75f);
					_nextWaterApplyAt = Time.unscaledTime + num;
					ApplyWaterAndCloudOverrides();
				}
				ApplyVisuals();
			}
			else
			{
				DisableVisuals();
			}
			if (flag)
			{
				if (_showNotifications.Value && Time.unscaledTime >= _nextSceneSuspendNotifyAt)
				{
					_nextSceneSuspendNotifyAt = Time.unscaledTime + 8f;
					Notify("ShaderPlayground paused in menu/desktop scene.");
				}
				return;
			}
			if (_debugMode.Value && Time.unscaledTime >= _nextDebugTelemetryAt)
			{
				_nextDebugTelemetryAt = Time.unscaledTime + Mathf.Clamp(_debugTelemetryIntervalSeconds.Value, 1f, 60f);
				EmitDebugTelemetry("tick");
			}
			TickHandshakeAndSync(Time.unscaledTime);
		}

		private void OnGUI()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			DrawHalftoneOverlay();
			DrawLensDirtOverlay();
			DrawRainOnLensOverlay();
			DrawFilmGateOverlay();
			DrawGlitchOverlay();
			if (_showWindow)
			{
				InitStyles();
				ClampWindowToScreen();
				_windowRect = GUI.Window(23154, _windowRect, new WindowFunction(DrawWindow), $"Shader Playground ({_toggleWindowKey.Value})", _windowStyle ?? GUI.skin.window);
				ClampWindowToScreen();
			}
		}

		private void DrawHalftoneOverlay()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			if (Event.current != null && (int)Event.current.type == 7 && _masterEnabled.Value && _halftoneEnabled.Value && !(_halftoneIntensity.Value <= 0.001f) && !IsSceneSuspendedForVisualOverrides())
			{
				if (_halftoneOverlayTexture == null)
				{
					_halftoneOverlayTexture = BuildHalftoneOverlayTexture();
				}
				if (!((Object)(object)_halftoneOverlayTexture == (Object)null))
				{
					float num = Mathf.Clamp01(_halftoneIntensity.Value);
					float num2 = Mathf.InverseLerp(0.25f, 8f, Mathf.Clamp(_halftoneDotSize.Value, 0.25f, 8f));
					float num3 = Mathf.Lerp(220f, 22f, num2);
					float num4 = Mathf.Max(1f, (float)Screen.width / num3);
					float num5 = Mathf.Max(1f, (float)Screen.height / num3);
					Matrix4x4 matrix = GUI.matrix;
					Color color = GUI.color;
					GUIUtility.RotateAroundPivot(_halftoneAngle.Value, new Vector2((float)Screen.width * 0.5f, (float)Screen.height * 0.5f));
					GUI.color = new Color(0f, 0f, 0f, Mathf.Lerp(0.03f, 0.22f, num));
					GUI.DrawTextureWithTexCoords(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)_halftoneOverlayTexture, new Rect(0f, 0f, num4, num5));
					GUI.color = color;
					GUI.matrix = matrix;
				}
			}
		}

		private static Texture2D BuildHalftoneOverlayTexture()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false, true)
			{
				wrapMode = (TextureWrapMode)0,
				filterMode = (FilterMode)1,
				hideFlags = (HideFlags)61,
				name = "ShaderPlayground.HalftoneOverlay"
			};
			float num = 63.5f;
			float num2 = Mathf.Max(1f, num);
			for (int i = 0; i < 128; i++)
			{
				for (int j = 0; j < 128; j++)
				{
					float num3 = (float)j - num;
					float num4 = (float)i - num;
					float num5 = Mathf.Sqrt(num3 * num3 + num4 * num4);
					float num6 = Mathf.Clamp01(1f - Mathf.Pow(num5 / num2, 1.8f));
					val.SetPixel(j, i, new Color(0f, 0f, 0f, num6));
				}
			}
			val.Apply(false, false);
			return val;
		}

		private void DrawLensDirtOverlay()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			if (Event.current != null && (int)Event.current.type == 7 && _masterEnabled.Value && _lensDirtEnabled.Value && !(_lensDirtIntensity.Value <= 0.001f) && !IsSceneSuspendedForVisualOverrides())
			{
				Texture2D orCreateLensDirtTexture = GetOrCreateLensDirtTexture();
				if (!((Object)(object)orCreateLensDirtTexture == (Object)null))
				{
					float num = Mathf.Clamp01(_lensDirtIntensity.Value);
					Color color = GUI.color;
					GUI.color = new Color(1f, 1f, 1f, Mathf.Lerp(0.04f, 0.28f, num));
					GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)orCreateLensDirtTexture, (ScaleMode)0, true);
					GUI.color = color;
				}
			}
		}

		private void DrawRainOnLensOverlay()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			if (Event.current != null && (int)Event.current.type == 7 && _masterEnabled.Value && _rainOnLensEnabled.Value && !(_rainOnLensIntensity.Value <= 0.001f) && !IsSceneSuspendedForVisualOverrides())
			{
				Texture2D orCreateLensDirtTexture = GetOrCreateLensDirtTexture();
				if (!((Object)(object)orCreateLensDirtTexture == (Object)null))
				{
					float num = Mathf.Clamp01(_rainOnLensIntensity.Value);
					float unscaledTime = Time.unscaledTime;
					Rect val = default(Rect);
					((Rect)(ref val))..ctor((Mathf.PerlinNoise(unscaledTime * 0.12f, 0.31f) - 0.5f) * 0.08f, Mathf.Repeat((0f - unscaledTime) * Mathf.Lerp(0.01f, 0.06f, num), 1f), 1.12f, 1.12f);
					float num2 = Mathf.Lerp(0.75f, 1.15f, Mathf.PerlinNoise(0.41f, unscaledTime * 0.9f));
					Color color = GUI.color;
					GUI.color = new Color(1f, 1f, 1f, Mathf.Clamp01(Mathf.Lerp(0.02f, 0.2f, num) * num2));
					GUI.DrawTextureWithTexCoords(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)orCreateLensDirtTexture, val);
					GUI.color = color;
				}
			}
		}

		private void DrawFilmGateOverlay()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			if (Event.current != null && (int)Event.current.type == 7 && _masterEnabled.Value && _filmGateEnabled.Value && !(_filmGateIntensity.Value <= 0.001f) && !IsSceneSuspendedForVisualOverrides())
			{
				float num = Mathf.Clamp01(_filmGateIntensity.Value);
				int num2 = Mathf.Clamp(Mathf.RoundToInt((float)Screen.height * Mathf.Lerp(0.03f, 0.14f, num)), 6, Mathf.Max(8, Screen.height / 3));
				float num3 = Mathf.Lerp(0.7f, 1f, num);
				Color color = GUI.color;
				GUI.color = new Color(0f, 0f, 0f, num3);
				GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)num2), (Texture)(object)Texture2D.whiteTexture, (ScaleMode)0);
				GUI.DrawTexture(new Rect(0f, (float)(Screen.height - num2), (float)Screen.width, (float)num2), (Texture)(object)Texture2D.whiteTexture, (ScaleMode)0);
				GUI.color = color;
			}
		}

		private void DrawGlitchOverlay()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			if (Event.current == null || (int)Event.current.type != 7 || !_masterEnabled.Value || !_glitchPackEnabled.Value || _glitchPackIntensity.Value <= 0.001f || IsSceneSuspendedForVisualOverrides())
			{
				return;
			}
			float num = Mathf.Clamp01(_glitchPackIntensity.Value / 0.1f);
			if (_glitchScanlineTexture == null)
			{
				_glitchScanlineTexture = BuildGlitchScanlineTexture();
			}
			if (!((Object)(object)_glitchScanlineTexture == (Object)null))
			{
				float unscaledTime = Time.unscaledTime;
				float num2 = (Mathf.PerlinNoise(0.37f, unscaledTime * 7.9f) - 0.5f) * 0.18f * num;
				float num3 = (Mathf.PerlinNoise(unscaledTime * 9.2f, 0.61f) - 0.5f) * 0.12f * num;
				float num4 = Mathf.Clamp01(Mathf.Sin(unscaledTime * 13.5f) * 0.5f + 0.5f);
				float num5 = Mathf.Lerp(0.04f, 0.22f, num) * Mathf.Lerp(0.75f, 1.25f, num4);
				Color color = GUI.color;
				GUI.color = new Color(1f, 1f, 1f, Mathf.Clamp01(num5));
				GUI.DrawTextureWithTexCoords(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)_glitchScanlineTexture, new Rect(num3, num2, 1f, 1f));
				if (Mathf.PerlinNoise(2.19f, unscaledTime * 5.7f) > Mathf.Lerp(0.86f, 0.62f, num))
				{
					int num6 = Mathf.FloorToInt(Mathf.Repeat(unscaledTime * 143f, Mathf.Max(1f, (float)Screen.height - 24f)));
					int num7 = Mathf.Clamp(Mathf.RoundToInt(Mathf.Lerp(2f, 14f, num)), 2, 18);
					float num8 = Mathf.Lerp(0.1f, 0.35f, num);
					float num9 = (Mathf.PerlinNoise(unscaledTime * 23.3f, 0.2f) - 0.5f) * Mathf.Lerp(16f, 120f, num);
					GUI.color = new Color(0.92f, 0.94f, 1f, num8);
					GUI.DrawTexture(new Rect(num9, (float)num6, (float)Screen.width, (float)num7), (Texture)(object)Texture2D.whiteTexture, (ScaleMode)0);
				}
				GUI.color = color;
			}
		}

		private bool CanUseMenuHotkey()
		{
			if (_ignoreHotkeysWhenTyping.Value)
			{
				return !IsAnyTextInputFocused();
			}
			return true;
		}

		private static bool IsAnyTextInputFocused()
		{
			try
			{
				Type type = Type.GetType("UnityEngine.EventSystems.EventSystem, UnityEngine.UI");
				if (type == null)
				{
					return false;
				}
				object obj = type.GetProperty("current", BindingFlags.Static | BindingFlags.Public)?.GetValue(null);
				if (obj == null)
				{
					return false;
				}
				object? obj2 = type.GetProperty("currentSelectedGameObject", BindingFlags.Instance | BindingFlags.Public)?.GetValue(obj);
				GameObject val = (GameObject)((obj2 is GameObject) ? obj2 : null);
				if ((Object)(object)val == (Object)null)
				{
					return false;
				}
				Component[] components = val.GetComponents<Component>();
				for (int i = 0; i < components.Length; i++)
				{
					string a = ((object)components[i])?.GetType().Name;
					if (string.Equals(a, "InputField", StringComparison.Ordinal) || string.Equals(a, "TMP_InputField", StringComparison.Ordinal))
					{
						return true;
					}
				}
			}
			catch
			{
			}
			return false;
		}

		private void DrawWindow(int _)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			InitStyles();
			Color contentColor = GUI.contentColor;
			GUI.contentColor = UiInk;
			GUILayout.Label("Shader Playground", _menuTitleStyle ?? GUI.skin.label, Array.Empty<GUILayoutOption>());
			GUILayout.Label("Standalone shader stack (no VisualLab bridge).", _subtitleStyle ?? GUI.skin.label, Array.Empty<GUILayoutOption>());
			DrawPastelTabs();
			GUILayout.Space(8f);
			float num = Mathf.Clamp(((Rect)(ref _windowRect)).height - 130f, 120f, Mathf.Max(120f, ((Rect)(ref _windowRect)).height - 70f));
			_scroll = GUILayout.BeginScrollView(_scroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num) });
			bool changed = false;
			switch (_activeTab)
			{
			case UiTab.Core:
				DrawCoreTab(ref changed);
				break;
			case UiTab.Effects:
				DrawEffectsTab(ref changed);
				break;
			case UiTab.Experimental:
				DrawExperimentalTab(ref changed);
				break;
			case UiTab.World:
				DrawWorldTab(ref changed);
				break;
			case UiTab.AdvancedColor:
				DrawAdvancedColorTab(ref changed);
				break;
			case UiTab.Quality:
				DrawQualityTab(ref changed);
				break;
			case UiTab.Presets:
				DrawPresetTab(ref changed);
				break;
			case UiTab.Tools:
				DrawToolsTab(ref changed);
				break;
			}
			GUILayout.EndScrollView();
			if (changed)
			{
				Commit("ui-change", notify: false);
			}
			GUILayout.FlexibleSpace();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("✔ Keep It!", _actionBtnStyle ?? _buttonStyle ?? GUI.skin.button, Array.Empty<GUILayoutOption>()))
			{
				Commit("manual", notify: true);
			}
			if (GUILayout.Button("✖ Not Today", _secondaryButtonStyle ?? _buttonStyle ?? GUI.skin.button, Array.Empty<GUILayoutOption>()))
			{
				_showWindow = false;
				_windowVisibleConfig.Value = false;
			}
			GUILayout.EndHorizontal();
			GUI.contentColor = contentColor;
			GUI.DragWindow(new Rect(0f, 0f, 10000f, 10000f));
		}

		private void DrawPastelTabs()
		{
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			for (int i = 0; i < UiTabLabels.Length; i++)
			{
				bool flag = i == (int)_activeTab;
				GUIStyle val = (GUIStyle)((!flag) ? (_tabStyle ?? _tabInactiveStyle ?? GUI.skin.button) : ((_tabActiveStyles != null && i < _tabActiveStyles.Length) ? ((object)_tabActiveStyles[i]) : ((object)(_buttonStyle ?? GUI.skin.button))));
				if (GUILayout.Button(UiTabLabels[i], val, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Height(34f),
					GUILayout.ExpandWidth(true)
				}) && !flag)
				{
					_activeTab = (UiTab)Mathf.Clamp(i, 0, UiTabLabels.Length - 1);
					_scroll = Vector2.zero;
				}
			}
			GUILayout.EndHorizontal();
		}

		private int DrawSegmentedButtons(int selected, string[] labels)
		{
			int num = Mathf.Clamp(selected, 0, labels.Length - 1);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			for (int i = 0; i < labels.Length; i++)
			{
				GUIStyle val = ((i == num) ? (_secondaryButtonStyle ?? _buttonStyle ?? GUI.skin.button) : (_tabStyle ?? _tabInactiveStyle ?? GUI.skin.button));
				if (GUILayout.Button(labels[i], val, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Height(30f),
					GUILayout.ExpandWidth(true)
				}))
				{
					num = i;
				}
			}
			GUILayout.EndHorizontal();
			return num;
		}

		private void DrawCoreTab(ref bool changed)
		{
			BeginSection("Core Runtime");
			changed |= Toggle(_masterEnabled, "Master Enabled");
			changed |= Toggle(_syncEnabled, "Sync Enabled");
			changed |= Toggle(_localOnlyMode, "Local Only");
			changed |= Toggle(_acceptHostSync, "Allow Host Sync");
			if (_acceptHostSync.Value && _localOnlyMode.Value)
			{
				_localOnlyMode.Value = false;
				changed = true;
			}
			changed |= Toggle(_showNotifications, "Show Notifications");
			changed |= SliderRow("Notification Min Interval", _notificationMinIntervalSeconds, 0.2f, 5f, "0.00");
			changed |= Toggle(_enableShaderPass, "Enable Shader Pass");
			changed |= Toggle(_forceVolumeFallback, "Force Volume Fallback");
			changed |= Toggle(_enableOtApiIntegration, "Enable otAPI Controls");
			if (_syncEnabled.Value && (_localOnlyMode.Value || !_acceptHostSync.Value))
			{
				GUILayout.Label("Host sync disabled by config (Local Only or Allow Host Sync is off).", Array.Empty<GUILayoutOption>());
			}
			EndSection();
		}

		private void DrawEffectsTab(ref bool changed)
		{
			BeginSection("Post FX Stack");
			if (IsClientOnly() && _syncEnabled.Value && !_localOnlyMode.Value && _acceptHostSync.Value)
			{
				GUILayout.Label("Host sync is active. Host profile updates can override local effect edits.", Array.Empty<GUILayoutOption>());
			}
			changed |= EffectRow("Fisheye", _crtEnabled, _crtIntensity, 0f, 0.1f);
			changed |= EffectRow("Dream Bloom", _dreamEnabled, _dreamIntensity);
			changed |= EffectRow("Comic/Sketch", _comicEnabled, _comicIntensity);
			changed |= EffectRow("Breathing", _heatwaveEnabled, _heatwaveIntensity, 0f, 0.05f);
			changed |= SliderRow("Breathing Speed", _heatwaveSpeed, 0.2f, 4f, "0.00");
			changed |= EffectRow("Noir", _noirEnabled, _noirIntensity);
			changed |= EffectRow("Vapor", _vaporEnabled, _vaporIntensity);
			changed |= EffectRow("Posterize", _posterizeEnabled, _posterizeIntensity);
			changed |= EffectRow("Pixelate", _pixelateEnabled, _pixelateIntensity);
			changed |= EffectRow("Chromatic Split", _chromaticSplitEnabled, _chromaticSplitIntensity);
			changed |= EffectRow("Dither", _ditherEnabled, _ditherIntensity);
			changed |= EffectRow("Motion Blur", _motionBlurEnabled, _motionBlurIntensity);
			changed |= EffectRow("Depth of Field", _depthOfFieldEnabled, _depthOfFieldIntensity);
			changed |= SliderRow("Lens Center X", _lensCenterX, -1f, 2f, "0.00");
			changed |= SliderRow("Lens Center Y", _lensCenterY, -1f, 2f, "0.00");
			EndSection();
		}

		private void DrawWorldTab(ref bool changed)
		{
			BeginSection("World Overhaul");
			changed |= Toggle(_enhancedSkyEnabled, "Enhanced Sky + Lighting");
			changed |= SliderRow("Sky Intensity", _skyIntensity, 0f, 1f, "0.00");
			changed |= SliderRow("Sky Exposure", _skyExposure, 0.05f, 2.5f, "0.00");
			changed |= SliderRow("Sky Hue Shift", _skyHueShift, -180f, 180f, "0");
			changed |= SliderRow("Sky Color Blend", _skyColorBlend, 0f, 1f, "0.00");
			GUILayout.Label("Skybox Style", _bodyLabelStyle ?? GUI.skin.label, Array.Empty<GUILayoutOption>());
			int num = DrawSegmentedButtons(Mathf.Clamp(_skyboxMaterialIndex.Value, 0, SkyboxStyleLabels.Length - 1), SkyboxStyleLabels);
			if (num != _skyboxMaterialIndex.Value)
			{
				_skyboxMaterialIndex.Value = num;
				changed = true;
			}
			changed |= SliderRow("Sun Intensity", _sunIntensityMultiplier, 0f, 3f, "0.00");
			changed |= SliderRow("Sun Temperature", _sunTemperature, 1000f, 20000f, "0");
			changed |= SliderRow("Sun Color R", _sunColorR, 0f, 1f, "0.00");
			changed |= SliderRow("Sun Color G", _sunColorG, 0f, 1f, "0.00");
			changed |= SliderRow("Sun Color B", _sunColorB, 0f, 1f, "0.00");
			changed |= SliderRow("Sun Color Blend", _sunColorBlend, 0f, 1f, "0.00");
			changed |= Toggle(_cloudLayersEnabled, "Cloud Layering");
			changed |= SliderRow("Cloud Density", _cloudDensity, 0f, 1f, "0.00");
			changed |= Toggle(_weatherSystemEnabled, "Daily Weather System");
			GUILayout.Label("Weather Mode", _bodyLabelStyle ?? GUI.skin.label, Array.Empty<GUILayoutOption>());
			int num2 = DrawSegmentedButtons(Mathf.Clamp(_weatherMode.Value, 0, 5), new string[6] { "Auto", "Clear", "Golden", "Overcast", "Storm", "Dream" });
			if (num2 != _weatherMode.Value)
			{
				_weatherMode.Value = num2;
				changed = true;
			}
			changed |= SliderRow("Weather Strength", _weatherStrength, 0f, 1f, "0.00");
			changed |= Toggle(_waterOverrideEnabled, "Realistic Water");
			bool enabled = GUI.enabled;
			GUI.enabled = enabled && _waterOverrideEnabled.Value;
			changed |= ReverseSliderRow("Underwater Clarity", _waterClarity, 0f, 1f, "0.00");
			changed |= SliderRow("Water Wave Strength", _waterWaveStrength, 0f, 1f, "0.00");
			GUI.enabled = enabled;
			EndSection();
		}

		private void DrawExperimentalTab(ref bool changed)
		{
			BeginSection("Experimental");
			GUILayout.Label("Effects in this tab are work-in-progress and may change between builds.", Array.Empty<GUILayoutOption>());
			changed |= EffectRow("Anamorphic Bloom", _anamorphicBloomEnabled, _anamorphicBloomIntensity);
			GUILayout.Label("Adds cinematic horizontal light streak flavor to bright highlights.", Array.Empty<GUILayoutOption>());
			changed |= EffectRow("Halftone", _halftoneEnabled, _halftoneIntensity);
			bool enabled = GUI.enabled;
			GUI.enabled = enabled && _halftoneEnabled.Value;
			changed |= SliderRow("Halftone Dot Size", _halftoneDotSize, 0.25f, 8f, "0.00");
			changed |= SliderRow("Halftone Angle", _halftoneAngle, 0f, 180f, "0");
			GUI.enabled = enabled;
			GUILayout.Label("Comic print dot quantization with controllable dot size and angle.", Array.Empty<GUILayoutOption>());
			changed |= EffectRow("Kuwahara/Oil Paint", _kuwaharaEnabled, _kuwaharaIntensity);
			bool enabled2 = GUI.enabled;
			GUI.enabled = enabled2 && _kuwaharaEnabled.Value;
			changed |= SliderRow("Kuwahara Radius", _kuwaharaRadius, 1f, 6f, "0.0");
			GUI.enabled = enabled2;
			GUILayout.Label("Painterly smoothing pass for soft oil-paint style regions.", Array.Empty<GUILayoutOption>());
			changed |= EffectRow("Selective Color", _selectiveColorEnabled, _selectiveColorIntensity);
			bool enabled3 = GUI.enabled;
			GUI.enabled = enabled3 && _selectiveColorEnabled.Value;
			changed |= SliderRow("Selective Hue", _selectiveColorHue, 0f, 360f, "0");
			changed |= SliderRow("Selective Range", _selectiveColorRange, 1f, 180f, "0");
			changed |= SliderRow("Selective Softness", _selectiveColorSoftness, 0f, 1f, "0.00");
			GUI.enabled = enabled3;
			GUILayout.Label("Keeps one hue range saturated while desaturating the rest.", Array.Empty<GUILayoutOption>());
			changed |= EffectRow("Radial Blur", _radialBlurEnabled, _radialBlurIntensity);
			GUILayout.Label("Center-based blur for dream/warp moments (uses Lens Center X/Y as origin).", Array.Empty<GUILayoutOption>());
			changed |= EffectRow("Lens Dirt", _lensDirtEnabled, _lensDirtIntensity);
			GUILayout.Label("Bloom reacts through a procedural lens dirt texture overlay.", Array.Empty<GUILayoutOption>());
			changed |= EffectRow("Rain-on-Lens", _rainOnLensEnabled, _rainOnLensIntensity);
			GUILayout.Label("Animated droplets and lens distortion for rainy, wet-camera moments.", Array.Empty<GUILayoutOption>());
			changed |= EffectRow("Caustics Overlay", _causticsOverlayEnabled, _causticsOverlayIntensity);
			GUILayout.Label("Moving water-light patterns on world surfaces using material overrides.", Array.Empty<GUILayoutOption>());
			changed |= EffectRow("Volumetric Fog Tint", _volumetricFogTintEnabled, _volumetricFogTintIntensity);
			bool enabled4 = GUI.enabled;
			GUI.enabled = enabled4 && _volumetricFogTintEnabled.Value;
			changed |= SliderRow("Fog Hue", _volumetricFogTintHue, 0f, 360f, "0");
			changed |= SliderRow("Fog Density Shaping", _volumetricFogTintDensity, 0f, 1f, "0.00");
			GUI.enabled = enabled4;
			GUILayout.Label("Stylized fog color + density shaping for atmospheric volume mood.", Array.Empty<GUILayoutOption>());
			changed |= EffectRow("Godray Fake", _godrayFakeEnabled, _godrayFakeIntensity);
			GUILayout.Label("Cheap sun-direction screen rays approximation using bloom/vignette/post-exposure.", Array.Empty<GUILayoutOption>());
			changed |= EffectRow("Film Gate", _filmGateEnabled, _filmGateIntensity);
			GUILayout.Label("Letterbox bars, subtle camera jitter, and grain for movie mode.", Array.Empty<GUILayoutOption>());
			changed |= EffectRow("Glitch Pack", _glitchPackEnabled, _glitchPackIntensity, 0f, 0.1f);
			GUILayout.Label("Scanline jitter, channel offset jumps, and digital tearing.", Array.Empty<GUILayoutOption>());
			GUILayout.Space(8f);
			GUILayout.Label("Color LUT Blend", Array.Empty<GUILayoutOption>());
			changed |= Toggle(_lutBlendEnabled, "Enable LUT Blend");
			changed |= SliderRow("LUT Blend", _lutBlendAmount, 0f, 1f, "0.00");
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("LUT A", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(52f) });
			string text = GUILayout.TextField(_lutPathAUi ?? string.Empty, _textFieldStyle ?? GUI.skin.textField, Array.Empty<GUILayoutOption>());
			if (!string.Equals(text, _lutPathAUi, StringComparison.Ordinal))
			{
				_lutPathAUi = text;
			}
			if (GUILayout.Button("Set A", _buttonStyle ?? GUI.skin.button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }))
			{
				changed |= UpdateLutPathAFromUi();
			}
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("LUT B", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(52f) });
			string text2 = GUILayout.TextField(_lutPathBUi ?? string.Empty, _textFieldStyle ?? GUI.skin.textField, Array.Empty<GUILayoutOption>());
			if (!string.Equals(text2, _lutPathBUi, StringComparison.Ordinal))
			{
				_lutPathBUi = text2;
			}
			if (GUILayout.Button("Set B", _buttonStyle ?? GUI.skin.button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }))
			{
				changed |= UpdateLutPathBFromUi();
			}
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Reload LUTs", _buttonStyle ?? GUI.skin.button, Array.Empty<GUILayoutOption>()))
			{
				ForceReloadLutTextures();
			}
			GUILayout.Label("A: " + DescribeLutTexture(_lutTextureA), Array.Empty<GUILayoutOption>());
			GUILayout.Label("B: " + DescribeLutTexture(_lutTextureB), Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.Label("Expected LUT format: strip (width = height*height), e.g. 1024x32.", Array.Empty<GUILayoutOption>());
			EndSection();
		}

		private void DrawQualityTab(ref bool changed)
		{
			BeginSection("Image Quality");
			GUILayout.Label("Runtime Quality Tier", _bodyLabelStyle ?? GUI.skin.label, Array.Empty<GUILayoutOption>());
			int num = DrawSegmentedButtons(Mathf.Clamp(_qualityTier.Value, 0, 2), new string[3] { "Low", "Medium", "High" });
			if (num != _qualityTier.Value)
			{
				_qualityTier.Value = num;
				changed = true;
			}
			GUILayout.Label("AA Preset", _bodyLabelStyle ?? GUI.skin.label, Array.Empty<GUILayoutOption>());
			int num2 = DrawSegmentedButtons(Mathf.Clamp(_antiAliasingPreset.Value, 0, 4), new string[5] { "Off", "FXAA", "SMAA", "TAA", "CAS" });
			if (num2 != _antiAliasingPreset.Value)
			{
				_antiAliasingPreset.Value = num2;
				changed = true;
			}
			changed |= SliderRow("CAS Sharpening", _casSharpening, 0f, 1f, "0.00");
			EndSection();
		}

		private void DrawAdvancedColorTab(ref bool changed)
		{
			BeginSection("Tonemapping");
			GUILayout.Label("Tonemapping Mode", _bodyLabelStyle ?? GUI.skin.label, Array.Empty<GUILayoutOption>());
			int num = DrawSegmentedButtons(Mathf.Clamp(_tonemappingMode.Value, 0, 2), new string[3] { "Off", "Neutral", "ACES" });
			if (num != _tonemappingMode.Value)
			{
				_tonemappingMode.Value = num;
				changed = true;
			}
			EndSection();
			BeginSection("White Balance");
			changed |= Toggle(_whiteBalanceEnabled, "Enabled");
			bool enabled = GUI.enabled;
			GUI.enabled = enabled && _whiteBalanceEnabled.Value;
			changed |= SliderRow("Temperature", _whiteBalanceTemperature, -100f, 100f, "0");
			changed |= SliderRow("Tint", _whiteBalanceTint, -100f, 100f, "0");
			GUI.enabled = enabled;
			EndSection();
			BeginSection("Lift / Gamma / Gain");
			changed |= Toggle(_liftGammaGainEnabled, "Enabled");
			bool enabled2 = GUI.enabled;
			GUI.enabled = enabled2 && _liftGammaGainEnabled.Value;
			changed |= SliderRow("Lift", _liftAmount, -1f, 1f, "0.00");
			changed |= SliderRow("Gamma", _gammaAmount, 0f, 2f, "0.00");
			changed |= SliderRow("Gain", _gainAmount, 0f, 2f, "0.00");
			GUI.enabled = enabled2;
			EndSection();
			BeginSection("Split Toning");
			changed |= Toggle(_splitToningEnabled, "Enabled");
			bool enabled3 = GUI.enabled;
			GUI.enabled = enabled3 && _splitToningEnabled.Value;
			GUILayout.Label("Shadows Tint", Array.Empty<GUILayoutOption>());
			changed |= SliderRow("Shadows R", _splitShadowsR, 0f, 1f, "0.00");
			changed |= SliderRow("Shadows G", _splitShadowsG, 0f, 1f, "0.00");
			changed |= SliderRow("Shadows B", _splitShadowsB, 0f, 1f, "0.00");
			GUILayout.Label("Highlights Tint", Array.Empty<GUILayoutOption>());
			changed |= SliderRow("Highlights R", _splitHighlightsR, 0f, 1f, "0.00");
			changed |= SliderRow("Highlights G", _splitHighlightsG, 0f, 1f, "0.00");
			changed |= SliderRow("Highlights B", _splitHighlightsB, 0f, 1f, "0.00");
			changed |= SliderRow("Balance", _splitToningBalance, -100f, 100f, "0");
			GUI.enabled = enabled3;
			EndSection();
		}

		private void DrawPresetTab(ref bool changed)
		{
			BeginSection("✨ Built-in Vibes");
			BeginSubCard("Mood Presets");
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("☀ Clean", _buttonStyle ?? GUI.skin.button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) }))
			{
				ApplyPreset(PresetKind.Clean);
				changed = true;
			}
			if (GUILayout.Button("\ud83c\udf9e Noir", _buttonStyle ?? GUI.skin.button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) }))
			{
				ApplyPreset(PresetKind.Noir);
				changed = true;
			}
			if (GUILayout.Button("\ud83c\udf29 Stormfront", _buttonStyle ?? GUI.skin.button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) }))
			{
				ApplyPreset(PresetKind.Stormfront);
				changed = true;
			}
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("\ud83c\udf19 Night Time", _buttonStyle ?? GUI.skin.button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) }))
			{
				ApplyPreset(PresetKind.NightTime);
				changed = true;
			}
			if (GUILayout.Button("\ud83c\udf11 Pitch Black", _buttonStyle ?? GUI.skin.button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) }))
			{
				ApplyPreset(PresetKind.PitchBlack);
				changed = true;
			}
			if (GUILayout.Button("\ud83d\udc96 Dreamy Style", _buttonStyle ?? GUI.skin.button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) }))
			{
				ApplyPreset(PresetKind.DreamyStyle);
				changed = true;
			}
			GUILayout.EndHorizontal();
			EndSubCard();
			BeginSubCard("My Personal Collection");
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("\ud83d\udcbe Save New Look", _buttonStyle ?? GUI.skin.button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(34f) }))
			{
				_savedProfileJson.Value = JsonUtility.ToJson((object)BuildState("save-slot"));
			}
			if (GUILayout.Button("\ud83d\udcc2 Load a Look", _buttonStyle ?? GUI.skin.button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(34f) }))
			{
				LoadSavedSlot();
			}
			GUILayout.EndHorizontal();
			EndSubCard();
			EndSection();
		}

		private void DrawToolsTab(ref bool changed)
		{
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			BeginSection("Scanner + Diagnostics");
			changed |= Toggle(_scannerLogOnSceneLoad, "Log Scanner On Scene Load");
			if (GUILayout.Button("Run Material/Shader Scanner", _buttonStyle ?? GUI.skin.button, Array.Empty<GUILayoutOption>()))
			{
				RunMaterialScanner(logToConsole: true);
			}
			GUILayout.Label($"Renderers: {_scanRenderers.Count} | Unique shaders: {_shaderCounts.Count}", _bodyLabelStyle ?? GUI.skin.label, Array.Empty<GUILayoutOption>());
			if (_scanSummaryLines.Count > 0)
			{
				GUILayout.Label("Top shader matches:", _bodyLabelStyle ?? GUI.skin.label, Array.Empty<GUILayoutOption>());
				for (int i = 0; i < Mathf.Min(_scanSummaryLines.Count, 10); i++)
				{
					GUILayout.Label(_scanSummaryLines[i], _bodyLabelStyle ?? GUI.skin.label, Array.Empty<GUILayoutOption>());
				}
			}
			EndSection();
			BeginSection("Handshake + Sync Log");
			changed |= Toggle(_enableBuiltInSyncLog, "Enable Built-In Sync Log");
			changed |= Toggle(_syncLogToBepInEx, "Write Sync Events To BepInEx Log");
			changed |= Toggle(_syncLogIncludeKeepalive, "Include Keepalive Events");
			changed |= Toggle(_strictSnapshotHashValidation, "Strict Snapshot Hash Validation");
			GUILayout.Label($"State: {_clientSyncState} ({_clientSyncStatusReason})", _bodyLabelStyle ?? GUI.skin.label, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"Host Sender: {_expectedHostSenderId} | Host Steam: {_expectedHostSteamId}", _bodyLabelStyle ?? GUI.skin.label, Array.Empty<GUILayoutOption>());
			GUILayout.Label("Epoch: " + FormatForUi(_activeSessionEpoch), _bodyLabelStyle ?? GUI.skin.label, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"Last Accepted: rev={_lastAcceptedRevision} hash={FormatForUi(_lastAcceptedStateHash)}", _bodyLabelStyle ?? GUI.skin.label, Array.Empty<GUILayoutOption>());
			GUILayout.Label("Last Event: " + FormatForUi(_lastSyncEvent), _bodyLabelStyle ?? GUI.skin.label, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Clear Sync Log", _buttonStyle ?? GUI.skin.button, Array.Empty<GUILayoutOption>()))
			{
				_syncEventLog.Clear();
				_syncLogScroll = Vector2.zero;
				_lastSyncEvent = "cleared";
			}
			if (GUILayout.Button("Log Status Snapshot", _buttonStyle ?? GUI.skin.button, Array.Empty<GUILayoutOption>()))
			{
				EmitSyncEvent("status_snapshot", $"state={_clientSyncState} reason={_clientSyncStatusReason} expectedHostSender={_expectedHostSenderId} expectedHostSteam={_expectedHostSteamId} epoch={_activeSessionEpoch} lastRev={_lastAcceptedRevision} lastHash={_lastAcceptedStateHash}");
			}
			GUILayout.EndHorizontal();
			float num = Mathf.Clamp(((Rect)(ref _windowRect)).height * 0.28f, 120f, 220f);
			_syncLogScroll = GUILayout.BeginScrollView(_syncLogScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num) });
			if (_syncEventLog.Count == 0)
			{
				GUILayout.Label("No sync events yet.", _bodyLabelStyle ?? GUI.skin.label, Array.Empty<GUILayoutOption>());
			}
			else
			{
				for (int num2 = _syncEventLog.Count - 1; num2 >= 0; num2--)
				{
					GUILayout.Label(_syncEventLog[num2], _bodyLabelStyle ?? GUI.skin.label, Array.Empty<GUILayoutOption>());
				}
			}
			GUILayout.EndScrollView();
			EndSection();
		}

		private void ApplyPreset(PresetKind preset)
		{
			ClearPresetShaderState();
			_enhancedSkyEnabled.Value = true;
			_cloudLayersEnabled.Value = true;
			_weatherSystemEnabled.Value = true;
			_waterOverrideEnabled.Value = true;
			_forceVolumeFallback.Value = false;
			_qualityTier.Value = 1;
			_antiAliasingPreset.Value = 2;
			_casSharpening.Value = 0.3f;
			_tonemappingMode.Value = 0;
			_whiteBalanceEnabled.Value = false;
			_whiteBalanceTemperature.Value = 0f;
			_whiteBalanceTint.Value = 0f;
			_liftGammaGainEnabled.Value = false;
			_liftAmount.Value = 0f;
			_gammaAmount.Value = 1f;
			_gainAmount.Value = 1f;
			_splitToningEnabled.Value = false;
			_splitShadowsR.Value = 0.5f;
			_splitShadowsG.Value = 0.5f;
			_splitShadowsB.Value = 0.5f;
			_splitHighlightsR.Value = 0.5f;
			_splitHighlightsG.Value = 0.5f;
			_splitHighlightsB.Value = 0.5f;
			_splitToningBalance.Value = 0f;
			_pixelateEnabled.Value = false;
			_pixelateIntensity.Value = 0f;
			_chromaticSplitEnabled.Value = false;
			_chromaticSplitIntensity.Value = 0f;
			_ditherEnabled.Value = false;
			_ditherIntensity.Value = 0f;
			_lensCenterX.Value = 0.5f;
			_lensCenterY.Value = 0.5f;
			_skyboxMaterialIndex.Value = 0;
			_skyExposure.Value = 1f;
			_sunIntensityMultiplier.Value = 1f;
			_sunTemperature.Value = ((_baseSunTemperature > 0f) ? _baseSunTemperature : 6500f);
			_sunColorR.Value = 1f;
			_sunColorG.Value = 0.97f;
			_sunColorB.Value = 0.9f;
			_sunColorBlend.Value = 0f;
			_crtEnabled.Value = false;
			_crtIntensity.Value = 0f;
			_dreamEnabled.Value = false;
			_dreamIntensity.Value = 0f;
			_comicEnabled.Value = false;
			_comicIntensity.Value = 0f;
			_heatwaveEnabled.Value = false;
			_heatwaveIntensity.Value = 0f;
			_heatwaveSpeed.Value = 1f;
			_noirEnabled.Value = false;
			_noirIntensity.Value = 0f;
			_vaporEnabled.Value = false;
			_vaporIntensity.Value = 0f;
			_posterizeEnabled.Value = false;
			_posterizeIntensity.Value = 0f;
			_motionBlurEnabled.Value = false;
			_motionBlurIntensity.Value = 0f;
			_depthOfFieldEnabled.Value = false;
			_depthOfFieldIntensity.Value = 0f;
			_anamorphicBloomEnabled.Value = false;
			_anamorphicBloomIntensity.Value = 0f;
			_halftoneEnabled.Value = false;
			_halftoneIntensity.Value = 0f;
			_halftoneDotSize.Value = 1.25f;
			_halftoneAngle.Value = 45f;
			_kuwaharaEnabled.Value = false;
			_kuwaharaIntensity.Value = 0f;
			_kuwaharaRadius.Value = 2f;
			_selectiveColorEnabled.Value = false;
			_selectiveColorIntensity.Value = 0f;
			_selectiveColorHue.Value = 0f;
			_selectiveColorRange.Value = 35f;
			_selectiveColorSoftness.Value = 0.25f;
			_radialBlurEnabled.Value = false;
			_radialBlurIntensity.Value = 0f;
			_lensDirtEnabled.Value = false;
			_lensDirtIntensity.Value = 0f;
			_rainOnLensEnabled.Value = false;
			_rainOnLensIntensity.Value = 0f;
			_causticsOverlayEnabled.Value = false;
			_causticsOverlayIntensity.Value = 0f;
			_godrayFakeEnabled.Value = false;
			_godrayFakeIntensity.Value = 0f;
			_filmGateEnabled.Value = false;
			_filmGateIntensity.Value = 0f;
			_glitchPackEnabled.Value = false;
			_glitchPackIntensity.Value = 0f;
			_volumetr