Decompiled source of LegacyFogSystem v0.0.2

plugins/LegacyFogSystem.dll

Decompiled 2 months ago
using System;
using System.CodeDom.Compiler;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using CullingSystem;
using GTFO.API;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LegacyFogSystem.Systems;
using LegacyFogSystem.Systems.Buffers;
using LegacyFogSystem.Systems.Debugs;
using Microsoft.CodeAnalysis;
using Player;
using UnityEngine;
using UnityEngine.PostProcessing;
using UnityEngine.Rendering;
using UnityEngine.Rendering.PostProcessing;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("LegacyFogSystem")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LegacyFogSystem")]
[assembly: AssemblyTitle("LegacyFogSystem")]
[assembly: TargetPlatform("Windows7.0")]
[assembly: SupportedOSPlatform("Windows7.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LegacyFogSystem
{
	internal enum PostProcessingPipeline
	{
		Unchanged,
		Legacy,
		Mixed
	}
	internal static class CFG
	{
		internal static void Init(ConfigFile cfg)
		{
			ConfigEntry<bool> val = cfg.Bind<bool>("User", "Reduce Fog Density", false, "Reduce Fog Density by 35% (Useful for R6+ Rundowns)");
			ConfigEntry<PostProcessingPipeline> val2 = cfg.Bind<PostProcessingPipeline>("User", "Post Processing Pipeline", PostProcessingPipeline.Legacy, "Aka Shader Type to use // Unchanged is R6's lighting // Legacy is Old rundowns settings // Mixed is in between Default and Legacy");
			LegacyLitVolume.DensityMultiplier = (val.Value ? 0.35f : 1f);
			PostProcessingObserver.Pipeline = val2.Value;
		}
	}
	[BepInPlugin("LegacyFogSystem", "LegacyFogSystem", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class EntryPoint : BasePlugin
	{
		private Harmony _Harmony = null;

		public override void Load()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			ClassInjector.RegisterTypeInIl2Cpp<LegacyLitVolume>();
			ClassInjector.RegisterTypeInIl2Cpp<AtlasDebugger>();
			ClassInjector.RegisterTypeInIl2Cpp<PostProcessingObserver>();
			_Harmony = new Harmony("LegacyFogSystem.Harmony");
			_Harmony.PatchAll();
			CFG.Init(((BasePlugin)this).Config);
		}

		public override bool Unload()
		{
			_Harmony.UnpatchSelf();
			return ((BasePlugin)this).Unload();
		}
	}
	internal static class Logger
	{
		private static readonly ManualLogSource _Logger;

		static Logger()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			_Logger = new ManualLogSource("LegacyFogSystem");
			Logger.Sources.Add((ILogSource)(object)_Logger);
		}

		private static string Format(object msg)
		{
			return msg.ToString();
		}

		public static void Info(BepInExInfoLogInterpolatedStringHandler handler)
		{
			_Logger.LogInfo(handler);
		}

		public static void Info(string str)
		{
			_Logger.LogMessage((object)str);
		}

		public static void Info(object data)
		{
			_Logger.LogMessage((object)Format(data));
		}

		public static void Debug(BepInExDebugLogInterpolatedStringHandler handler)
		{
			_Logger.LogDebug(handler);
		}

		public static void Debug(string str)
		{
			_Logger.LogDebug((object)str);
		}

		public static void Debug(object data)
		{
			_Logger.LogDebug((object)Format(data));
		}

		public static void Error(BepInExErrorLogInterpolatedStringHandler handler)
		{
			_Logger.LogError(handler);
		}

		public static void Error(string str)
		{
			_Logger.LogError((object)str);
		}

		public static void Error(object data)
		{
			_Logger.LogError((object)Format(data));
		}

		public static void Fatal(BepInExFatalLogInterpolatedStringHandler handler)
		{
			_Logger.LogFatal(handler);
		}

		public static void Fatal(string str)
		{
			_Logger.LogFatal((object)str);
		}

		public static void Fatal(object data)
		{
			_Logger.LogFatal((object)Format(data));
		}

		public static void Warn(BepInExWarningLogInterpolatedStringHandler handler)
		{
			_Logger.LogWarning(handler);
		}

		public static void Warn(string str)
		{
			_Logger.LogWarning((object)str);
		}

		public static void Warn(object data)
		{
			_Logger.LogWarning((object)Format(data));
		}

		[Conditional("DEBUG")]
		public static void DebugOnly(object data)
		{
			_Logger.LogDebug((object)Format(data));
		}
	}
	internal static class CommandBufferExtensions
	{
		public static void DispatchCompute(this CommandBuffer cmd, ComputeShader cs, int kernel, int[] groupCount)
		{
			cmd.DispatchCompute(cs, kernel, groupCount[0], groupCount[1], groupCount[2]);
		}
	}
	[GeneratedCode("VersionInfoGenerator", "2.1.3+git35c0c2a-master")]
	[CompilerGenerated]
	internal static class VersionInfo
	{
		public const string RootNamespace = "LegacyFogSystem";

		public const string Version = "1.0.0";

		public const string VersionPrerelease = null;

		public const string VersionMetadata = null;

		public const string SemVer = "1.0.0";

		public const string GitRevShort = null;

		public const string GitRevLong = null;

		public const string GitBranch = null;

		public const string GitTag = null;

		public const int GitCommitsSinceTag = 0;

		public const bool GitIsDirty = false;
	}
}
namespace LegacyFogSystem.Systems
{
	internal sealed class LegacyLitVolume : MonoBehaviour
	{
		private LitBuffer<sCL_SpotLight> _CB_SpotLight;

		private LitBuffer<sCL_PointLight> _CB_PointLight;

		private LitBuffer<sCL_PointLight> _CB_EffectLight;

		private LitBuffer<sCL_FogSphere> _CB_FogSphere;

		public Color FogColor;

		public float FogAmbience;

		public float FogRange = 40f;

		public float LightAttenuation = 0.035f;

		public float DepthExponent = 2f;

		public float Density;

		public float DensityHeightMaxBoost;

		public float DensityHeight;

		public float DensityHeightRange;

		public Texture3D DensityNoise;

		public Vector3 DensityNoiseDirection;

		public float DensityNoiseSpeed;

		public float DensityNoiseScale;

		public ComputeShader CalcCS;

		public ComputeShader BlurCS;

		public Material BlendMat;

		private int _Kernel_Calc;

		private int _Kernel_Accumulate;

		private int _Kernel_Passthrough;

		private int _Kernel_GaussianBlur;

		private Camera _Cam;

		private CommandBuffer _CMD_Blend;

		private CommandBuffer _CMD_Calc;

		private Matrix4x4 _PrevInvProjection;

		private Matrix4x4 _PrevInvView;

		private float _HasPrevFrame = 0f;

		private float _ReprojectionBlend = 0f;

		public static float DensityMultiplier = 1f;

		public PreLitVolume PreLit;

		public float ActualSpotlightIrr = 1f;

		public float ActualPointlightIrr = 2.25f;

		public float ActualEffectlightIrr = 2.5f;

		public float ActualSpotlightRange = 1f;

		public float ActualSpotlightAngle = 1f;

		public float ActualPointlightRange = 1f;

		public float ActualEffectlightRange = 1f;

		public float ActualFogSphereIrr = 150f;

		private RenderTexture _RT_FrustumVoxel_Body;

		private RenderTexture _RT_FrustumVoxel_Reblend;

		private RenderTexture _RT_FrustumVoxel_Accumulate;

		private RenderTextureDescriptor _RTD_Froxel;

		private int _VoxelDepth;

		private int _VoxelWidth;

		private int _VoxelHeight;

		private readonly int[] _Calc_GroupCount = new int[3];

		private readonly int[] _Blur_GroupCount = new int[3];

		private readonly int[] _Accum_GroupCount = new int[3];

		private int _CurrentFogQuality = -1;

		private Resolution _CurrentRes;

		private int _ScrWidth;

		private int _ScrHeight;

		private Vector3 _NoiseOffset;

		private float _Coeff_Noise = 0.75f;

		private float _Coeff_Phase = 0f;

		private float _Coeff_Absorbtion = 0.087f;

		private float _Coeff_Extinction = 0.5f;

		private void Setup_ComputeBuffer()
		{
			_CB_SpotLight = new LitBuffer<sCL_SpotLight>(32);
			_CB_PointLight = new LitBuffer<sCL_PointLight>(32);
			_CB_EffectLight = new LitBuffer<sCL_PointLight>(32);
			_CB_FogSphere = new LitBuffer<sCL_FogSphere>(32);
		}

		private void Clear_ComputeBuffer()
		{
			_CB_SpotLight?.Dispose();
			_CB_SpotLight = null;
			_CB_PointLight?.Dispose();
			_CB_PointLight = null;
			_CB_EffectLight?.Dispose();
			_CB_EffectLight = null;
			_CB_FogSphere?.Dispose();
			_CB_FogSphere = null;
		}

		private void Start()
		{
			_Kernel_Calc = CalcCS.FindKernel("Calculate");
			_Kernel_Accumulate = CalcCS.FindKernel("Accumulate");
			_Kernel_Passthrough = BlurCS.FindKernel("Passthrough");
			_Kernel_GaussianBlur = BlurCS.FindKernel("GaussianBlur");
			_Cam = ((Component)this).GetComponent<Camera>();
			Setup_ComputeBuffer();
			Setup_CalcBuffer();
			Setup_BlendBuffer();
		}

		private void Update()
		{
			Update_CheckRes();
			Update_ShaderProperties();
		}

		private void OnPreCull()
		{
			Update_LinkPreLitVolume();
			Update_CalcBuffer();
			Update_BlendBuffer();
		}

		private void OnPreRender()
		{
			Update_CollectLight();
		}

		private void OnDestroy()
		{
			Clear_ComputeBuffer();
			Clear_RenderTextures();
			Clear_CalcBuffer();
			Clear_BlendBuffer();
		}

		private void Setup_BlendBuffer()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			_CMD_Blend = new CommandBuffer
			{
				name = "LitVolume Blend Cmd"
			};
			_Cam.AddCommandBuffer((CameraEvent)23, _CMD_Blend);
		}

		private void Update_BlendBuffer()
		{
			//IL_004c: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			if (_CMD_Blend != null && !((Object)(object)BlendMat == (Object)null))
			{
				_CMD_Blend.Clear();
				_CMD_Blend.GetTemporaryRT(SID.TEMP_Grab, -1, -1, 24, (FilterMode)0, (RenderTextureFormat)9);
				_CMD_Blend.Blit(RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)2), RenderTargetIdentifier.op_Implicit(SID.TEMP_Grab));
				_CMD_Blend.SetGlobalTexture("_MainTex", RenderTargetIdentifier.op_Implicit(SID.TEMP_Grab));
				_CMD_Blend.Blit(RenderTargetIdentifier.op_Implicit(SID.TEMP_Grab), RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)2), BlendMat);
				_CMD_Blend.ReleaseTemporaryRT(SID.TEMP_Grab);
			}
		}

		private void Clear_BlendBuffer()
		{
			if (_CMD_Blend != null)
			{
				_Cam.RemoveCommandBuffer((CameraEvent)23, _CMD_Blend);
				_CMD_Blend.Dispose();
				_CMD_Blend = null;
			}
		}

		private void Setup_CalcBuffer()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			_CMD_Calc = new CommandBuffer
			{
				name = "LitVolume Calc Cmd"
			};
			_Cam.AddCommandBuffer((CameraEvent)5, _CMD_Calc);
		}

		private void Update_CalcBuffer()
		{
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: 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_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			if (_CMD_Calc != null && !((Object)(object)_RT_FrustumVoxel_Body == (Object)null))
			{
				_CMD_Calc.Clear();
				UpdateParams(_CMD_Calc);
				_CMD_Calc.SetComputeBufferParam(CalcCS, _Kernel_Calc, SID.CB_PointLight, _CB_PointLight.CB);
				_CMD_Calc.SetComputeBufferParam(CalcCS, _Kernel_Calc, SID.CB_EffectLight, _CB_EffectLight.CB);
				_CMD_Calc.SetComputeBufferParam(CalcCS, _Kernel_Calc, SID.CB_SpotLight, _CB_SpotLight.CB);
				_CMD_Calc.SetComputeBufferParam(CalcCS, _Kernel_Calc, SID.CB_FogSphere, _CB_FogSphere.CB);
				_CMD_Calc.DispatchCompute(CalcCS, _Kernel_Calc, _Calc_GroupCount);
				_CMD_Calc.CopyTexture(RenderTargetIdentifier.op_Implicit((Texture)(object)_RT_FrustumVoxel_Body), RenderTargetIdentifier.op_Implicit((Texture)(object)_RT_FrustumVoxel_Reblend));
				Matrix4x4 val = GL.GetGPUProjectionMatrix(_Cam.projectionMatrix, false) * _Cam.worldToCameraMatrix;
				_CMD_Calc.SetComputeMatrixParam(CalcCS, SID.VF_Prev_VP, val);
				_CMD_Calc.DispatchCompute(CalcCS, _Kernel_Accumulate, _Accum_GroupCount);
				_CMD_Calc.GetTemporaryRT(SID.TEMP_BlurCopy, _RTD_Froxel, (FilterMode)2);
				_CMD_Calc.CopyTexture(RenderTargetIdentifier.op_Implicit((Texture)(object)_RT_FrustumVoxel_Accumulate), RenderTargetIdentifier.op_Implicit(SID.TEMP_BlurCopy));
				_CMD_Calc.SetComputeTextureParam(BlurCS, _Kernel_Passthrough, SID.Input, RenderTargetIdentifier.op_Implicit(SID.TEMP_BlurCopy));
				_CMD_Calc.SetComputeTextureParam(BlurCS, _Kernel_Passthrough, SID.Output, RenderTargetIdentifier.op_Implicit((Texture)(object)_RT_FrustumVoxel_Accumulate));
				_CMD_Calc.DispatchCompute(BlurCS, _Kernel_Passthrough, _Blur_GroupCount);
				_CMD_Calc.CopyTexture(RenderTargetIdentifier.op_Implicit((Texture)(object)_RT_FrustumVoxel_Accumulate), RenderTargetIdentifier.op_Implicit(SID.TEMP_BlurCopy));
				_CMD_Calc.SetComputeTextureParam(BlurCS, _Kernel_Passthrough, SID.Input, RenderTargetIdentifier.op_Implicit(SID.TEMP_BlurCopy));
				_CMD_Calc.SetComputeTextureParam(BlurCS, _Kernel_Passthrough, SID.Output, RenderTargetIdentifier.op_Implicit((Texture)(object)_RT_FrustumVoxel_Accumulate));
				_CMD_Calc.DispatchCompute(BlurCS, _Kernel_Passthrough, _Blur_GroupCount);
				_CMD_Calc.ReleaseTemporaryRT(SID.TEMP_BlurCopy);
			}
		}

		private void Clear_CalcBuffer()
		{
			if (_CMD_Calc != null)
			{
				_Cam.RemoveCommandBuffer((CameraEvent)5, _CMD_Calc);
				_CMD_Calc.Dispose();
				_CMD_Calc = null;
			}
		}

		private void UpdateParams(CommandBuffer cmd)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: 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_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			float nearClipPlane = _Cam.nearClipPlane;
			float farClipPlane = _Cam.farClipPlane;
			farClipPlane = Mathf.Clamp(FogRange, nearClipPlane, farClipPlane);
			Matrix4x4 val = Matrix4x4.Perspective(_Cam.fieldOfView, _Cam.aspect, nearClipPlane, farClipPlane);
			Matrix4x4 inverse = ((Matrix4x4)(ref val)).inverse;
			Matrix4x4 cameraToWorldMatrix = _Cam.cameraToWorldMatrix;
			Vector4 val2 = default(Vector4);
			((Vector4)(ref val2))..ctor(nearClipPlane, farClipPlane, (float)Time.frameCount, DepthExponent);
			BlendMat.SetVector(SID.VF_FogParams, val2);
			cmd.SetComputeVectorParam(CalcCS, SID.VF_FogParams, val2);
			cmd.SetComputeVectorParam(CalcCS, SID.VF_ReprojectionParams, new Vector4(_ReprojectionBlend, 1f, _HasPrevFrame, (_ReprojectionBlend > 0f) ? ((float)Time.frameCount) : 0f));
			cmd.SetComputeMatrixParam(CalcCS, SID.VF_Inv_Proj, inverse);
			cmd.SetComputeMatrixParam(CalcCS, SID.VF_Inv_View, cameraToWorldMatrix);
			BlendMat.SetMatrix(SID.VF_Inv_Proj, inverse);
			BlendMat.SetMatrix(SID.VF_Inv_View, cameraToWorldMatrix);
			cmd.SetComputeVectorParam(CalcCS, SID.VF_CameraWorldPos, Vector4.op_Implicit(((Component)_Cam).transform.position));
			_PrevInvProjection = inverse;
			_PrevInvView = cameraToWorldMatrix;
			_HasPrevFrame = 1f;
		}

		private void Update_LinkPreLitVolume()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)PreLit == (Object)null))
			{
				FogColor = PreLit.m_fogColor;
				FogAmbience = PreLit.m_fogAmbience;
				Density = PreLit.m_fogDensity * DensityMultiplier;
				DensityHeight = PreLit.m_densityHeightAltitude;
				DensityHeightRange = PreLit.m_densityHeightRange;
				DensityHeightMaxBoost = PreLit.m_densityHeightMaxBoost * DensityMultiplier;
				DensityNoiseDirection = PreLit.m_densityNoiseDirection;
				DensityNoiseScale = PreLit.m_densityNoiseScale;
				DensityNoiseSpeed = PreLit.m_densityNoiseSpeed;
			}
		}

		private void Update_CollectLight()
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: 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_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Unknown result type (might be due to invalid IL or missing references)
			//IL_043e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0440: Unknown result type (might be due to invalid IL or missing references)
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04db: Unknown result type (might be due to invalid IL or missing references)
			_CB_PointLight.ClearBuffer();
			_CB_EffectLight.ClearBuffer();
			_CB_SpotLight.ClearBuffer();
			_CB_FogSphere.ClearBuffer();
			int num = 0;
			Enumerator<C_Light> enumerator = C_CullingManager.VisiblePointLights.GetEnumerator();
			Vector3 val = default(Vector3);
			while (enumerator.MoveNext())
			{
				C_Light current = enumerator.Current;
				if (num >= _CB_PointLight.MaxSize)
				{
					break;
				}
				if (((C_Cullable)current).IsShown && ((C_Cullable)current).IsRegistered)
				{
					Light unityLight = current.m_unityLight;
					float num2 = unityLight.range * ActualPointlightRange;
					((Vector3)(ref val))..ctor(unityLight.color.r, unityLight.color.g, unityLight.color.b);
					val *= unityLight.intensity * ActualPointlightIrr;
					_CB_PointLight.TempBuffer[num] = new sCL_PointLight
					{
						Position = ((Component)unityLight).transform.position,
						Irradiance = val,
						InvRangeSqr = 1f / (num2 * num2),
						Physical = 0f
					};
					num++;
				}
			}
			_CB_PointLight.PushTempBuffer(num);
			num = 0;
			Enumerator<LightBase> enumerator2 = ClusteredRendering.s_visibleEffectLights.GetEnumerator();
			Vector3 val2 = default(Vector3);
			while (enumerator2.MoveNext())
			{
				LightBase current2 = enumerator2.Current;
				if (num >= _CB_EffectLight.MaxSize)
				{
					break;
				}
				if (current2.IsVisible && ((Behaviour)current2).enabled && current2.WantsToShow)
				{
					Color color = current2.Color;
					((Vector3)(ref val2))..ctor(color.r, color.g, color.b);
					val2 *= current2.Intensity * ActualEffectlightIrr;
					float num3 = current2.Range * ActualEffectlightRange;
					_CB_EffectLight.TempBuffer[num] = new sCL_PointLight
					{
						Position = ((Component)current2).transform.position,
						Irradiance = val2,
						InvRangeSqr = 1f / (num3 * num3),
						Physical = current2.Physical
					};
					num++;
				}
			}
			_CB_EffectLight.PushTempBuffer(num);
			num = 0;
			Enumerator<C_Light> enumerator3 = C_CullingManager.VisibleSpotLights.GetEnumerator();
			Vector3 val3 = default(Vector3);
			while (enumerator3.MoveNext())
			{
				C_Light current3 = enumerator3.Current;
				if (num >= _CB_SpotLight.MaxSize)
				{
					break;
				}
				if (((C_Cullable)current3).IsShown && ((C_Cullable)current3).IsRegistered)
				{
					Light unityLight2 = current3.m_unityLight;
					float num4 = unityLight2.range * ActualSpotlightRange;
					float num5 = unityLight2.spotAngle * ActualSpotlightAngle;
					((Vector3)(ref val3))..ctor(unityLight2.color.r, unityLight2.color.g, unityLight2.color.b);
					val3 *= unityLight2.intensity * ActualSpotlightIrr;
					CL_ShadowGenerator shadowGenerator = current3.m_shadowGenerator;
					Matrix4x4 val4 = Matrix4x4.Perspective(num5, shadowGenerator.m_aspect, shadowGenerator.m_zNear, shadowGenerator.m_zFar);
					val4 = GL.GetGPUProjectionMatrix(val4, true);
					Matrix4x4 val5 = Matrix4x4.TRS(((Component)unityLight2).transform.position, ((Component)unityLight2).transform.rotation, new Vector3(1f, 1f, -1f));
					Matrix4x4 inverse = ((Matrix4x4)(ref val5)).inverse;
					Matrix4x4 viewProjection = val4 * inverse;
					_CB_SpotLight.TempBuffer[num] = new sCL_SpotLight
					{
						Position = ((Component)unityLight2).transform.position,
						Irradiance = val3,
						InvRangeSqr = 1f / (num4 * num4),
						ViewProjection = viewProjection,
						InvNearRange = shadowGenerator.InvNearRange,
						ShadowIndex = shadowGenerator.ShadowID
					};
					num++;
				}
			}
			_CB_SpotLight.PushTempBuffer(num);
			num = 0;
			Enumerator<FogSphere> enumerator4 = PreLitVolume.s_activeFogSpheres.GetEnumerator();
			while (enumerator4.MoveNext())
			{
				FogSphere current4 = enumerator4.Current;
				if (num >= _CB_FogSphere.MaxSize)
				{
					break;
				}
				sCL_FogSphere data = current4.m_data;
				ref Vector3 radiance = ref data.Radiance;
				radiance *= ActualFogSphereIrr;
				data.Density *= DensityMultiplier;
				_CB_FogSphere.TempBuffer[num] = data;
				num++;
			}
			_CB_FogSphere.PushTempBuffer(num);
		}

		private void Update_CheckRes()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			Resolution currentResolution = Screen.currentResolution;
			int intValue = CellSettingsManager.GetIntValue((eCellSettingID)79);
			if (((Resolution)(ref currentResolution)).width != ((Resolution)(ref _CurrentRes)).width || ((Resolution)(ref currentResolution)).height != ((Resolution)(ref _CurrentRes)).height || intValue != _CurrentFogQuality)
			{
				_CurrentFogQuality = intValue;
				_CurrentRes = currentResolution;
				_ScrWidth = ((Resolution)(ref currentResolution)).width;
				_ScrHeight = ((Resolution)(ref currentResolution)).height;
				Clear_RenderTextures();
				Create_RenderTextures();
				UpdateOnce_OnResChange();
			}
		}

		private void Create_RenderTextures()
		{
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Expected O, but got Unknown
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Expected O, but got Unknown
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Expected O, but got Unknown
			int num;
			int voxelDepth;
			switch (_CurrentFogQuality)
			{
			case 0:
				num = 16;
				voxelDepth = 96;
				break;
			case 1:
				num = 16;
				voxelDepth = 112;
				break;
			case 2:
				num = 12;
				voxelDepth = 112;
				break;
			case 3:
				num = 12;
				voxelDepth = 128;
				break;
			default:
				num = 8;
				voxelDepth = 128;
				break;
			}
			_VoxelWidth = _ScrWidth / num;
			_VoxelHeight = _ScrHeight / num;
			_VoxelDepth = voxelDepth;
			uint num2 = default(uint);
			uint num3 = default(uint);
			uint num4 = default(uint);
			CalcCS.GetKernelThreadGroupSizes(_Kernel_Calc, ref num2, ref num3, ref num4);
			_Calc_GroupCount[0] = Mathf.CeilToInt(Mathf.Max(1f, (float)_VoxelWidth / (float)num2));
			_Calc_GroupCount[1] = Mathf.CeilToInt(Mathf.Max(1f, (float)_VoxelHeight / (float)num3));
			_Calc_GroupCount[2] = Mathf.CeilToInt(Mathf.Max(1f, (float)_VoxelDepth / (float)num4));
			uint num5 = default(uint);
			CalcCS.GetKernelThreadGroupSizes(_Kernel_Accumulate, ref num2, ref num3, ref num5);
			_Accum_GroupCount[0] = Mathf.CeilToInt(Mathf.Max(1f, (float)_VoxelWidth / (float)num2));
			_Accum_GroupCount[1] = Mathf.CeilToInt(Mathf.Max(1f, (float)_VoxelHeight / (float)num3));
			_Accum_GroupCount[2] = 1;
			BlurCS.GetKernelThreadGroupSizes(_Kernel_Passthrough, ref num2, ref num3, ref num4);
			_Blur_GroupCount[0] = Mathf.CeilToInt(Mathf.Max(1f, (float)_VoxelWidth / (float)num2));
			_Blur_GroupCount[1] = Mathf.CeilToInt(Mathf.Max(1f, (float)_VoxelHeight / (float)num3));
			_Blur_GroupCount[2] = Mathf.CeilToInt(Mathf.Max(1f, (float)_VoxelDepth / (float)num4));
			RenderTextureDescriptor rTD_Froxel = default(RenderTextureDescriptor);
			((RenderTextureDescriptor)(ref rTD_Froxel)).width = _VoxelWidth;
			((RenderTextureDescriptor)(ref rTD_Froxel)).height = _VoxelHeight;
			((RenderTextureDescriptor)(ref rTD_Froxel)).volumeDepth = _VoxelDepth;
			((RenderTextureDescriptor)(ref rTD_Froxel)).msaaSamples = 1;
			((RenderTextureDescriptor)(ref rTD_Froxel)).dimension = (TextureDimension)3;
			((RenderTextureDescriptor)(ref rTD_Froxel)).useMipMap = false;
			((RenderTextureDescriptor)(ref rTD_Froxel)).enableRandomWrite = true;
			((RenderTextureDescriptor)(ref rTD_Froxel)).colorFormat = (RenderTextureFormat)2;
			_RTD_Froxel = rTD_Froxel;
			_RT_FrustumVoxel_Body = new RenderTexture(_RTD_Froxel)
			{
				name = "RT LLV Froxel Body",
				hideFlags = (HideFlags)61,
				filterMode = (FilterMode)2
			};
			_RT_FrustumVoxel_Body.Create();
			_RT_FrustumVoxel_Reblend = new RenderTexture(_RTD_Froxel)
			{
				name = "RT LLV Froxel Reblend History",
				hideFlags = (HideFlags)61,
				filterMode = (FilterMode)2
			};
			_RT_FrustumVoxel_Reblend.Create();
			_RT_FrustumVoxel_Accumulate = new RenderTexture(_RTD_Froxel)
			{
				name = "RT LLV Froxel Accum",
				hideFlags = (HideFlags)61,
				filterMode = (FilterMode)2
			};
			_RT_FrustumVoxel_Accumulate.Create();
		}

		private void Clear_RenderTextures()
		{
			if ((Object)(object)_RT_FrustumVoxel_Body != (Object)null)
			{
				_RT_FrustumVoxel_Body.Release();
				_RT_FrustumVoxel_Body = null;
			}
			if ((Object)(object)_RT_FrustumVoxel_Reblend != (Object)null)
			{
				_RT_FrustumVoxel_Reblend.Release();
				_RT_FrustumVoxel_Reblend = null;
			}
			if ((Object)(object)_RT_FrustumVoxel_Accumulate != (Object)null)
			{
				_RT_FrustumVoxel_Accumulate.Release();
				_RT_FrustumVoxel_Accumulate = null;
			}
		}

		private void UpdateOnce_OnResChange()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor((float)_VoxelWidth, (float)_VoxelHeight, (float)_VoxelDepth);
			CalcCS.SetVector(SID.VF_VoxelDimension, Vector4.op_Implicit(val));
			CalcCS.SetTexture(_Kernel_Calc, SID.DensityNoiseTexture, (Texture)(object)DensityNoise);
			CalcCS.SetTexture(_Kernel_Calc, "_FogVolume_Reblend", (Texture)(object)_RT_FrustumVoxel_Reblend);
			CalcCS.SetTexture(_Kernel_Calc, SID.FogVolume_Body, (Texture)(object)_RT_FrustumVoxel_Body);
			CalcCS.SetTexture(_Kernel_Accumulate, SID.FogVolume_Body, (Texture)(object)_RT_FrustumVoxel_Body);
			CalcCS.SetTexture(_Kernel_Accumulate, SID.FogVolume_Accumulate, (Texture)(object)_RT_FrustumVoxel_Accumulate);
			BlurCS.SetVector("_Dimension", Vector4.op_Implicit(val));
			BlendMat.SetVector(SID.VF_VoxelDimension, Vector4.op_Implicit(val));
			BlendMat.SetTexture(SID.VF_Volume, (Texture)(object)_RT_FrustumVoxel_Accumulate);
		}

		private void Update_ShaderProperties()
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			Vector4 val = default(Vector4);
			val.x = 1f - FogColor.r;
			val.y = 1f - FogColor.g;
			val.z = 1f - FogColor.b;
			float num = Mathf.Min(Density, DensityHeightMaxBoost);
			val.w = FogColor.a * (1f - num) + num;
			_NoiseOffset += DensityNoiseSpeed * Time.deltaTime * DensityNoiseDirection;
			_NoiseOffset.x %= 1f;
			_NoiseOffset.y %= 1f;
			_NoiseOffset.z %= 1f;
			CalcCS.SetFloat(SID.LightAttenuation, LightAttenuation);
			CalcCS.SetVector(SID.FogColorAbsorbtion, val);
			CalcCS.SetVector(SID.DensityParams, new Vector4(Density, DensityHeightMaxBoost, DensityHeight, DensityHeightRange));
			CalcCS.SetVector(SID.DensityNoiseParams, new Vector4(_NoiseOffset.x, _NoiseOffset.y, _NoiseOffset.z, DensityNoiseScale));
			CalcCS.SetVector(SID.VF_ScatteringParams, new Vector4(_Coeff_Noise, _Coeff_Phase, val.w * _Coeff_Absorbtion, _Coeff_Extinction));
			RenderTexture atlasTexture = CL_ShadowAtlas.AtlasTexture;
			if ((Object)(object)atlasTexture != (Object)null)
			{
				Vector2 val2 = Vector2.one * (float)CL_ShadowAtlas.cShadowResolution;
				CalcCS.SetTexture(_Kernel_Calc, SID.SA_AtlasTexture, (Texture)(object)atlasTexture);
				CalcCS.SetVector(SID.SA_AtlasCellDim, Vector4.op_Implicit(val2));
			}
		}
	}
	internal sealed class PostProcessingObserver : MonoBehaviour
	{
		public static PostProcessingPipeline Pipeline;

		private PostProcessLayer _Layer;

		private PostProcessingBehaviour _Behaviour;

		private void Start()
		{
			if (Pipeline == PostProcessingPipeline.Unchanged)
			{
				Object.Destroy((Object)(object)this);
				return;
			}
			_Layer = ((Component)this).GetComponent<PostProcessLayer>();
			_Behaviour = ((Component)this).GetComponent<PostProcessingBehaviour>();
			if (Pipeline == PostProcessingPipeline.Legacy)
			{
				if ((Object)(object)_Layer != (Object)null)
				{
					((Behaviour)_Layer).enabled = false;
				}
				if ((Object)(object)_Behaviour != (Object)null)
				{
					((PostProcessingModel)_Behaviour.profile.vignette).enabled = false;
				}
			}
			else if (Pipeline == PostProcessingPipeline.Mixed)
			{
				if ((Object)(object)_Layer != (Object)null)
				{
					((Behaviour)_Layer).enabled = false;
				}
				if ((Object)(object)_Behaviour != (Object)null)
				{
					((Behaviour)_Behaviour).enabled = true;
				}
			}
		}

		private void OnPreCull()
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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 (!((Object)(object)_Layer == (Object)null) && !((Object)(object)_Behaviour == (Object)null))
			{
				if (Pipeline == PostProcessingPipeline.Legacy)
				{
					((Behaviour)_Behaviour).enabled = true;
					((Behaviour)_Layer).enabled = true;
				}
				else if (Pipeline == PostProcessingPipeline.Mixed)
				{
					((Behaviour)_Behaviour).enabled = true;
					((Behaviour)_Layer).enabled = false;
					Settings settings = ((PostProcessingComponent<EyeAdaptationModel>)(object)_Behaviour.m_EyeAdaptation).model.settings;
					settings.maxLuminance = -9.75f;
					((PostProcessingComponent<EyeAdaptationModel>)(object)_Behaviour.m_EyeAdaptation).model.settings = settings;
				}
			}
		}
	}
	internal static class SID
	{
		public static readonly int FogColorAbsorbtion = ID("_FogColorAbsorbtion");

		public static readonly int LightAttenuation = ID("_LightAttenuation");

		public static readonly int DensityParams = ID("_DensityParams");

		public static readonly int DensityNoiseParams = ID("_DensityNoiseParams");

		public static readonly int DensityNoiseTexture = ID("_DensityNoiseTexture");

		public static readonly int FogVolume_Body = ID("_FogVolume_Body");

		public static readonly int FogVolume_Accumulate = ID("_FogVolume_Accumulate");

		public static readonly int CB_PointLight = ID("_CB_PointLight");

		public static readonly int CB_EffectLight = ID("_CB_EffectLight");

		public static readonly int CB_SpotLight = ID("_CB_SpotLight");

		public static readonly int CB_FogSphere = ID("_CB_FogSphere");

		public static readonly int VF_VoxelDimension = ID("_VF_VoxelDimension");

		public static readonly int VF_Inv_Proj = ID("_VF_Inv_Proj");

		public static readonly int VF_Inv_View = ID("_VF_Inv_View");

		public static readonly int VF_Prev_VP = ID("_VF_Prev_VP");

		public static readonly int VF_FogParams = ID("_VF_FogParams");

		public static readonly int VF_ReprojectionParams = ID("_VF_ReprojectionParams");

		public static readonly int VF_ScatteringParams = ID("_VF_ScatteringParams");

		public static readonly int VF_CameraWorldPos = ID("_VF_CameraWorldPos");

		public static readonly int VF_Volume = ID("_VF_Volume");

		public static readonly int SA_AtlasTexture = ID("_SA_AtlasTexture");

		public static readonly int SA_AtlasCellDim = ID("_SA_AtlasCellDimension");

		public static readonly int TEMP_Grab = ID("_TMP_Grab");

		public static readonly int TEMP_BlurCopy = ID("_TMP_BlurCopy");

		public static readonly int TEMP_Blurry = ID("_TMP_Blurry");

		public static readonly int Input = ID("_Input");

		public static readonly int Output = ID("_Output");

		private static int ID(string name)
		{
			return Shader.PropertyToID(name);
		}
	}
}
namespace LegacyFogSystem.Systems.Debugs
{
	internal sealed class AtlasDebugger : MonoBehaviour
	{
		private Material _DEBUGMat;

