Decompiled source of The Chair v1.0.0

The_Chair.dll

Decompiled 7 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using LuxWater;
using OtherLoader;
using Sodalite.Api;
using Sodalite.Utilities;
using UnityEditor;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
using UnityEngine.Profiling;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace LuxWater.Demo
{
	public class LuxWater_ExtendedFlycam : MonoBehaviour
	{
		public float cameraSensitivity = 90f;

		public float climbSpeed = 4f;

		public float normalMoveSpeed = 10f;

		public float slowMoveFactor = 0.25f;

		public float fastMoveFactor = 3f;

		private float rotationX = 0f;

		private float rotationY = 0f;

		private bool isOrtho = false;

		private Camera cam;

		private void Start()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			rotationX = ((Component)this).transform.eulerAngles.y;
			cam = ((Component)this).GetComponent<Camera>();
			if ((Object)(object)cam != (Object)null)
			{
				isOrtho = cam.orthographic;
			}
		}

		private void Update()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: 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_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: 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_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: 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_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: 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_01db: 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)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: 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_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: 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_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			float deltaTime = Time.deltaTime;
			rotationX += Input.GetAxis("Mouse X") * cameraSensitivity * deltaTime;
			rotationY += Input.GetAxis("Mouse Y") * cameraSensitivity * deltaTime;
			rotationY = Mathf.Clamp(rotationY, -90f, 90f);
			Quaternion val = Quaternion.AngleAxis(rotationX, Vector3.up);
			val *= Quaternion.AngleAxis(rotationY, Vector3.left);
			((Component)this).transform.localRotation = Quaternion.Slerp(((Component)this).transform.localRotation, val, deltaTime * 6f);
			if (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303))
			{
				Transform transform = ((Component)this).transform;
				transform.position += ((Component)this).transform.forward * (normalMoveSpeed * fastMoveFactor) * Input.GetAxis("Vertical") * deltaTime;
				Transform transform2 = ((Component)this).transform;
				transform2.position += ((Component)this).transform.right * (normalMoveSpeed * fastMoveFactor) * Input.GetAxis("Horizontal") * deltaTime;
			}
			else if (Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305))
			{
				Transform transform3 = ((Component)this).transform;
				transform3.position += ((Component)this).transform.forward * (normalMoveSpeed * slowMoveFactor) * Input.GetAxis("Vertical") * deltaTime;
				Transform transform4 = ((Component)this).transform;
				transform4.position += ((Component)this).transform.right * (normalMoveSpeed * slowMoveFactor) * Input.GetAxis("Horizontal") * deltaTime;
			}
			else
			{
				if (isOrtho)
				{
					Camera obj = cam;
					obj.orthographicSize *= 1f - Input.GetAxis("Vertical") * deltaTime;
				}
				else
				{
					Transform transform5 = ((Component)this).transform;
					transform5.position += ((Component)this).transform.forward * normalMoveSpeed * Input.GetAxis("Vertical") * deltaTime;
				}
				Transform transform6 = ((Component)this).transform;
				transform6.position += ((Component)this).transform.right * normalMoveSpeed * Input.GetAxis("Horizontal") * deltaTime;
			}
			if (Input.GetKey((KeyCode)113))
			{
				Transform transform7 = ((Component)this).transform;
				transform7.position -= ((Component)this).transform.up * climbSpeed * deltaTime;
			}
			if (Input.GetKey((KeyCode)101))
			{
				Transform transform8 = ((Component)this).transform;
				transform8.position += ((Component)this).transform.up * climbSpeed * deltaTime;
			}
		}
	}
}
public class LuxWater_SetToGerstnerHeight : MonoBehaviour
{
	public Material WaterMaterial;

	public Vector3 Damping = new Vector3(0.3f, 1f, 0.3f);

	public float TimeOffset = 0f;

	public bool UpdateWaterMaterialPerFrame = false;

	[Space(8f)]
	public bool AddCircleAnim = false;

	public float Radius = 6f;

	public float Speed = 1f;

	[Space(8f)]
	public Transform[] ManagedWaterProjectors;

	[Header("Debug")]
	public float MaxDisp;

	private Transform trans;

	private LuxWaterUtils.GersterWavesDescription Description;

	private bool ObjectIsVisible = false;

	private Vector3 Offset = Vector3.zero;

	private void Start()
	{
		trans = ((Component)this).transform;
		LuxWaterUtils.GetGersterWavesDescription(ref Description, WaterMaterial);
	}

	private void OnBecameVisible()
	{
		ObjectIsVisible = true;
	}

	private void OnBecameInvisible()
	{
		ObjectIsVisible = false;
	}

	private void LateUpdate()
	{
		//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_0059: 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)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: 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_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: 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)
		//IL_00ec: 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)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		if ((!ObjectIsVisible && !AddCircleAnim) || (Object)(object)WaterMaterial == (Object)null)
		{
			return;
		}
		if (UpdateWaterMaterialPerFrame)
		{
			LuxWaterUtils.GetGersterWavesDescription(ref Description, WaterMaterial);
		}
		Vector3 position = trans.position;
		position -= Offset;
		if (AddCircleAnim)
		{
			position.x += Mathf.Sin(Time.time * Speed) * Time.deltaTime * Radius;
			position.z += Mathf.Cos(Time.time * Speed) * Time.deltaTime * Radius;
		}
		int num = ManagedWaterProjectors.Length;
		if (num > 0)
		{
			for (int i = 0; i != num; i++)
			{
				Vector3 position2 = ManagedWaterProjectors[i].position;
				position2.x = position.x;
				position2.z = position.z;
				ManagedWaterProjectors[i].position = position2;
			}
		}
		Offset = LuxWaterUtils.GetGestnerDisplacement(position, Description, TimeOffset);
		float magnitude = ((Vector3)(ref Offset)).magnitude;
		if (magnitude > MaxDisp)
		{
			MaxDisp = magnitude;
		}
		ref Vector3 offset = ref Offset;
		offset.x += Offset.x * Damping.x;
		ref Vector3 offset2 = ref Offset;
		offset2.y += Offset.y * Damping.y;
		ref Vector3 offset3 = ref Offset;
		offset3.z += Offset.z * Damping.z;
		trans.position = position + Offset;
	}
}
public class LuxWater_WaterVolumeListener : MonoBehaviour
{
	private void OnEnable()
	{
		LuxWater_WaterVolume.OnEnterWaterVolume += Enter;
		LuxWater_WaterVolume.OnExitWaterVolume += Exit;
	}

	private void OnDisable()
	{
		LuxWater_WaterVolume.OnEnterWaterVolume -= Enter;
		LuxWater_WaterVolume.OnExitWaterVolume -= Exit;
	}

	private void Enter()
	{
		Debug.Log((object)"Entered.");
	}

	private void Exit()
	{
		Debug.Log((object)"Exited.");
	}
}
namespace LuxWater
{
	[ExecuteInEditMode]
	[RequireComponent(typeof(Camera))]
	public class LuxWater_CameraDepthMode : MonoBehaviour
	{
		public bool GrabDepthTexture = false;

		private Camera cam;

		private Material CopyDepthMat;

		private RenderTextureFormat format;

		private Dictionary<Camera, CommandBuffer> m_cmdBuffer = new Dictionary<Camera, CommandBuffer>();

		private bool CamCallBackAdded = false;

		[HideInInspector]
		public bool ShowShaderWarning = true;