		private RenderTexture _RT;

		private void Start()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			_DEBUGMat = AssetAPI.GetLoadedAsset<Material>("Assets/LegacyLitVolume/Mats/DebugAtlas.mat");
			_RT = new RenderTexture(512, 256, 0, (RenderTextureFormat)13);
			_RT.Create();
		}

		private void OnPostRender()
		{
			if ((Object)(object)CL_ShadowAtlas.AtlasTexture != (Object)null)
			{
				RenderTexture atlasTexture = CL_ShadowAtlas.AtlasTexture;
				Graphics.Blit((Texture)(object)atlasTexture, _RT, _DEBUGMat);
			}
		}

		private void OnGUI()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			GUI.DrawTexture(new Rect(0f, 0f, 512f, 256f), (Texture)(object)_RT);
		}
	}
	internal sealed class ScreenDebug : MonoBehaviour
	{
		public static RenderTexture RT;

		private CommandBuffer _CB;

		private Camera _Cam;

		private CameraEvent _CurrentEvent;

		private BuiltinRenderTextureType Target;

		private void Start()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			_Cam = ((Component)this).GetComponent<Camera>();
			RT = new RenderTexture(Screen.width, Screen.height, 24, (RenderTextureFormat)9);
			_CB = new CommandBuffer();
			_CB.name = "Debug CB";
		}

		private void AddBuffer(CameraEvent evt)
		{
			//IL_0014: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			_CB.Clear();
			_CB.Blit(RenderTargetIdentifier.op_Implicit(Target), RenderTargetIdentifier.op_Implicit((Texture)(object)RT));
			_Cam.RemoveCommandBuffer(_CurrentEvent, _CB);
			_Cam.AddCommandBuffer(evt, _CB);
			_CurrentEvent = evt;
		}

		private void OnGUI()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)RT == (Object)null))
			{
				GUI.DrawTexture(new Rect(0f, 0f, 256f, 144f), (Texture)(object)RT, (ScaleMode)2);
			}
		}
	}
}
namespace LegacyFogSystem.Systems.Buffers
{
	internal class LitBuffer<T> where T : struct
	{
		public readonly int MaxSize;

		public readonly int Stride;

		private readonly Array _Buffer;

		private readonly IntPtr _ClassPtr;

		public int Size { get; private set; }

		public ComputeBuffer CB { get; private set; }

		public T[] TempBuffer { get; private set; }

		public LitBuffer(int size)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			_Buffer = Array.CreateInstance(Il2CppType.Of<T>(), size);
			_ClassPtr = Il2CppClassPointerStore<T>.NativeClassPtr;
			int num = Marshal.SizeOf<T>();
			MaxSize = size;
			Size = 0;
			Stride = num;
			CB = new ComputeBuffer(size, num);
			TempBuffer = new T[size];
		}

		public unsafe void ClearBuffer()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			for (int i = 0; i < MaxSize; i++)
			{
				T value = new T();
				IntPtr intPtr = (nint)Unsafe.AsPointer(ref value);
				Object val = new Object(IL2CPP.il2cpp_value_box(_ClassPtr, intPtr));
				_Buffer.SetValue(val, i);
				TempBuffer[i] = value;
			}
		}

		public void PushTempBuffer(int size = -1)
		{
			Push(TempBuffer, size);
		}

		public unsafe void Push(T[] buffers, int size = -1)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			if (CB != null)
			{
				int num2 = (Size = Mathf.Min(Mathf.Min(buffers.Length, (size > 0) ? size : int.MaxValue), MaxSize));
				for (int i = 0; i < num2; i++)
				{
					IntPtr intPtr = (nint)Unsafe.AsPointer(ref buffers[i]);
					Object val = new Object(IL2CPP.il2cpp_value_box(_ClassPtr, intPtr));
					_Buffer.SetValue(val, i);
				}
				CB.SetData(_Buffer, 0, 0, MaxSize);
			}
		}

		public void Dispose()
		{
			if (CB != null)
			{
				CB.Dispose();
				CB = null;
			}
		}
	}
}
namespace LegacyFogSystem.Injects
{
	[HarmonyPatch(typeof(LocalPlayerAgent), "Setup")]
	internal static class Inject_ModifyAmbient
	{
		private static void Postfix(LocalPlayerAgent __instance)
		{
			EffectLight ambientLight = __instance.m_ambientLight;
			if ((Object)(object)ambientLight != (Object)null)
			{
				((LightBase)ambientLight).Intensity = 0.12f;
				((LightBase)ambientLight).Range = 1.62f;
			}
		}
	}
	[HarmonyPatch(typeof(PlayerManager), "Awake")]
	internal static class Inject_Reorder_UI_Apply
	{
		private static void Postfix(PlayerManager __instance)
		{
			GameObject prefabLocal = __instance.m_prefabLocal;
			GameObject gameObject = ((Component)prefabLocal.GetComponentInChildren<FPSCamera>(true)).gameObject;
			UI_Apply component = gameObject.GetComponent<UI_Apply>();
			UI_Apply val = gameObject.AddComponent<UI_Apply>();
			val.m_UIBlitterMaterial = component.m_UIBlitterMaterial;
			Object.Destroy((Object)(object)component);
		}
	}
	[HarmonyPatch(typeof(ClusteredRendering), "Setup")]
	internal class Inject_SetupLegacyPreLit
	{
		private static void Postfix(ClusteredRendering __instance)
		{
			PreLitVolume component = ((Component)__instance).GetComponent<PreLitVolume>();
			if ((Object)(object)component == (Object)null)
			{
				Logger.Error("PreLitVolume is missing?!");
				return;
			}
			RenderPipe.Config.smoothnessLimit = 1f;
			ShaderIDs.VolumesEnabled = Shader.PropertyToID("_NoDontAlterTheVolumeSettingsThankYou");
			Shader.SetGlobalFloat("_VolumesEnabled", 0f);
			__instance.UpdateLitVolume = false;
			((Component)__instance).GetComponent<AmplifyOcclusionEffect>().Intensity = 0f;
			LegacyLitVolume component2 = ((Component)__instance).GetComponent<LegacyLitVolume>();
			if ((Object)(object)component2 == (Object)null)
			{
				component2 = ((Component)__instance).gameObject.AddComponent<LegacyLitVolume>();
				component2.PreLit = component;
				component2.DensityNoise = component.m_densityNoise;
				component2.CalcCS = AssetAPI.GetLoadedAsset<ComputeShader>("Assets/LegacyLitVolume/Shaders/CalcLitVolume.compute");
				component2.BlurCS = AssetAPI.GetLoadedAsset<ComputeShader>("Assets/LegacyLitVolume/Shaders/BlurLitVolume.compute");
				component2.BlendMat = AssetAPI.GetLoadedAsset<Material>("Assets/LegacyLitVolume/Mats/BlendFog.mat");
				((Component)__instance).gameObject.AddComponent<PostProcessingObserver>();
			}
		}
	}
}