		private void OnEnable()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_0027: Invalid comparison between Unknown and I4
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			cam = ((Component)this).GetComponent<Camera>();
			Camera obj = cam;
			obj.depthTextureMode = (DepthTextureMode)(obj.depthTextureMode | 1);
			if ((int)SystemInfo.graphicsDeviceType == 16)
			{
				Camera.onPreCull = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(OnPrecull));
				CamCallBackAdded = true;
				CopyDepthMat = new Material(Shader.Find("Hidden/Lux Water/CopyDepth"));
				format = (RenderTextureFormat)14;
				if (!SystemInfo.SupportsRenderTextureFormat(format))
				{
					format = (RenderTextureFormat)15;
				}
				if (!SystemInfo.SupportsRenderTextureFormat(format))
				{
					format = (RenderTextureFormat)2;
				}
			}
		}

		private void OnDisable()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			if (CamCallBackAdded)
			{
				Camera.onPreCull = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(OnPrecull));
				foreach (KeyValuePair<Camera, CommandBuffer> item in m_cmdBuffer)
				{
					if ((Object)(object)item.Key != (Object)null)
					{
						item.Key.RemoveCommandBuffer((CameraEvent)7, item.Value);
					}
				}
				m_cmdBuffer.Clear();
			}
			ShowShaderWarning = true;
		}

		private void OnPrecull(Camera camera)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_001b: Invalid comparison between Unknown and I4
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Invalid comparison between Unknown and I4
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			if (!GrabDepthTexture)
			{
				return;
			}
			RenderingPath actualRenderingPath = cam.actualRenderingPath;
			if ((int)actualRenderingPath == 3 && (int)SystemInfo.graphicsDeviceType == 16)
			{
				if (!m_cmdBuffer.TryGetValue(camera, out var value))
				{
					value = new CommandBuffer();
					value.name = "Lux Water Grab Depth";
					camera.AddCommandBuffer((CameraEvent)14, value);
					m_cmdBuffer[camera] = value;
				}
				value.Clear();
				int pixelWidth = camera.pixelWidth;
				int pixelHeight = camera.pixelHeight;
				int num = Shader.PropertyToID("_Lux_GrabbedDepth");
				value.GetTemporaryRT(num, pixelWidth, pixelHeight, 0, (FilterMode)0, format, (RenderTextureReadWrite)1);
				value.Blit(RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)1), RenderTargetIdentifier.op_Implicit(num), CopyDepthMat, 0);
				value.ReleaseTemporaryRT(num);
				return;
			}
			GrabDepthTexture = false;
			foreach (KeyValuePair<Camera, CommandBuffer> item in m_cmdBuffer)
			{
				if ((Object)(object)item.Key != (Object)null)
				{
					item.Key.RemoveCommandBuffer((CameraEvent)7, item.Value);
				}
			}
			m_cmdBuffer.Clear();
			ShowShaderWarning = true;
		}
	}
	public class LuxWater_HelpBtn : PropertyAttribute
	{
		public string URL;

		public LuxWater_HelpBtn(string URL)
		{
			this.URL = URL;
		}
	}
	[CustomPropertyDrawer(typeof(LuxWater_HelpBtn))]
	public class LuxWater_HelpBtnDrawer : DecoratorDrawer
	{
		private static string baseURL = "https://docs.google.com/document/d/1NDtUpVBgd3UYEI8LRNI4teFF3qm38h-u3Az-ozaaOX0/view#heading=";

		private LuxWater_HelpBtn help => (LuxWater_HelpBtn)(object)((DecoratorDrawer)this).attribute;

		public override float GetHeight()
		{
			return ((DecoratorDrawer)this).GetHeight() + 2f;
		}

		public override void OnGUI(Rect position)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			Color blue = default(Color);
			((Color)(ref blue))..ctor(0.3f, 0.47f, 1f, 1f);
			if (!EditorGUIUtility.isProSkin)
			{
				blue = Color.blue;
			}
			GUIStyle val = new GUIStyle(EditorStyles.miniButton);
			val.padding = new RectOffset(0, 0, 2, 2);
			val.normal.background = null;
			val.normal.textColor = blue;
			val.onNormal.textColor = blue;
			val.active.textColor = blue;
			val.onActive.textColor = blue;
			val.focused.textColor = blue;
			val.onFocused.textColor = blue;
			((Rect)(ref position)).x = ((Rect)(ref position)).x + ((Rect)(ref position)).width - 30f;
			((Rect)(ref position)).width = 30f;
			if (GUI.Button(position, "Help", val))
			{
				Application.OpenURL(baseURL + help.URL);
			}
		}
	}
	public class LuxWater_InfiniteOcean : MonoBehaviour
	{
		[Space(6f)]
		[LuxWater_HelpBtn("h.c1utuz9up55r")]
		public Camera MainCam;

		public float GridSize = 10f;

		private Transform trans;

		private Transform camTrans;

		private void OnEnable()
		{
			trans = ((Component)this).GetComponent<Transform>();
		}

		private void LateUpdate()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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)
			if ((Object)(object)MainCam == (Object)null)
			{
				Camera main = Camera.main;
				if ((Object)(object)main == (Object)null)
				{
					return;
				}
				MainCam = main;
			}
			if ((Object)(object)camTrans == (Object)null)
			{
				camTrans = ((Component)MainCam).transform;
			}
			Vector3 position = camTrans.position;
			Vector3 position2 = trans.position;
			Vector3 lossyScale = trans.lossyScale;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(GridSize * lossyScale.x, GridSize * lossyScale.z);
			float num = (float)Math.Round(position.x / val.x);
			float num2 = val.x * num;
			num = (float)Math.Round(position.z / val.y);
			float num3 = val.y * num;
			position2.x = num2 + position2.x % val.x;
			position2.z = num3 + position2.z % val.y;
			trans.position = position2;
		}
	}
	[ExecuteInEditMode]
	public class LuxWater_PlanarReflection : MonoBehaviour
	{
		public enum ReflectionResolution
		{
			Full = 1,
			Half = 2,
			Quarter = 4,
			Eighth = 8
		}

		public enum NumberOfShadowCascades
		{
			One = 1,
			Two = 2,
			Four = 4
		}

		[Space(6f)]
		[LuxWater_HelpBtn("h.5c3jy4qfh163")]
		public bool UpdateSceneView = true;

		[Space(5f)]
		public bool isMaster = false;

		public Material[] WaterMaterials;

		[Space(5f)]
		public LayerMask reflectionMask = LayerMask.op_Implicit(-1);

		public ReflectionResolution Resolution = ReflectionResolution.Half;

		public Color clearColor = Color.black;

		public bool reflectSkybox = true;

		[Space(5f)]
		public bool disablePixelLights = false;

		[Space(5f)]
		public bool renderShadows = true;

		public float shadowDistance = 0f;

		public NumberOfShadowCascades ShadowCascades = NumberOfShadowCascades.One;

		[Space(5f)]
		public float WaterSurfaceOffset = 0f;

		public float clipPlaneOffset = 0.07f;

		private string reflectionSampler = "_LuxWater_ReflectionTex";

		private Vector3 m_Oldpos;

		private Camera m_ReflectionCamera;

		private Material m_SharedMaterial;

		private Dictionary<Camera, bool> m_HelperCameras;

		private RenderTexture m_reflectionMap;

		private void OnEnable()
		{
			((Component)this).gameObject.layer = LayerMask.NameToLayer("Water");
			Renderer component = ((Component)this).GetComponent<Renderer>();
			if ((Object)(object)component != (Object)null)
			{
				m_SharedMaterial = ((Component)this).GetComponent<Renderer>().sharedMaterial;
			}
		}

		private void OnDisable()
		{
			if ((Object)(object)m_ReflectionCamera != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)m_ReflectionCamera.targetTexture);
				Object.DestroyImmediate((Object)(object)m_ReflectionCamera);
			}
			if (m_HelperCameras != null)
			{
				m_HelperCameras.Clear();
			}
		}

		private Camera CreateReflectionCameraFor(Camera cam)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			string text = ((Object)((Component)this).gameObject).name + "Reflection" + ((Object)cam).name;
			GameObject val = GameObject.Find(text);
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = new GameObject(text, new Type[1] { typeof(Camera) });
				((Object)val).hideFlags = (HideFlags)61;
			}
			if (!Object.op_Implicit((Object)(object)val.GetComponent(typeof(Camera))))
			{
				val.AddComponent(typeof(Camera));
			}
			Camera component = val.GetComponent<Camera>();
			component.backgroundColor = clearColor;
			component.clearFlags = (CameraClearFlags)(reflectSkybox ? 1 : 2);
			SetStandardCameraParameter(component, reflectionMask);
			if (!Object.op_Implicit((Object)(object)component.targetTexture))
			{
				component.targetTexture = CreateTextureFor(cam);
			}
			return component;
		}

		private void SetStandardCameraParameter(Camera cam, LayerMask mask)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			cam.cullingMask = LayerMask.op_Implicit(mask) & ~(1 << LayerMask.NameToLayer("Water"));
			cam.backgroundColor = Color.black;
			((Behaviour)cam).enabled = false;
		}

		private RenderTexture CreateTextureFor(Camera cam)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			int num = Mathf.FloorToInt((float)(cam.pixelWidth / (int)Resolution));
			int num2 = Mathf.FloorToInt((float)(cam.pixelHeight / (int)Resolution));
			RenderTexture val = new RenderTexture(num, num2, 24);
			((Object)val).hideFlags = (HideFlags)52;
			return val;
		}

		public void RenderHelpCameras(Camera currentCam)
		{
			if (m_HelperCameras == null)
			{
				m_HelperCameras = new Dictionary<Camera, bool>();
			}
			if (!m_HelperCameras.ContainsKey(currentCam))
			{
				m_HelperCameras.Add(currentCam, value: false);
			}
			if (((Object.op_Implicit((Object)(object)SceneView.currentDrawingSceneView) && (Object)(object)SceneView.currentDrawingSceneView.camera == (Object)(object)Camera.current) || !m_HelperCameras[currentCam]) && !((Object)currentCam).name.Contains("Reflection Probes"))
			{
				if (!Object.op_Implicit((Object)(object)m_ReflectionCamera))
				{
					m_ReflectionCamera = CreateReflectionCameraFor(currentCam);
				}
				RenderReflectionFor(currentCam, m_ReflectionCamera);
				m_HelperCameras[currentCam] = true;
			}
		}

		public void LateUpdate()
		{
			if (m_HelperCameras != null)
			{
				m_HelperCameras.Clear();
			}
		}

		public void WaterTileBeingRendered(Transform tr, Camera currentCam)
		{
			RenderHelpCameras(currentCam);
			if (Object.op_Implicit((Object)(object)m_ReflectionCamera) && Object.op_Implicit((Object)(object)m_SharedMaterial))
			{
				m_SharedMaterial.SetTexture(reflectionSampler, (Texture)(object)m_ReflectionCamera.targetTexture);
			}
		}

		public void OnWillRenderObject()
		{
			WaterTileBeingRendered(((Component)this).transform, Camera.current);
		}

		private void RenderReflectionFor(Camera cam, Camera reflectCamera)
		{
			//IL_00a4: 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_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: 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)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: 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_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: 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_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: 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)
			if (!Object.op_Implicit((Object)(object)reflectCamera) || (Object.op_Implicit((Object)(object)m_SharedMaterial) && !m_SharedMaterial.HasProperty(reflectionSampler)))
			{
				return;
			}
			int num = Mathf.FloorToInt((float)(cam.pixelWidth / (int)Resolution));
			int num2 = Mathf.FloorToInt((float)(cam.pixelHeight / (int)Resolution));
			if (((Texture)reflectCamera.targetTexture).width != num || ((Texture)reflectCamera.targetTexture).height != num2)
			{
				Object.DestroyImmediate((Object)(object)reflectCamera.targetTexture);
				reflectCamera.targetTexture = CreateTextureFor(cam);
			}
			reflectCamera.cullingMask = LayerMask.op_Implicit(reflectionMask) & ~(1 << LayerMask.NameToLayer("Water"));
			SaneCameraSettings(reflectCamera);
			reflectCamera.backgroundColor = clearColor;
			reflectCamera.clearFlags = (CameraClearFlags)(reflectSkybox ? 1 : 2);
			GL.invertCulling = true;
			Transform transform = ((Component)this).transform;
			Vector3 eulerAngles = ((Component)cam).transform.eulerAngles;
			((Component)reflectCamera).transform.eulerAngles = new Vector3(0f - eulerAngles.x, eulerAngles.y, eulerAngles.z);
			((Component)reflectCamera).transform.position = ((Component)cam).transform.position;
			reflectCamera.orthographic = cam.orthographic;
			reflectCamera.orthographicSize = cam.orthographicSize;
			Vector3 position = ((Component)transform).transform.position;
			position.y = transform.position.y + WaterSurfaceOffset;
			Vector3 up = ((Component)transform).transform.up;
			float num3 = 0f - Vector3.Dot(up, position) - clipPlaneOffset;
			Vector4 plane = default(Vector4);
			((Vector4)(ref plane))..ctor(up.x, up.y, up.z, num3);
			Matrix4x4 val = Matrix4x4.zero;
			val = CalculateReflectionMatrix(val, plane);
			m_Oldpos = ((Component)cam).transform.position;
			Vector3 position2 = ((Matrix4x4)(ref val)).MultiplyPoint(m_Oldpos);
			reflectCamera.worldToCameraMatrix = cam.worldToCameraMatrix * val;
			Vector4 clipPlane = CameraSpacePlane(reflectCamera, position, up, 1f);
			Matrix4x4 projectionMatrix = cam.projectionMatrix;
			projectionMatrix = CalculateObliqueMatrix(projectionMatrix, clipPlane);
			reflectCamera.projectionMatrix = projectionMatrix;
			((Component)reflectCamera).transform.position = position2;
			Vector3 eulerAngles2 = ((Component)cam).transform.eulerAngles;
			((Component)reflectCamera).transform.eulerAngles = new Vector3(0f - eulerAngles2.x, eulerAngles2.y, eulerAngles2.z);
			int pixelLightCount = QualitySettings.pixelLightCount;
			if (disablePixelLights)
			{
				QualitySettings.pixelLightCount = 0;
			}
			float num4 = QualitySettings.shadowDistance;
			int shadowCascades = QualitySettings.shadowCascades;
			if (!renderShadows)
			{
				QualitySettings.shadowDistance = 0f;
			}
			else if (shadowDistance > 0f)
			{
				QualitySettings.shadowDistance = shadowDistance;
			}
			QualitySettings.shadowCascades = (int)ShadowCascades;
			reflectCamera.Render();
			GL.invertCulling = false;
			if (disablePixelLights)
			{
				QualitySettings.pixelLightCount = pixelLightCount;
			}
			if (!renderShadows || shadowDistance > 0f)
			{
				QualitySettings.shadowDistance = num4;
			}
			QualitySettings.shadowCascades = shadowCascades;
			if (isMaster)
			{
				for (int i = 0; i < WaterMaterials.Length; i++)
				{
					WaterMaterials[i].SetTexture(reflectionSampler, (Texture)(object)reflectCamera.targetTexture);
				}
			}
		}

		private void SaneCameraSettings(Camera helperCam)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			helperCam.depthTextureMode = (DepthTextureMode)0;
			helperCam.backgroundColor = Color.black;
			helperCam.clearFlags = (CameraClearFlags)2;
			helperCam.renderingPath = (RenderingPath)1;
		}

		private static Matrix4x4 CalculateObliqueMatrix(Matrix4x4 projection, Vector4 clipPlane)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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)
			Vector4 val = ((Matrix4x4)(ref projection)).inverse * new Vector4(Sgn(clipPlane.x), Sgn(clipPlane.y), 1f, 1f);
			Vector4 val2 = clipPlane * (2f / Vector4.Dot(clipPlane, val));
			((Matrix4x4)(ref projection))[2] = val2.x - ((Matrix4x4)(ref projection))[3];
			((Matrix4x4)(ref projection))[6] = val2.y - ((Matrix4x4)(ref projection))[7];
			((Matrix4x4)(ref projection))[10] = val2.z - ((Matrix4x4)(ref projection))[11];
			((Matrix4x4)(ref projection))[14] = val2.w - ((Matrix4x4)(ref projection))[15];
			return projection;
		}

		private static Matrix4x4 CalculateReflectionMatrix(Matrix4x4 reflectionMat, Vector4 plane)
		{
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			reflectionMat.m00 = 1f - 2f * ((Vector4)(ref plane))[0] * ((Vector4)(ref plane))[0];
			reflectionMat.m01 = -2f * ((Vector4)(ref plane))[0] * ((Vector4)(ref plane))[1];
			reflectionMat.m02 = -2f * ((Vector4)(ref plane))[0] * ((Vector4)(ref plane))[2];
			reflectionMat.m03 = -2f * ((Vector4)(ref plane))[3] * ((Vector4)(ref plane))[0];
			reflectionMat.m10 = -2f * ((Vector4)(ref plane))[1] * ((Vector4)(ref plane))[0];
			reflectionMat.m11 = 1f - 2f * ((Vector4)(ref plane))[1] * ((Vector4)(ref plane))[1];
			reflectionMat.m12 = -2f * ((Vector4)(ref plane))[1] * ((Vector4)(ref plane))[2];
			reflectionMat.m13 = -2f * ((Vector4)(ref plane))[3] * ((Vector4)(ref plane))[1];
			reflectionMat.m20 = -2f * ((Vector4)(ref plane))[2] * ((Vector4)(ref plane))[0];
			reflectionMat.m21 = -2f * ((Vector4)(ref plane))[2] * ((Vector4)(ref plane))[1];
			reflectionMat.m22 = 1f - 2f * ((Vector4)(ref plane))[2] * ((Vector4)(ref plane))[2];
			reflectionMat.m23 = -2f * ((Vector4)(ref plane))[3] * ((Vector4)(ref plane))[2];
			reflectionMat.m30 = 0f;
			reflectionMat.m31 = 0f;
			reflectionMat.m32 = 0f;
			reflectionMat.m33 = 1f;
			return reflectionMat;
		}

		private static float Sgn(float a)
		{
			if (a > 0f)
			{
				return 1f;
			}
			if (a < 0f)
			{
				return -1f;
			}
			return 0f;
		}

		private Vector4 CameraSpacePlane(Camera cam, Vector3 pos, Vector3 normal, float sideSign)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = pos + normal * clipPlaneOffset;
			Matrix4x4 worldToCameraMatrix = cam.worldToCameraMatrix;
			Vector3 val2 = ((Matrix4x4)(ref worldToCameraMatrix)).MultiplyPoint(val);
			Vector3 val3 = ((Matrix4x4)(ref worldToCameraMatrix)).MultiplyVector(normal);
			Vector3 val4 = ((Vector3)(ref val3)).normalized * sideSign;
			return new Vector4(val4.x, val4.y, val4.z, 0f - Vector3.Dot(val2, val4));
		}
	}
	[ExecuteInEditMode]
	public class LuxWater_PlanarWaterTile : MonoBehaviour
	{
		[Space(6f)]
		[LuxWater_HelpBtn("h.nu6w5ylbucb7")]
		public LuxWater_PlanarReflection reflection;

		public void OnEnable()
		{
			AcquireComponents();
		}

		private void AcquireComponents()
		{
			if (!Object.op_Implicit((Object)(object)reflection))
			{
				if (Object.op_Implicit((Object)(object)((Component)this).transform.parent))
				{
					reflection = ((Component)((Component)this).transform.parent).GetComponent<LuxWater_PlanarReflection>();
				}
				else
				{
					reflection = ((Component)((Component)this).transform).GetComponent<LuxWater_PlanarReflection>();
				}
			}
		}

		public void Update()
		{
			AcquireComponents();
		}

		public void OnWillRenderObject()
		{
			if (Object.op_Implicit((Object)(object)reflection))
			{
				reflection.WaterTileBeingRendered(((Component)this).transform, Camera.current);
			}
		}
	}
	public class LuxWater_Projector : MonoBehaviour
	{
		public enum ProjectorType
		{
			FoamProjector,
			NormalProjector
		}

		[Space(8f)]
		public ProjectorType Type = ProjectorType.FoamProjector;

		[NonSerialized]
		public static List<LuxWater_Projector> FoamProjectors = new List<LuxWater_Projector>();

		[NonSerialized]
		public static List<LuxWater_Projector> NormalProjectors = new List<LuxWater_Projector>();

		[NonSerialized]
		public Renderer m_Rend;

		[NonSerialized]
		public Material m_Mat;

		private bool added = false;

		private Vector3 origPos;

		private void Update()
		{
			//IL_0007: 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)
			Vector3 position = ((Component)this).transform.position;
			position.y = origPos.y;
		}

		private void OnEnable()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			origPos = ((Component)this).transform.position;
			Renderer component = ((Component)this).GetComponent<Renderer>();
			if ((Object)(object)component != (Object)null)
			{
				m_Rend = ((Component)this).GetComponent<Renderer>();
				m_Mat = m_Rend.sharedMaterials[0];
				m_Rend.enabled = false;
				if (Type == ProjectorType.FoamProjector)
				{
					FoamProjectors.Add(this);
				}
				else
				{
					NormalProjectors.Add(this);
				}
				added = true;
			}
		}

		private void OnDisable()
		{
			if (added)
			{
				if (Type == ProjectorType.FoamProjector)
				{
					FoamProjectors.Remove(this);
				}
				else
				{
					NormalProjectors.Remove(this);
				}
				m_Rend.enabled = true;
			}
		}
	}
	[RequireComponent(typeof(Camera))]
	[ExecuteInEditMode]
	public class LuxWater_ProjectorRenderer : MonoBehaviour
	{
		public enum BufferResolution
		{
			Full = 1,
			Half = 2,
			Quarter = 4,
			Eighth = 8
		}

		[Space(8f)]
		public BufferResolution FoamBufferResolution = BufferResolution.Full;

		public BufferResolution NormalBufferResolution = BufferResolution.Full;

		[Space(2f)]
		[Header("Debug")]
		[Space(4f)]
		public bool DebugFoamBuffer = false;

		public bool DebugNormalBuffer = false;

		public bool DebugStats = false;

		private int drawnFoamProjectors = 0;

		private int drawnNormalProjectors = 0;

		private static CommandBuffer cb_Foam;

		private static CommandBuffer cb_Normals;

		private Camera cam;

		private Transform camTransform;

		private RenderTexture ProjectedFoam;

		private RenderTexture ProjectedNormals;

		private Texture2D defaultBump;

		private Bounds tempBounds;

		private int _LuxWater_FoamOverlayPID;

		private int _LuxWater_NormalOverlayPID;

		private Plane[] frustumPlanes = (Plane[])(object)new Plane[6];

		private Material DebugMat;

		private Material DebugNormalMat;

		private void OnEnable()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			_LuxWater_FoamOverlayPID = Shader.PropertyToID("_LuxWater_FoamOverlay");
			_LuxWater_NormalOverlayPID = Shader.PropertyToID("_LuxWater_NormalOverlay");
			cb_Foam = new CommandBuffer();
			cb_Foam.name = "Lux Water: Foam Overlay Buffer";
			cb_Normals = new CommandBuffer();
			cb_Normals.name = "Lux Water: Normal Overlay Buffer";
		}

		private void OnDisable()
		{
			if ((Object)(object)ProjectedFoam != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)ProjectedFoam);
			}
			if ((Object)(object)ProjectedNormals != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)ProjectedNormals);
			}
			if ((Object)(object)defaultBump != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)defaultBump);
			}
			if ((Object)(object)DebugMat != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)DebugMat);
			}
			if (cb_Foam != null && cb_Foam.sizeInBytes > 0)
			{
				cb_Foam.Clear();
				cb_Foam.Dispose();
			}
			if (cb_Normals != null && cb_Normals.sizeInBytes > 0)
			{
				cb_Normals.Clear();
				cb_Normals.Dispose();
			}
			Shader.DisableKeyword("USINGWATERPROJECTORS");
		}

		private void OnPreCull()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: 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_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: 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_01c0: Expected O, but got Unknown
			//IL_01fc: 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_021e: 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_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Expected O, but got Unknown
			//IL_0278: 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)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Expected O, but got Unknown
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Expected O, but got Unknown
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03da: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
			if (!Application.isPlaying)
			{
				if ((Object)(object)defaultBump == (Object)null)
				{
					defaultBump = new Texture2D(1, 1, (TextureFormat)4, false);
					Texture2D obj = defaultBump;
					Color val = default(Color);
					((Color)(ref val))..ctor(0.5f, 0.5f, 1f, 0.5f);
					obj.SetPixel(0, 0, ((Color)(ref val)).gamma);
					defaultBump.Apply(false);
				}
				Shader.SetGlobalTexture(_LuxWater_NormalOverlayPID, (Texture)(object)defaultBump);
				Shader.SetGlobalTexture(_LuxWater_FoamOverlayPID, (Texture)(object)Texture2D.blackTexture);
				return;
			}
			cam = ((Component)this).GetComponent<Camera>();
			if ((Object)(object)SceneView.currentDrawingSceneView != (Object)null && (Object)(object)SceneView.currentDrawingSceneView.camera == (Object)(object)cam)
			{
				return;
			}
			int count = LuxWater_Projector.FoamProjectors.Count;
			int count2 = LuxWater_Projector.NormalProjectors.Count;
			if (count + count2 == 0)
			{
				if (cb_Foam != null)
				{
					cb_Foam.Clear();
				}
				if (cb_Normals != null)
				{
					cb_Normals.Clear();
				}
				Shader.DisableKeyword("USINGWATERPROJECTORS");
				return;
			}
			Shader.EnableKeyword("USINGWATERPROJECTORS");
			Matrix4x4 projectionMatrix = cam.projectionMatrix;
			Matrix4x4 worldToCameraMatrix = cam.worldToCameraMatrix;
			Matrix4x4 worldToProjectMatrix = projectionMatrix * worldToCameraMatrix;
			int pixelWidth = cam.pixelWidth;
			int pixelHeight = cam.pixelHeight;
			GeomUtil.CalculateFrustumPlanes(frustumPlanes, worldToProjectMatrix);
			int num = Mathf.FloorToInt((float)(pixelWidth / (int)FoamBufferResolution));
			int num2 = Mathf.FloorToInt((float)(pixelHeight / (int)FoamBufferResolution));
			if (!Object.op_Implicit((Object)(object)ProjectedFoam))
			{
				ProjectedFoam = new RenderTexture(num, num2, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)1);
			}
			else if (((Texture)ProjectedFoam).width != num)
			{
				Object.DestroyImmediate((Object)(object)ProjectedFoam);
				ProjectedFoam = new RenderTexture(num, num2, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)1);
			}
			GL.PushMatrix();
			GL.modelview = worldToCameraMatrix;
			GL.LoadProjectionMatrix(projectionMatrix);
			cb_Foam.Clear();
			cb_Foam.SetRenderTarget(RenderTargetIdentifier.op_Implicit((Texture)(object)ProjectedFoam));
			cb_Foam.ClearRenderTarget(true, true, new Color(0f, 0f, 0f, 0f), 1f);
			drawnFoamProjectors = 0;
			for (int i = 0; i < count; i++)
			{
				LuxWater_Projector luxWater_Projector = LuxWater_Projector.FoamProjectors[i];
				tempBounds = luxWater_Projector.m_Rend.bounds;
				if (GeometryUtility.TestPlanesAABB(frustumPlanes, tempBounds))
				{
					cb_Foam.DrawRenderer(luxWater_Projector.m_Rend, luxWater_Projector.m_Mat);
					drawnFoamProjectors++;
				}
			}
			Graphics.ExecuteCommandBuffer(cb_Foam);
			Shader.SetGlobalTexture(_LuxWater_FoamOverlayPID, (Texture)(object)ProjectedFoam);
			num = Mathf.FloorToInt((float)(pixelWidth / (int)NormalBufferResolution));
			num2 = Mathf.FloorToInt((float)(pixelHeight / (int)NormalBufferResolution));
			if (!Object.op_Implicit((Object)(object)ProjectedNormals))
			{
				ProjectedNormals = new RenderTexture(num, num2, 0, (RenderTextureFormat)2, (RenderTextureReadWrite)1);
			}
			else if (((Texture)ProjectedNormals).width != num)
			{
				Object.DestroyImmediate((Object)(object)ProjectedNormals);
				ProjectedNormals = new RenderTexture(num, num2, 0, (RenderTextureFormat)2, (RenderTextureReadWrite)1);
			}
			cb_Normals.Clear();
			cb_Normals.SetRenderTarget(RenderTargetIdentifier.op_Implicit((Texture)(object)ProjectedNormals));
			cb_Normals.ClearRenderTarget(true, true, new Color(0f, 0f, 0f, 0f), 1f);
			drawnNormalProjectors = 0;
			for (int j = 0; j < count2; j++)
			{
				LuxWater_Projector luxWater_Projector2 = LuxWater_Projector.NormalProjectors[j];
				tempBounds = luxWater_Projector2.m_Rend.bounds;
				if (GeometryUtility.TestPlanesAABB(frustumPlanes, tempBounds))
				{
					cb_Normals.DrawRenderer(luxWater_Projector2.m_Rend, luxWater_Projector2.m_Mat);
					drawnNormalProjectors++;
				}
			}
			Graphics.ExecuteCommandBuffer(cb_Normals);
			Shader.SetGlobalTexture(_LuxWater_NormalOverlayPID, (Texture)(object)ProjectedNormals);
			GL.PopMatrix();
		}

		private void OnDrawGizmos()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_00b8: 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)
			Camera component = ((Component)this).GetComponent<Camera>();
			int num = 0;
			int num2 = (int)(component.aspect * 128f);
			if ((Object)(object)DebugMat == (Object)null)
			{
				DebugMat = new Material(Shader.Find("Hidden/LuxWater_Debug"));
			}
			if ((Object)(object)DebugNormalMat == (Object)null)
			{
				DebugNormalMat = new Material(Shader.Find("Hidden/LuxWater_DebugNormals"));
			}
			if (DebugFoamBuffer)
			{
				if ((Object)(object)ProjectedFoam == (Object)null)
				{
					return;
				}
				GL.PushMatrix();
				GL.LoadPixelMatrix(0f, (float)Screen.width, (float)Screen.height, 0f);
				Graphics.DrawTexture(new Rect((float)num, 0f, (float)num2, 128f), (Texture)(object)ProjectedFoam, DebugMat);
				GL.PopMatrix();
				num = num2;
			}
			if (DebugNormalBuffer && !((Object)(object)ProjectedNormals == (Object)null))
			{
				GL.PushMatrix();
				GL.LoadPixelMatrix(0f, (float)Screen.width, (float)Screen.height, 0f);
				Graphics.DrawTexture(new Rect((float)num, 0f, (float)num2, 128f), (Texture)(object)ProjectedNormals, DebugNormalMat);
				GL.PopMatrix();
			}
		}

		private void OnGUI()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			if (DebugStats)
			{
				int count = LuxWater_Projector.FoamProjectors.Count;
				int count2 = LuxWater_Projector.NormalProjectors.Count;
				TextAnchor alignment = GUI.skin.label.alignment;
				GUI.skin.label.alignment = (TextAnchor)3;
				GUI.Label(new Rect(10f, 0f, 300f, 40f), "Foam Projectors   [Registered] " + count + "  [Drawn] " + drawnFoamProjectors);
				GUI.Label(new Rect(10f, 18f, 300f, 40f), "Normal Projectors [Registered] " + count2 + "  [Drawn] " + drawnNormalProjectors);
				GUI.skin.label.alignment = alignment;
			}
		}
	}
	public static class GeomUtil
	{
		private static Action<Plane[], Matrix4x4> _calculateFrustumPlanes_Imp;

		public static void CalculateFrustumPlanes(Plane[] planes, Matrix4x4 worldToProjectMatrix)
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			if (_calculateFrustumPlanes_Imp == null)
			{
				MethodInfo method = typeof(GeometryUtility).GetMethod("Internal_ExtractPlanes", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[2]
				{
					typeof(Plane[]),
					typeof(Matrix4x4)
				}, null);
				if ((object)method == null)
				{
					throw new Exception("Failed to reflect internal method. Your Unity version may not contain the presumed named method in GeometryUtility.");
				}
				_calculateFrustumPlanes_Imp = Delegate.CreateDelegate(typeof(Action<Plane[], Matrix4x4>), method) as Action<Plane[], Matrix4x4>;
				if (_calculateFrustumPlanes_Imp == null)
				{
					throw new Exception("Failed to reflect internal method. Your Unity version may not contain the presumed named method in GeometryUtility.");
				}
			}
			_calculateFrustumPlanes_Imp(planes, worldToProjectMatrix);
		}
	}
	[RequireComponent(typeof(Camera))]
	public class LuxWater_UnderWaterBlur : MonoBehaviour
	{
		[Space(6f)]
		[LuxWater_HelpBtn("h.3a2840a53u5j")]
		public float blurSpread = 0.6f;

		public int blurDownSample = 4;

		public int blurIterations = 4;

		private Vector2[] m_offsets = (Vector2[])(object)new Vector2[4];

		private Material blurMaterial;

		private Material blitMaterial;

		private LuxWater_UnderWaterRendering waterrendermanager;

		private bool doBlur = false;

		private bool initBlur = true;

		private void OnEnable()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			blurMaterial = new Material(Shader.Find("Hidden/Lux Water/BlurEffectConeTap"));
			blitMaterial = new Material(Shader.Find("Hidden/Lux Water/UnderWaterPost"));
			((MonoBehaviour)this).Invoke("GetWaterrendermanagerInstance", 0f);
		}

		private void OnDisable()
		{
			if (Object.op_Implicit((Object)(object)blurMaterial))
			{
				Object.DestroyImmediate((Object)(object)blurMaterial);
			}
			if (Object.op_Implicit((Object)(object)blitMaterial))
			{
				Object.DestroyImmediate((Object)(object)blitMaterial);
			}
		}

		private void GetWaterrendermanagerInstance()
		{
			waterrendermanager = LuxWater_UnderWaterRendering.instance;
		}

		private void OnRenderImage(RenderTexture src, RenderTexture dest)
		{
			if ((Object)(object)waterrendermanager == (Object)null)
			{
				Graphics.Blit((Texture)(object)src, dest);
				return;
			}
			doBlur = waterrendermanager.activeWaterVolume > -1;
			if (doBlur || initBlur)
			{
				initBlur = false;
				int num = ((Texture)src).width / blurDownSample;
				int num2 = ((Texture)src).height / blurDownSample;
				RenderTexture val = RenderTexture.GetTemporary(num, num2, 0, (RenderTextureFormat)9);
				DownSample(src, val);
				for (int i = 0; i < blurIterations; i++)
				{
					RenderTexture temporary = RenderTexture.GetTemporary(num, num2, 0, (RenderTextureFormat)9);
					FourTapCone(val, temporary, i);
					RenderTexture.ReleaseTemporary(val);
					val = temporary;
				}
				Shader.SetGlobalTexture("_UnderWaterTex", (Texture)(object)val);
				Graphics.Blit((Texture)(object)src, dest, blitMaterial, 1);
				RenderTexture.ReleaseTemporary(val);
			}
			else
			{
				Graphics.Blit((Texture)(object)src, dest);
			}
		}

		private void FourTapCone(RenderTexture source, RenderTexture dest, int iteration)
		{
			float num = 0.5f + (float)iteration * blurSpread;
			m_offsets[0].x = 0f - num;
			m_offsets[0].y = 0f - num;
			m_offsets[1].x = 0f - num;
			m_offsets[1].y = num;
			m_offsets[2].x = num;
			m_offsets[2].y = num;
			m_offsets[3].x = num;
			m_offsets[3].y = 0f - num;
			if (iteration == 0)
			{
				Graphics.BlitMultiTap((Texture)(object)source, dest, blurMaterial, m_offsets);
			}
			else
			{
				Graphics.BlitMultiTap((Texture)(object)source, dest, blurMaterial, m_offsets);
			}
		}

		private void DownSample(RenderTexture source, RenderTexture dest)
		{
			float num = 1f;
			m_offsets[0].x = 0f - num;
			m_offsets[0].y = 0f - num;
			m_offsets[1].x = 0f - num;
			m_offsets[1].y = num;
			m_offsets[2].x = num;
			m_offsets[2].y = num;
			m_offsets[3].x = num;
			m_offsets[3].y = 0f - num;
			Graphics.BlitMultiTap((Texture)(object)source, dest, blurMaterial, m_offsets);
		}
	}
	[RequireComponent(typeof(Camera))]
	public class LuxWater_UnderWaterRendering : MonoBehaviour
	{
		public static LuxWater_UnderWaterRendering instance;

		[Space(6f)]
		[LuxWater_HelpBtn("h.d0q6uguuxpy")]
		public Transform Sun;

		[Space(4f)]
		public bool FindSunOnEnable = false;

		public string SunGoName = "";

		public string SunTagName = "";

		private Light SunLight;

		[Space(2f)]
		[Header("Deep Water Lighting")]
		[Space(4f)]
		public bool EnableDeepwaterLighting = false;

		public float DefaultWaterSurfacePosition = 0f;

		public float DirectionalLightingFadeRange = 64f;

		public float FogLightingFadeRange = 64f;

		[Space(2f)]
		[Header("Advanced Deferred Fog")]
		[Space(4f)]
		public bool EnableAdvancedDeferredFog = false;

		public float FogDepthShift = 1f;

		public float FogEdgeBlending = 0.125f;

		[NonSerialized]
		[Space(8f)]
		public int activeWaterVolume = -1;

		[NonSerialized]
		public List<Camera> activeWaterVolumeCameras = new List<Camera>();

		[NonSerialized]
		public float activeGridSize = 0f;

		[NonSerialized]
		public float WaterSurfacePos = 0f;

		[NonSerialized]
		[Space(8f)]
		public List<int> RegisteredWaterVolumesIDs = new List<int>();

		[NonSerialized]
		public List<LuxWater_WaterVolume> RegisteredWaterVolumes = new List<LuxWater_WaterVolume>();

		private List<Mesh> WaterMeshes = new List<Mesh>();

		private List<Transform> WaterTransforms = new List<Transform>();

		private List<Material> WaterMaterials = new List<Material>();

		private List<bool> WaterIsOnScreen = new List<bool>();

		private List<bool> WaterUsesSlidingVolume = new List<bool>();

		private RenderTexture UnderWaterMask;

		[Space(2f)]
		[Header("Managed transparent Materials")]
		[Space(4f)]
		public List<Material> m_aboveWatersurface = new List<Material>();

		public List<Material> m_belowWatersurface = new List<Material>();

		[Space(2f)]
		[Header("Optimize")]
		[Space(4f)]
		public ShaderVariantCollection PrewarmedShaders;

		public int ListCapacity = 10;

		[Space(2f)]
		[Header("Debug")]
		[Space(4f)]
		public bool enableDebug = false;

		[Space(8f)]
		private Material mat;

		private Material blurMaterial;

		private Material blitMaterial;

		private Camera cam;

		private bool UnderwaterIsSetUp = false;

		private Transform camTransform;

		private Matrix4x4 frustumCornersArray = Matrix4x4.identity;

		private SphericalHarmonicsL2 ambientProbe;

		private Vector3[] directions = (Vector3[])(object)new Vector3[1]
		{
			new Vector3(0f, 1f, 0f)
		};

		private Color[] AmbientLightingSamples = (Color[])(object)new Color[1];

		private bool DoUnderWaterRendering = false;

		private Matrix4x4 camProj;

		private Vector3[] frustumCorners = (Vector3[])(object)new Vector3[4];

		private float Projection;

		private bool islinear = false;

		private Matrix4x4 WatervolumeMatrix;

		private int UnderWaterMaskPID;

		private int Lux_FrustumCornersWSPID;

		private int Lux_CameraWSPID;

		private int GerstnerEnabledPID;

		private int LuxWaterMask_GerstnerVertexIntensityPID;

		private int GerstnerVertexIntensityPID;

		private int LuxWaterMask_GAmplitudePID;

		private int GAmplitudePID;

		private int LuxWaterMask_GFinalFrequencyPID;

		private int GFinalFrequencyPID;

		private int LuxWaterMask_GSteepnessPID;

		private int GSteepnessPID;

		private int LuxWaterMask_GFinalSpeedPID;

		private int GFinalSpeedPID;

		private int LuxWaterMask_GDirectionABPID;

		private int GDirectionABPID;

		private int LuxWaterMask_GDirectionCDPID;

		private int GDirectionCDPID;

		private int LuxWaterMask_GerstnerSecondaryWaves;

		private int GerstnerSecondaryWaves;

		private int Lux_UnderWaterAmbientSkyLightPID;

		private int Lux_UnderWaterSunColorPID;

		private int Lux_UnderWaterSunDirPID;

		private int Lux_UnderWaterSunDirViewSpacePID;

		private int Lux_EdgeLengthPID;

		private int Lux_CausticsEnabledPID;

		private int Lux_CausticModePID;

		private int Lux_UnderWaterFogColorPID;

		private int Lux_UnderWaterFogDensityPID;

		private int Lux_UnderWaterFogAbsorptionCancellationPID;

		private int Lux_UnderWaterAbsorptionHeightPID;

		private int Lux_UnderWaterAbsorptionMaxHeightPID;

		private int Lux_MaxDirLightDepthPID;

		private int Lux_MaxFogLightDepthPID;

		private int Lux_UnderWaterAbsorptionDepthPID;

		private int Lux_UnderWaterAbsorptionColorStrengthPID;

		private int Lux_UnderWaterAbsorptionStrengthPID;

		private int Lux_UnderWaterUnderwaterScatteringPowerPID;

		private int Lux_UnderWaterUnderwaterScatteringIntensityPID;

		private int Lux_UnderWaterUnderwaterScatteringColorPID;

		private int Lux_UnderWaterUnderwaterScatteringOcclusionPID;

		private int Lux_UnderWaterCausticsPID;

		private int Lux_UnderWaterDeferredFogParams;

		private int CausticTexPID;

		private void OnEnable()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_008b: 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_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Invalid comparison between Unknown and I4
			if ((Object)(object)instance != (Object)null)
			{
				Object.Destroy((Object)(object)this);
			}
			else
			{
				instance = this;
			}
			mat = new Material(Shader.Find("Hidden/Lux Water/WaterMask"));
			blurMaterial = new Material(Shader.Find("Hidden/Lux Water/BlurEffectConeTap"));
			blitMaterial = new Material(Shader.Find("Hidden/Lux Water/UnderWaterPost"));
			if ((Object)(object)cam == (Object)null)
			{
				cam = ((Component)this).GetComponent<Camera>();
			}
			Camera obj = cam;
			obj.depthTextureMode = (DepthTextureMode)(obj.depthTextureMode | 1);
			camTransform = ((Component)cam).transform;
			if (FindSunOnEnable)
			{
				if (SunGoName != "")
				{
					Sun = GameObject.Find(SunGoName).transform;
				}
				else if (SunTagName != "")
				{
					Sun = GameObject.FindWithTag(SunTagName).transform;
				}
			}
			if (SystemInfo.usesReversedZBuffer)
			{
				Projection = -1f;
			}
			else
			{
				Projection = 1f;
			}
			UnderWaterMaskPID = Shader.PropertyToID("_UnderWaterMask");
			Lux_FrustumCornersWSPID = Shader.PropertyToID("_Lux_FrustumCornersWS");
			Lux_CameraWSPID = Shader.PropertyToID("_Lux_CameraWS");
			GerstnerEnabledPID = Shader.PropertyToID("_GerstnerEnabled");
			LuxWaterMask_GerstnerVertexIntensityPID = Shader.PropertyToID("_LuxWaterMask_GerstnerVertexIntensity");
			GerstnerVertexIntensityPID = Shader.PropertyToID("_GerstnerVertexIntensity");
			LuxWaterMask_GAmplitudePID = Shader.PropertyToID("_LuxWaterMask_GAmplitude");
			GAmplitudePID = Shader.PropertyToID("_GAmplitude");
			LuxWaterMask_GFinalFrequencyPID = Shader.PropertyToID("_LuxWaterMask_GFinalFrequency");
			GFinalFrequencyPID = Shader.PropertyToID("_GFinalFrequency");
			LuxWaterMask_GSteepnessPID = Shader.PropertyToID("_LuxWaterMask_GSteepness");
			GSteepnessPID = Shader.PropertyToID("_GSteepness");
			LuxWaterMask_GFinalSpeedPID = Shader.PropertyToID("_LuxWaterMask_GFinalSpeed");
			GFinalSpeedPID = Shader.PropertyToID("_GFinalSpeed");
			LuxWaterMask_GDirectionABPID = Shader.PropertyToID("_LuxWaterMask_GDirectionAB");
			GDirectionABPID = Shader.PropertyToID("_GDirectionAB");
			LuxWaterMask_GDirectionCDPID = Shader.PropertyToID("_LuxWaterMask_GDirectionCD");
			GDirectionCDPID = Shader.PropertyToID("_GDirectionCD");
			LuxWaterMask_GerstnerSecondaryWaves = Shader.PropertyToID("_LuxWaterMask_GerstnerSecondaryWaves");
			GerstnerSecondaryWaves = Shader.PropertyToID("_GerstnerSecondaryWaves");
			Lux_UnderWaterAmbientSkyLightPID = Shader.PropertyToID("_Lux_UnderWaterAmbientSkyLight");
			Lux_UnderWaterSunColorPID = Shader.PropertyToID("_Lux_UnderWaterSunColor");
			Lux_UnderWaterSunDirPID = Shader.PropertyToID("_Lux_UnderWaterSunDir");
			Lux_UnderWaterSunDirViewSpacePID = Shader.PropertyToID("_Lux_UnderWaterSunDirViewSpace");
			Lux_EdgeLengthPID = Shader.PropertyToID("_LuxWater_EdgeLength");
			Lux_MaxDirLightDepthPID = Shader.PropertyToID("_MaxDirLightDepth");
			Lux_MaxFogLightDepthPID = Shader.PropertyToID("_MaxFogLightDepth");
			Lux_CausticsEnabledPID = Shader.PropertyToID("_CausticsEnabled");
			Lux_CausticModePID = Shader.PropertyToID("_CausticMode");
			Lux_UnderWaterFogColorPID = Shader.PropertyToID("_Lux_UnderWaterFogColor");
			Lux_UnderWaterFogDensityPID = Shader.PropertyToID("_Lux_UnderWaterFogDensity");
			Lux_UnderWaterFogAbsorptionCancellationPID = Shader.PropertyToID("_Lux_UnderWaterFogAbsorptionCancellation");
			Lux_UnderWaterAbsorptionHeightPID = Shader.PropertyToID("_Lux_UnderWaterAbsorptionHeight");
			Lux_UnderWaterAbsorptionMaxHeightPID = Shader.PropertyToID("_Lux_UnderWaterAbsorptionMaxHeight");
			Lux_UnderWaterAbsorptionDepthPID = Shader.PropertyToID("_Lux_UnderWaterAbsorptionDepth");
			Lux_UnderWaterAbsorptionColorStrengthPID = Shader.PropertyToID("_Lux_UnderWaterAbsorptionColorStrength");
			Lux_UnderWaterAbsorptionStrengthPID = Shader.PropertyToID("_Lux_UnderWaterAbsorptionStrength");
			Lux_UnderWaterUnderwaterScatteringPowerPID = Shader.PropertyToID("_Lux_UnderWaterUnderwaterScatteringPower");
			Lux_UnderWaterUnderwaterScatteringIntensityPID = Shader.PropertyToID("_Lux_UnderWaterUnderwaterScatteringIntensity");
			Lux_UnderWaterUnderwaterScatteringColorPID = Shader.PropertyToID("_Lux_UnderWaterUnderwaterScatteringColor");
			Lux_UnderWaterUnderwaterScatteringOcclusionPID = Shader.PropertyToID("_Lux_UnderwaterScatteringOcclusion");
			Lux_UnderWaterCausticsPID = Shader.PropertyToID("_Lux_UnderWaterCaustics");
			Lux_UnderWaterDeferredFogParams = Shader.PropertyToID("_LuxUnderWaterDeferredFogParams");
			CausticTexPID = Shader.PropertyToID("_CausticTex");
			islinear = (int)QualitySettings.desiredColorSpace == 1;
			if ((Object)(object)PrewarmedShaders != (Object)null && !PrewarmedShaders.isWarmedUp)
			{
				PrewarmedShaders.WarmUp();
			}
			if ((Object)(object)Sun != (Object)null)
			{
				SunLight = ((Component)Sun).GetComponent<Light>();
			}
			RegisteredWaterVolumesIDs.Capacity = ListCapacity;
			RegisteredWaterVolumes.Capacity = ListCapacity;
			WaterMeshes.Capacity = ListCapacity;
			WaterTransforms.Capacity = ListCapacity;
			WaterMaterials.Capacity = ListCapacity;
			WaterIsOnScreen.Capacity = ListCapacity;
			WaterUsesSlidingVolume.Capacity = ListCapacity;
			activeWaterVolumeCameras.Capacity = 2;
			SetDeepwaterLighting();
			SetDeferredFogParams();
		}

		private void CleanUp()
		{
			instance = null;
			if ((Object)(object)UnderWaterMask != (Object)null)
			{
				UnderWaterMask.Release();
				Object.Destroy((Object)(object)UnderWaterMask);
			}
			if (Object.op_Implicit((Object)(object)mat))
			{
				Object.Destroy((Object)(object)mat);
			}
			if (Object.op_Implicit((Object)(object)blurMaterial))
			{
				Object.Destroy((Object)(object)blurMaterial);
			}
			if (Object.op_Implicit((Object)(object)blitMaterial))
			{
				Object.Destroy((Object)(object)blitMaterial);
			}
			Shader.DisableKeyword("LUXWATER_DEEPWATERLIGHTING");
			Shader.DisableKeyword("LUXWATER_DEFERREDFOG");
		}

		private void OnDisable()
		{
			CleanUp();
		}

		private void OnDestroy()
		{
			CleanUp();
		}

		private void OnValidate()
		{
			SetDeepwaterLighting();
			SetDeferredFogParams();
		}

		public void SetDeferredFogParams()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			if (EnableAdvancedDeferredFog)
			{
				Shader.EnableKeyword("LUXWATER_DEFERREDFOG");
				Vector4 val = default(Vector4);
				((Vector4)(ref val))..ctor((float)(DoUnderWaterRendering ? 1 : 0), FogDepthShift, FogEdgeBlending, 0f);
				Shader.SetGlobalVector(Lux_UnderWaterDeferredFogParams, val);
			}
			else
			{
				Shader.DisableKeyword("LUXWATER_DEFERREDFOG");
			}
		}

		public void SetDeepwaterLighting()
		{
			if (EnableDeepwaterLighting)
			{
				Shader.EnableKeyword("LUXWATER_DEEPWATERLIGHTING");
				if (activeWaterVolume != -1)
				{
					Shader.SetGlobalFloat("_Lux_UnderWaterWaterSurfacePos", WaterSurfacePos);
				}
				else
				{
					Shader.SetGlobalFloat("_Lux_UnderWaterWaterSurfacePos", DefaultWaterSurfacePosition);
				}
				Shader.SetGlobalFloat("_Lux_UnderWaterDirLightingDepth", DirectionalLightingFadeRange);
				Shader.SetGlobalFloat("_Lux_UnderWaterFogLightingDepth", FogLightingFadeRange);
			}
			else
			{
				Shader.DisableKeyword("LUXWATER_DEEPWATERLIGHTING");
			}
		}

		public void RegisterWaterVolume(LuxWater_WaterVolume item, int ID, bool visible, bool SlidingVolume)
		{
			RegisteredWaterVolumesIDs.Add(ID);
			RegisteredWaterVolumes.Add(item);
			WaterMeshes.Add(item.WaterVolumeMesh);
			WaterMaterials.Add(((Component)((Component)item).transform).GetComponent<Renderer>().sharedMaterial);
			WaterTransforms.Add(((Component)item).transform);
			WaterIsOnScreen.Add(visible);
			WaterUsesSlidingVolume.Add(SlidingVolume);
			int num = WaterMaterials.Count - 1;
			Shader.SetGlobalTexture(Lux_UnderWaterCausticsPID, WaterMaterials[num].GetTexture(CausticTexPID));
			SetGerstnerWaves(num);
		}

		public void DeRegisterWaterVolume(LuxWater_WaterVolume item, int ID)
		{
			int num = RegisteredWaterVolumesIDs.IndexOf(ID);
			if (activeWaterVolume == num)
			{
				activeWaterVolume = -1;
			}
			RegisteredWaterVolumesIDs.RemoveAt(num);
			RegisteredWaterVolumes.RemoveAt(num);
			WaterMeshes.RemoveAt(num);
			WaterMaterials.RemoveAt(num);
			WaterTransforms.RemoveAt(num);
			WaterIsOnScreen.RemoveAt(num);
			WaterUsesSlidingVolume.RemoveAt(num);
		}

		public void SetWaterVisible(int ID)
		{
			int index = RegisteredWaterVolumesIDs.IndexOf(ID);
			WaterIsOnScreen[index] = true;
		}

		public void SetWaterInvisible(int ID)
		{
			int index = RegisteredWaterVolumesIDs.IndexOf(ID);
			WaterIsOnScreen[index] = false;
		}

		public void EnteredWaterVolume(LuxWater_WaterVolume item, int ID, Camera triggerCam, float GridSize)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			DoUnderWaterRendering = true;
			int num = RegisteredWaterVolumesIDs.IndexOf(ID);
			if (num != activeWaterVolume)
			{
				activeWaterVolume = num;
				activeGridSize = GridSize;
				WaterSurfacePos = WaterTransforms[activeWaterVolume].position.y;
				for (int i = 0; i < m_aboveWatersurface.Count; i++)
				{
					m_aboveWatersurface[i].renderQueue = 2997;
				}
				for (int j = 0; j < m_belowWatersurface.Count; j++)
				{
					m_belowWatersurface[j].renderQueue = 3001;
				}
			}
			if (!activeWaterVolumeCameras.Contains(triggerCam))
			{
				activeWaterVolumeCameras.Add(triggerCam);
			}
		}

		public void LeftWaterVolume(LuxWater_WaterVolume item, int ID, Camera triggerCam)
		{
			DoUnderWaterRendering = false;
			int num = RegisteredWaterVolumesIDs.IndexOf(ID);
			if (activeWaterVolume == num)
			{
				activeWaterVolume = -1;
				for (int i = 0; i < m_aboveWatersurface.Count; i++)
				{
					m_aboveWatersurface[i].renderQueue = 3000;
				}
				for (int j = 0; j < m_belowWatersurface.Count; j++)
				{
					m_belowWatersurface[j].renderQueue = 2997;
				}
			}
			if (activeWaterVolumeCameras.Contains(triggerCam))
			{
				activeWaterVolumeCameras.Remove(triggerCam);
			}
		}

		private void OnPreCull()
		{
			SetDeferredFogParams();
			RenderWaterMask(cam, SecondaryCameraRendering: false);
		}

		[ImageEffectOpaque]
		private void OnRenderImage(RenderTexture src, RenderTexture dest)
		{
			RenderUnderWater(src, dest, cam, SecondaryCameraRendering: false);
		}

		public void SetGerstnerWaves(int index)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			if (WaterMaterials[index].GetFloat(GerstnerEnabledPID) == 1f)
			{
				mat.EnableKeyword("GERSTNERENABLED");
				mat.SetVector(LuxWaterMask_GerstnerVertexIntensityPID, WaterMaterials[index].GetVector(GerstnerVertexIntensityPID));
				mat.SetVector(LuxWaterMask_GAmplitudePID, WaterMaterials[index].GetVector(GAmplitudePID));
				mat.SetVector(LuxWaterMask_GFinalFrequencyPID, WaterMaterials[index].GetVector(GFinalFrequencyPID));
				mat.SetVector(LuxWaterMask_GSteepnessPID, WaterMaterials[index].GetVector(GSteepnessPID));
				mat.SetVector(LuxWaterMask_GFinalSpeedPID, WaterMaterials[index].GetVector(GFinalSpeedPID));
				mat.SetVector(LuxWaterMask_GDirectionABPID, WaterMaterials[index].GetVector(GDirectionABPID));
				mat.SetVector(LuxWaterMask_GDirectionCDPID, WaterMaterials[index].GetVector(GDirectionCDPID));
				mat.SetVector(LuxWaterMask_GerstnerSecondaryWaves, WaterMaterials[index].GetVector(GerstnerSecondaryWaves));
			}
			else
			{
				mat.DisableKeyword("GERSTNERENABLED");
			}
		}

		public void RenderWaterMask(Camera currentCamera, bool SecondaryCameraRendering)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_0060: Expected O, but got Unknown
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: 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_012f: 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_0147: 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_0151: 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_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: 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_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: 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_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: 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)
			//IL_009e: Expected O, but got Unknown
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0444: Unknown result type (might be due to invalid IL or missing references)
			//IL_0462: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_0470: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_0484: Unknown result type (might be due to invalid IL or missing references)
			//IL_0489: Unknown result type (might be due to invalid IL or missing references)
			//IL_052f: Unknown result type (might be due to invalid IL or missing references)
			//IL_058c: Unknown result type (might be due to invalid IL or missing references)
			//IL_05aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0604: Unknown result type (might be due to invalid IL or missing references)
			//IL_0622: Unknown result type (might be due to invalid IL or missing references)
			//IL_0640: Unknown result type (might be due to invalid IL or missing references)
			//IL_065e: Unknown result type (might be due to invalid IL or missing references)
			//IL_074c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0805: Unknown result type (might be due to invalid IL or missing references)
			Shader.SetGlobalFloat("_Lux_Time", Time.timeSinceLevelLoad);
			currentCamera.depthTextureMode = (DepthTextureMode)(currentCamera.depthTextureMode | 1);
			camTransform = ((Component)currentCamera).transform;
			Profiler.BeginSample("Create UnderWaterMask Tex");
			if (!Object.op_Implicit((Object)(object)UnderWaterMask))
			{
				UnderWaterMask = new RenderTexture(currentCamera.pixelWidth, currentCamera.pixelHeight, 24, (RenderTextureFormat)0, (RenderTextureReadWrite)1);
			}
			else if (((Texture)UnderWaterMask).width != currentCamera.pixelWidth && !SecondaryCameraRendering)
			{
				UnderWaterMask = new RenderTexture(currentCamera.pixelWidth, currentCamera.pixelHeight, 24, (RenderTextureFormat)0, (RenderTextureReadWrite)1);
			}
			Shader.SetGlobalTexture(UnderWaterMaskPID, (Texture)(object)UnderWaterMask);
			Graphics.SetRenderTarget(UnderWaterMask);
			Profiler.EndSample();
			Profiler.BeginSample("Set up Frustum Corners");
			currentCamera.CalculateFrustumCorners(new Rect(0f, 0f, 1f, 1f), currentCamera.farClipPlane, currentCamera.stereoActiveEye, frustumCorners);
			Vector3 val = camTransform.TransformVector(frustumCorners[0]);
			Vector3 val2 = camTransform.TransformVector(frustumCorners[1]);
			Vector3 val3 = camTransform.TransformVector(frustumCorners[2]);
			Vector3 val4 = camTransform.TransformVector(frustumCorners[3]);
			((Matrix4x4)(ref frustumCornersArray)).SetRow(0, Vector4.op_Implicit(val));
			((Matrix4x4)(ref frustumCornersArray)).SetRow(1, Vector4.op_Implicit(val4));
			((Matrix4x4)(ref frustumCornersArray)).SetRow(2, Vector4.op_Implicit(val2));
			((Matrix4x4)(ref frustumCornersArray)).SetRow(3, Vector4.op_Implicit(val3));
			Shader.SetGlobalMatrix(Lux_FrustumCornersWSPID, frustumCornersArray);
			Shader.SetGlobalVector(Lux_CameraWSPID, Vector4.op_Implicit(camTransform.position));
			Profiler.EndSample();
			Profiler.BeginSample("Set up ambient lighting");
			ambientProbe = RenderSettings.ambientProbe;
			((SphericalHarmonicsL2)(ref ambientProbe)).Evaluate(directions, AmbientLightingSamples);
			if (islinear)
			{
				int lux_UnderWaterAmbientSkyLightPID = Lux_UnderWaterAmbientSkyLightPID;
				Color val5 = AmbientLightingSamples[0] * RenderSettings.ambientIntensity;
				Shader.SetGlobalColor(lux_UnderWaterAmbientSkyLightPID, ((Color)(ref val5)).linear);
			}
			else
			{
				Shader.SetGlobalColor(Lux_UnderWaterAmbientSkyLightPID, AmbientLightingSamples[0] * RenderSettings.ambientIntensity);
			}
			Profiler.EndSample();
			if (activeWaterVolumeCameras.Contains(currentCamera) || !EnableAdvancedDeferredFog)
			{
			}
			if (activeWaterVolume > -1)
			{
				Shader.EnableKeyword("LUXWATERENABLED");
				if (!EnableDeepwaterLighting)
				{
					Shader.SetGlobalFloat("_Lux_UnderWaterDirLightingDepth", WaterMaterials[activeWaterVolume].GetFloat(Lux_MaxDirLightDepthPID));
					Shader.SetGlobalFloat("_Lux_UnderWaterFogLightingDepth", WaterMaterials[activeWaterVolume].GetFloat(Lux_MaxFogLightDepthPID));
				}
				Shader.SetGlobalFloat("_Lux_UnderWaterWaterSurfacePos", WaterSurfacePos);
			}
			else
			{
				Shader.DisableKeyword("LUXWATERENABLED");
			}
			GL.PushMatrix();
			GL.Clear(true, true, Color.black, 1f);
			camProj = currentCamera.projectionMatrix;
			GL.LoadProjectionMatrix(camProj);
			Shader.SetGlobalVector("_WorldSpaceCameraPos", Vector4.op_Implicit(camTransform.position));
			Shader.SetGlobalVector("_ProjectionParams", new Vector4(Projection, currentCamera.nearClipPlane, currentCamera.farClipPlane, 1f / currentCamera.farClipPlane));
			Shader.SetGlobalVector("_ScreenParams", new Vector4((float)currentCamera.pixelWidth, (float)currentCamera.pixelHeight, 1f + 1f / (float)currentCamera.pixelWidth, 1f + 1f / (float)currentCamera.pixelHeight));
			Vector2 val6 = default(Vector2);
			for (int i = 0; i < RegisteredWaterVolumes.Count; i++)
			{
				if ((!WaterIsOnScreen[i] && i != activeWaterVolume) || (!EnableAdvancedDeferredFog && i != activeWaterVolume))
				{
					continue;
				}
				WatervolumeMatrix = WaterTransforms[i].localToWorldMatrix;
				if (WaterUsesSlidingVolume[i])
				{
					Vector3 position = camTransform.position;
					Vector4 column = ((Matrix4x4)(ref WatervolumeMatrix)).GetColumn(3);
					Vector3 lossyScale = WaterTransforms[i].lossyScale;
					((Vector2)(ref val6))..ctor(activeGridSize * lossyScale.x, activeGridSize * lossyScale.z);
					float num = (float)Math.Round(position.x / val6.x);
					float num2 = val6.x * num;
					num = (float)Math.Round(position.z / val6.y);
					float num3 = val6.y * num;
					column.x = num2 + column.x % val6.x;
					column.z = num3 + column.z % val6.y;
					((Matrix4x4)(ref WatervolumeMatrix)).SetColumn(3, column);
				}
				Material val7 = WaterMaterials[i];
				Profiler.BeginSample("Set up Gerstner");
				if (val7.GetFloat(GerstnerEnabledPID) == 1f)
				{
					mat.EnableKeyword("GERSTNERENABLED");
					mat.SetVector(LuxWaterMask_GerstnerVertexIntensityPID, val7.GetVector(GerstnerVertexIntensityPID));
					mat.SetVector(LuxWaterMask_GAmplitudePID, val7.GetVector(GAmplitudePID));
					mat.SetVector(LuxWaterMask_GFinalFrequencyPID, val7.GetVector(GFinalFrequencyPID));
					mat.SetVector(LuxWaterMask_GSteepnessPID, val7.GetVector(GSteepnessPID));
					mat.SetVector(LuxWaterMask_GFinalSpeedPID, val7.GetVector(GFinalSpeedPID));
					mat.SetVector(LuxWaterMask_GDirectionABPID, val7.GetVector(GDirectionABPID));
					mat.SetVector(LuxWaterMask_GDirectionCDPID, val7.GetVector(GDirectionCDPID));
					mat.SetVector(LuxWaterMask_GerstnerSecondaryWaves, val7.GetVector(GerstnerSecondaryWaves));
				}
				else
				{
					mat.DisableKeyword("GERSTNERENABLED");
				}
				Profiler.EndSample();
				Profiler.BeginSample("Draw Water Mask");
				bool flag = val7.HasProperty(Lux_EdgeLengthPID) && SystemInfo.graphicsShaderLevel >= 46;
				if (flag)
				{
					mat.SetFloat(Lux_EdgeLengthPID, val7.GetFloat(Lux_EdgeLengthPID));
				}
				Profiler.BeginSample("Draw Water Volume");
				if (i == activeWaterVolume && activeWaterVolumeCameras.Contains(currentCamera))
				{
					if (WaterUsesSlidingVolume[i] && flag)
					{
						mat.SetPass(5);
					}
					else
					{
						mat.SetPass(0);
					}
					Graphics.DrawMeshNow(WaterMeshes[i], WatervolumeMatrix, 0);
				}
				Profiler.EndSample();
				if ((i == activeWaterVolume && activeWaterVolumeCameras.Contains(currentCamera)) || EnableAdvancedDeferredFog)
				{
					if (flag)
					{
						if (i == activeWaterVolume)
						{
							mat.SetPass(3);
						}
						else
						{
							mat.SetPass(4);
						}
					}
					else if (i == activeWaterVolume)
					{
						mat.SetPass(1);
					}
					else
					{
						mat.SetPass(2);
					}
					Graphics.DrawMeshNow(WaterMeshes[i], WatervolumeMatrix, 1);
				}
				Profiler.EndSample();
			}
			GL.PopMatrix();
		}

		public void RenderUnderWater(RenderTexture src, RenderTexture dest, Camera currentCamera, bool SecondaryCameraRendering)
		{
			//IL_004e: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//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_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f5: Unknown result type (might be due to invalid IL or missing references)
			if (activeWaterVolumeCameras.Contains(currentCamera))
			{
				if (DoUnderWaterRendering && activeWaterVolume > -1)
				{
					if (!UnderwaterIsSetUp)
					{
						if (Object.op_Implicit((Object)(object)Sun))
						{
							Vector3 val = -Sun.forward;
							Color val2 = SunLight.color * SunLight.intensity;
							if (islinear)
							{
								val2 = ((Color)(ref val2)).linear;
							}
							Shader.SetGlobalColor(Lux_UnderWaterSunColorPID, val2 * Mathf.Clamp01(Vector3.Dot(val, Vector3.up)));
							Shader.SetGlobalVector(Lux_UnderWaterSunDirPID, Vector4.op_Implicit(-val));
							Shader.SetGlobalVector(Lux_UnderWaterSunDirViewSpacePID, Vector4.op_Implicit(currentCamera.WorldToViewportPoint(((Component)currentCamera).transform.position - val * 1000f)));
						}
						if (WaterMaterials[activeWaterVolume].GetFloat(Lux_CausticsEnabledPID) == 1f)
						{
							blitMaterial.EnableKeyword("GEOM_TYPE_FROND");
							if (WaterMaterials[activeWaterVolume].GetFloat(Lux_CausticModePID) == 1f)
							{
								blitMaterial.EnableKeyword("GEOM_TYPE_LEAF");
							}
							else
							{
								blitMaterial.DisableKeyword("GEOM_TYPE_LEAF");
							}
						}
						else
						{
							blitMaterial.DisableKeyword("GEOM_TYPE_FROND");
						}
						if (islinear)
						{
							int lux_UnderWaterFogColorPID = Lux_UnderWaterFogColorPID;
							Color color = WaterMaterials[activeWaterVolume].GetColor("_Color");
							Shader.SetGlobalColor(lux_UnderWaterFogColorPID, ((Color)(ref color)).linear);
						}
						else
						{
							Shader.SetGlobalColor(Lux_UnderWaterFogColorPID, WaterMaterials[activeWaterVolume].GetColor("_Color"));
						}
						Shader.SetGlobalFloat(Lux_UnderWaterFogDensityPID, WaterMaterials[activeWaterVolume].GetFloat("_Density"));
						Shader.SetGlobalFloat(Lux_UnderWaterFogAbsorptionCancellationPID, WaterMaterials[activeWaterVolume].GetFloat("_FogAbsorptionCancellation"));
						Shader.SetGlobalFloat(Lux_UnderWaterAbsorptionHeightPID, WaterMaterials[activeWaterVolume].GetFloat("_AbsorptionHeight"));
						Shader.SetGlobalFloat(Lux_UnderWaterAbsorptionMaxHeightPID, WaterMaterials[activeWaterVolume].GetFloat("_AbsorptionMaxHeight"));
						Shader.SetGlobalFloat(Lux_UnderWaterAbsorptionDepthPID, WaterMaterials[activeWaterVolume].GetFloat("_AbsorptionDepth"));
						Shader.SetGlobalFloat(Lux_UnderWaterAbsorptionColorStrengthPID, WaterMaterials[activeWaterVolume].GetFloat("_AbsorptionColorStrength"));
						Shader.SetGlobalFloat(Lux_UnderWaterAbsorptionStrengthPID, WaterMaterials[activeWaterVolume].GetFloat("_AbsorptionStrength"));
						Shader.SetGlobalFloat(Lux_UnderWaterUnderwaterScatteringPowerPID, WaterMaterials[activeWaterVolume].GetFloat("_ScatteringPower"));
						Shader.SetGlobalFloat(Lux_UnderWaterUnderwaterScatteringIntensityPID, WaterMaterials[activeWaterVolume].GetFloat("_UnderwaterScatteringIntensity"));
						if (islinear)
						{
							int lux_UnderWaterUnderwaterScatteringColorPID = Lux_UnderWaterUnderwaterScatteringColorPID;
							Color color2 = WaterMaterials[activeWaterVolume].GetColor("_TranslucencyColor");
							Shader.SetGlobalColor(lux_UnderWaterUnderwaterScatteringColorPID, ((Color)(ref color2)).linear);
						}
						else
						{
							Shader.SetGlobalColor(Lux_UnderWaterUnderwaterScatteringColorPID, WaterMaterials[activeWaterVolume].GetColor("_TranslucencyColor"));
						}
						Shader.SetGlobalFloat(Lux_UnderWaterUnderwaterScatteringOcclusionPID, WaterMaterials[activeWaterVolume].GetFloat("_ScatterOcclusion"));
						Shader.SetGlobalTexture(Lux_UnderWaterCausticsPID, WaterMaterials[activeWaterVolume].GetTexture(CausticTexPID));
						Shader.SetGlobalFloat("_Lux_UnderWaterCausticsTiling", WaterMaterials[activeWaterVolume].GetFloat("_CausticsTiling"));
						Shader.SetGlobalFloat("_Lux_UnderWaterCausticsScale", WaterMaterials[activeWaterVolume].GetFloat("_CausticsScale"));
						Shader.SetGlobalFloat("_Lux_UnderWaterCausticsSpeed", WaterMaterials[activeWaterVolume].GetFloat("_CausticsSpeed"));
						Shader.SetGlobalFloat("_Lux_UnderWaterCausticsTiling", WaterMaterials[activeWaterVolume].GetFloat("_CausticsTiling"));
						Shader.SetGlobalFloat("_Lux_UnderWaterCausticsSelfDistortion", WaterMaterials[activeWaterVolume].GetFloat("_CausticsSelfDistortion"));
						Shader.SetGlobalVector("_Lux_UnderWaterFinalBumpSpeed01", WaterMaterials[activeWaterVolume].GetVector("_FinalBumpSpeed01"));
						Shader.SetGlobalVector("_Lux_UnderWaterFogDepthAtten", WaterMaterials[activeWaterVolume].GetVector("_DepthAtten"));
					}
					Graphics.Blit((Texture)(object)src, dest, blitMaterial, 0);
				}
				else
				{
					Graphics.Blit((Texture)(object)src, dest);
				}
			}
			else
			{
				Graphics.Blit((Texture)(object)src, dest);
			}
		}

		private void OnDrawGizmos()
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			if (enableDebug && !((Object)(object)cam == (Object)null) && !((Object)(object)UnderWaterMask == (Object)null))
			{
				int num = (int)(cam.aspect * 128f);
				GL.PushMatrix();
				GL.LoadPixelMatrix(0f, (float)Screen.width, (float)Screen.height, 0f);
				Graphics.DrawTexture(new Rect(0f, 0f, (float)num, 128f), (Texture)(object)UnderWaterMask);
				GL.PopMatrix();
			}
		}

		private void OnGUI()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			if (enableDebug)
			{
				TextAnchor alignment = GUI.skin.label.alignment;
				GUI.skin.label.alignment = (TextAnchor)3;
				if (activeWaterVolume == -1)
				{
					GUI.Label(new Rect(10f, 0f, 160f, 40f), "Active water volume: none\nRegistered volumes: " + RegisteredWaterVolumes.Count);
				}
				else
				{
					GUI.Label(new Rect(10f, 0f, 400f, 40f), "Active water volume: " + ((Object)((Component)((Component)RegisteredWaterVolumes[activeWaterVolume]).transform).gameObject).name + "\nRegistered volumes: " + RegisteredWaterVolumes.Count);
				}
				GUI.skin.label.alignment = alignment;
			}
		}
	}
	[RequireComponent(typeof(Camera))]
	public class LuxWater_UnderwaterRenderingSlave : MonoBehaviour
	{
		private LuxWater_UnderWaterRendering waterrendermanager;

		private bool readyToGo = false;

		public Camera cam;

		private void OnEnable()
		{
			cam = ((Component)this).GetComponent<Camera>();
			((MonoBehaviour)this).Invoke("GetWaterrendermanager", 0f);
		}

		private void GetWaterrendermanager()
		{
			LuxWater_UnderWaterRendering instance = LuxWater_UnderWaterRendering.instance;
			if ((Object)(object)instance != (Object)null)
			{
				waterrendermanager = instance;
				readyToGo = true;
			}
		}

		private void OnPreCull()
		{
			if (readyToGo)
			{
				waterrendermanager.RenderWaterMask(cam, SecondaryCameraRendering: true);
			}
		}

		[ImageEffectOpaque]
		private void OnRenderImage(RenderTexture src, RenderTexture dest)
		{
			if (readyToGo)
			{
				waterrendermanager.RenderUnderWater(src, dest, cam, SecondaryCameraRendering: true);
			}
			else
			{
				Graphics.Blit((Texture)(object)src, dest);
			}
		}
	}
	public class LuxWater_WaterVolume : MonoBehaviour
	{
		public delegate void TriggerEnter();

		public delegate void TriggerExit();

		[Space(6f)]
		[LuxWater_HelpBtn("h.86taxuhovssb")]
		public Mesh WaterVolumeMesh;

		[Space(8f)]
		public bool SlidingVolume = false;

		public float GridSize = 10f;

		private LuxWater_UnderWaterRendering waterrendermanager;

		private bool readyToGo = false;

		private int ID;

		public static event TriggerEnter OnEnterWaterVolume;

		public static event TriggerExit OnExitWaterVolume;

		private void OnEnable()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)WaterVolumeMesh == (Object)null)
			{
				Debug.Log((object)"No WaterVolumeMesh assigned.");
				return;
			}
			ID = ((Object)this).GetInstanceID();
			((MonoBehaviour)this).Invoke("Register", 0f);
			Renderer component = ((Component)this).GetComponent<Renderer>();
			component.shadowCastingMode = (ShadowCastingMode)0;
			Material sharedMaterial = component.sharedMaterial;
			sharedMaterial.EnableKeyword("USINGWATERVOLUME");
			sharedMaterial.SetFloat("_WaterSurfaceYPos", ((Component)this).transform.position.y);
		}

		private void OnDisable()
		{
			if (Object.op_Implicit((Object)(object)waterrendermanager))
			{
				waterrendermanager.DeRegisterWaterVolume(this, ID);
			}
			readyToGo = false;
			((Component)this).GetComponent<Renderer>().sharedMaterial.DisableKeyword("USINGWATERVOLUME");
		}

		private void Register()
		{
			LuxWater_UnderWaterRendering instance = LuxWater_UnderWaterRendering.instance;
			if ((Object)(object)instance != (Object)null)
			{
				waterrendermanager = LuxWater_UnderWaterRendering.instance;
				bool isVisible = ((Component)this).GetComponent<Renderer>().isVisible;
				waterrendermanager.RegisterWaterVolume(this, ID, isVisible, SlidingVolume);
				readyToGo = true;
			}
			else
			{
				((MonoBehaviour)this).Invoke("Register", 0f);
			}
		}

		private void OnBecameVisible()
		{
			if (readyToGo)
			{
				waterrendermanager.SetWaterVisible(ID);
			}
		}

		private void OnBecameInvisible()
		{
			if (readyToGo)
			{
				waterrendermanager.SetWaterInvisible(ID);
			}
		}

		private void OnTriggerEnter(Collider other)
		{
			LuxWater_WaterVolumeTrigger component = ((Component)other).GetComponent<LuxWater_WaterVolumeTrigger>();
			if ((Object)(object)component != (Object)null && (Object)(object)waterrendermanager != (Object)null && readyToGo && component.active)
			{
				waterrendermanager.EnteredWaterVolume(this, ID, component.cam, GridSize);
				if (LuxWater_WaterVolume.OnEnterWaterVolume != null)
				{
					LuxWater_WaterVolume.OnEnterWaterVolume();
				}
			}