Decompiled source of SR dod bleakhill2 v0.9.5

SR_dod_bleakhill2.dll

Decompiled 3 months ago
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using Atlas;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEditor;
using UnityEngine;

[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]
internal class LuxTexturePostprocessor : AssetPostprocessor
{
	public const string SpecSuffix = "_LuxSPEC";

	public const string SpecShortSuffix = "LuxSPEC";

	public const string NormalSuffix = "_LuxNRM";

	public const string NormalShortSuffix = "LuxNRM";

	public void OnPostprocessTexture(Texture2D specMap)
	{
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Expected O, but got Unknown
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Expected O, but got Unknown
		if (!((AssetPostprocessor)this).assetPath.Contains("_LuxSPEC"))
		{
			return;
		}
		string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(((AssetPostprocessor)this).assetPath);
		string[] array = fileNameWithoutExtension.Split(new char[1] { '_' });
		string text = string.Empty;
		for (int i = 0; i < array.Length && !(array[i] == "LuxSPEC"); i++)
		{
			text = text + array[i] + '_';
		}
		text += "LuxNRM";
		string text2 = Path.Combine(Path.GetDirectoryName(((AssetPostprocessor)this).assetPath), Path.GetFileNameWithoutExtension(text));
		text2 += Path.GetExtension(((AssetPostprocessor)this).assetPath);
		if (File.Exists(text2))
		{
			TextureImporter val = (TextureImporter)AssetImporter.GetAtPath(text2);
			if (!val.isReadable)
			{
				Debug.Log((object)"Normal texture has to be reimported as readable. Please reimport the _SPEC texture as well.");
				val.isReadable = true;
				AssetDatabase.ImportAsset(text2, (ImportAssetOptions)1);
				return;
			}
			Debug.Log((object)("Filtering Texture: " + fileNameWithoutExtension));
			TextureImporter val2 = (TextureImporter)AssetImporter.GetAtPath(((AssetPostprocessor)this).assetPath);
			val2.isReadable = true;
			val2.filterMode = (FilterMode)2;
			Object obj = AssetDatabase.LoadAssetAtPath(text2, typeof(Texture2D));
			Texture2D bumpMap = (Texture2D)(object)((obj is Texture2D) ? obj : null);
			int width = ((Texture)specMap).width;
			int height = ((Texture)specMap).height;
			int mipmapCount = specMap.mipmapCount;
			for (int j = 1; j < mipmapCount; j++)
			{
				ProcessMipLevel(ref specMap, bumpMap, width, height, j);
			}
			specMap.Apply(false, false);
			bumpMap = null;
		}
		else
		{
			Debug.Log((object)("No corresponding normal map found at:" + text2));
			Debug.Log((object)(Path.GetFileNameWithoutExtension(text) + Path.GetExtension(((AssetPostprocessor)this).assetPath)));
		}
	}

	private static void ProcessMipLevel(ref Texture2D specMap, Texture2D bumpMap, int maxwidth, int maxheight, int mipLevel)
	{
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: 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_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		Color32[] pixels = specMap.GetPixels32(mipLevel);
		Color32[] pixels2 = bumpMap.GetPixels32(0);
		int num = Mathf.Max(1, ((Texture)specMap).width >> mipLevel);
		int num2 = Mathf.Max(1, ((Texture)specMap).height >> mipLevel);
		int num3 = 0;
		int num4 = 1 << mipLevel;
		Vector3 val3 = default(Vector3);
		for (int i = 0; i < num2; i++)
		{
			for (int j = 0; j < num; j++)
			{
				float num5 = (float)j / (float)num;
				float num6 = (float)i / (float)num2;
				int num7 = Mathf.FloorToInt(num5 * (float)maxwidth);
				int num8 = Mathf.FloorToInt(num6 * (float)maxheight);
				Vector3 val = Vector3.zero;
				for (int k = 0; k < num4; k++)
				{
					for (int l = 0; l < num4; l++)
					{
						int num9 = num7 + l;
						int num10 = num8 + k;
						Color32 val2 = pixels2[num10 * maxheight + num9];
						((Vector3)(ref val3))..ctor((float)(int)val2.a / 255f * 2f - 1f, (float)(int)val2.g / 255f * 2f - 1f, 0f);
						val3.z = Mathf.Sqrt(1f - val3.x * val3.x - val3.y * val3.y);
						((Vector3)(ref val3)).Normalize();
						val += val3;
					}
				}
				val /= (float)(num4 * num4);
				Vector3 val4 = val;
				float magnitude = ((Vector3)(ref val4)).magnitude;
				float num11 = 10000f;
				if (magnitude < 1f)
				{
					num11 = (3f * magnitude - magnitude * magnitude * magnitude) / (1f - magnitude * magnitude);
				}
				float num12 = 1f - (float)(int)pixels[num3].a / 255f;
				pixels[num3].a = (byte)(Mathf.Clamp01(1f - Mathf.Sqrt(num12 * num12 + 1f / num11)) * 255f);
				num3++;
			}
		}
		specMap.SetPixels32(pixels, mipLevel);
	}
}
[AddComponentMenu("Lux/Area Light")]
[ExecuteInEditMode]
[RequireComponent(typeof(Light))]
public class LuxAreaLight : MonoBehaviour
{
	[Header("Area Light Properties")]
	[Range(0f, 40f)]
	public float lightLength = 1f;

	[Range(0.04f, 40f)]
	public float lightRadius = 0.5f;

	[Range(0f, 1f)]
	public float specularIntensity = 1f;

	[Header("Light Overwrites")]
	public Color lightColor = new Color(1f, 1f, 1f, 0f);

	[Range(0f, 8f)]
	public float lightIntensity = 1f;

	private Light lightSource;

	private float range;

	private void Update()
	{
		UpdateAreaLight();
	}

	private void OnValidate()
	{
		UpdateAreaLight();
	}

	private void OnEnable()
	{
		UpdateAreaLight();
	}

	private void OnDisable()
	{
		ResetAreaLight();
	}

	public void UpdateAreaLight()
	{
		//IL_006e: 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_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)lightSource == (Object)null)
		{
			lightSource = ((Component)this).GetComponent<Light>();
		}
		range = lightSource.range;
		if (range < lightLength * 0.75f)
		{
			range = lightLength * 0.75f;
			lightSource.range = range;
		}
		Color val = lightColor;
		val *= lightIntensity;
		float num = lightRadius / 80f;
		float num2 = lightLength / 80f;
		val.a = Mathf.Floor(num * 2047f) * 2048f + Mathf.Floor(num2 * 2047f) + specularIntensity * 0.5f;
		lightSource.intensity = 1f;
		lightSource.color = val;
	}

	private void OnDrawGizmosSelected()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: 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_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		Gizmos.matrix = ((Component)this).transform.localToWorldMatrix;
		Gizmos.color = Color.red;
		if ((double)lightLength == 0.0)
		{
			Gizmos.DrawWireSphere(Vector3.zero, lightRadius);
		}
		else
		{
			Gizmos.DrawWireSphere(Vector3.zero - new Vector3(0f, lightLength * 0.5f, 0f), lightRadius);
			Gizmos.DrawWireSphere(Vector3.zero + new Vector3(0f, lightLength * 0.5f, 0f), lightRadius);
		}
		Gizmos.matrix = Matrix4x4.identity;
	}

	private void ResetAreaLight()
	{
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)lightSource == (Object)null)
		{
			lightSource = ((Component)this).GetComponent<Light>();
		}
		lightSource.color = new Color(lightColor.r, lightColor.g, lightColor.b, 1f);
		lightSource.intensity = lightIntensity;
	}
}
public class ReadOnlyRangeAttribute : PropertyAttribute
{
	public float min;

	public float max;

	public ReadOnlyRangeAttribute(float min, float max)
	{
		this.min = min;
		this.max = max;
	}
}
public class CustomLabelRangeAttribute : PropertyAttribute
{
	public float min;

	public float max;

	public string labeltext;

	public CustomLabelRangeAttribute(float min, float max, string labeltext)
	{
		this.min = min;
		this.max = max;
		this.labeltext = labeltext;
	}
}
[ExecuteInEditMode]
public class LuxDynamicWeather : MonoBehaviour
{
	[Header("Dynamic Weather")]
	[Space(4f)]
	public bool ScriptControlledWeather = true;

	[Space(10f)]
	[Range(0.1f, 4f)]
	public float TimeScale = 1f;

	[Tooltip("Next to 'Rainfall' 'Temperature' is the most important input as it decides whether it rains or snows.'")]
	[Range(-40f, 40f)]
	public float Temperature = 20f;

	[Tooltip("Controls rain and snow intensity according to the given temperature.")]
	[Range(0f, 1f)]
	public float Rainfall = 0f;

	[ReadOnlyRange(0f, 1f)]
	public float RainIntensity = 0f;

	[ReadOnlyRange(0f, 1f)]
	public float SnowIntensity = 0f;

	[Space(10f)]
	[Range(0f, 1f)]
	public float WetnessInfluenceOnAlbedo = 0.85f;

	[Range(0f, 1f)]
	public float WetnessInfluenceOnSmoothness = 0.5f;

	[Range(0f, 1f)]
	public float AccumulationRateWetness = 0.35f;

	[Range(0f, 0.5f)]
	public float EvaporationRateWetness = 0.075f;

	[Space(10f)]
	[Range(0f, 1f)]
	public float AccumulationRateCracks = 0.25f;

	[Range(0f, 1f)]
	public float AccumulationRatePuddles = 0.2f;

	[Range(0f, 0.5f)]
	public float EvaporationRateCracks = 0.2f;

	[Range(0f, 0.5f)]
	public float EvaporationRatePuddles = 0.1f;

	[Space(5f)]
	[Range(0f, 0.5f)]
	public float AccumulationRateSnow = 0.1f;

	[Space(15f)]
	[Range(0f, 1f)]
	public float AccumulatedWetness = 0f;

	[Range(0f, 1f)]
	public float AccumulatedCracks = 0f;

	[Range(0f, 1f)]
	public float AccumulatedPuddles = 0f;

	[ReadOnlyRange(0f, 1f)]
	public float AccumulatedWater = 0f;

	[Space(5f)]
	[Range(0f, 1f)]
	public float AccumulatedSnow = 0f;

	[Space(5f)]
	[Range(0f, 1f)]
	public float WaterToSnow = 0.01f;

	[Space(15f)]
	[Range(0.01f, 1f)]
	public float WaterToSnowTimeScale = 1f;

	public AnimationCurve WaterToSnowCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
	{
		new Keyframe(0f, 0.25f),
		new Keyframe(1f, 1f)
	});

	[ReadOnlyRange(0f, 1f)]
	public float SnowMelt = 0f;

	[Header("Snow")]
	[Space(4f)]
	[ColorUsage(false, true, 0f, 2f, 0.125f, 3f)]
	public Color SnowColor = Color.white;

	public Color SnowSpecularColor = new Color(0.2f, 0.2f, 0.2f, 1f);

	public Color SnowScatterColor;

	[Range(0f, 1f)]
	public float SnowDiffuseScatteringBias = 0f;

	[Range(1f, 10f)]
	public float SnowDiffuseScatteringContraction = 8f;

	[Space(5f)]
	[Tooltip("Mask in (G) Normal in (BA)")]
	public Texture2D SnowMask;

	[Tooltip("Snow and Water Bump in (GA) Snow Smoothness in (B)")]
	public Texture2D SnowAndWaterBump;

	[Range(-100f, 8000f)]
	public float SnowStartHeight = -100f;

	[Range(0f, 1f)]
	public float SnowHeightBlending = 0.01f;

	private float Lux_adjustedSnowAmount;

	[Header("World mapped Snow")]
	[Space(4f)]
	public float SnowTiling = 0.2f;

	public float SnowDetailTiling = 0.5f;

	public float SnowMaskTiling = 0.01f;

	public float SnowMaskDetailTiling = 0.37f;

	public float SnowNormalStregth = 1f;

	public float SnowNormalDetailStrength = 0.3f;

	[Space(10f)]
	public ParticleSystem SnowParticleSystem;

	public int MaxSnowParticlesEmissionRate = 3000;

	[Header("Rain")]
	[Space(4f)]
	public Texture2D RainRipples;

	public float RippleTiling = 4f;

	public float RippleAnimSpeed = 1f;

	[Range(0f, 1f)]
	public float RippleRefraction = 0.5f;

	public int RenderTextureSize = 512;

	public RenderTexture RainRipplesRenderTexture;

	private Material m_material;

	[Space(10f)]
	public ParticleSystem RainParticleSystem;

	public int MaxRainParticlesEmissionRate = 3000;

	private int RainSnowIntensityPID;

	private int WaterFloodLevelPID;

	private int RainRipplesPID;

	private int RippleAnimSpeedPID;

	private int RippleTilingPID;

	private int RippleRefractionPID;

	private int SnowHeightParamsPID;

	private int WaterToSnowPID;

	private int SnowMeltPID;

	private int SnowAmountPID;

	private int SnowColorPID;

	private int SnowSpecColorPID;

	private int SnowScatterColorPID;

	private int SnowScatteringBiasPID;

	private int SnowSnowScatteringContractionPID;

	private int WorldMappedSnowTilingPID;

	private int WorldMappedSnowStrengthPID;

	private int SnowMaskPID;

	private int SnowWaterBumpPID;

	[Header("GI")]
	[Space(4f)]
	[Tooltip("When using dynamic GI you may attach one renderer per GI System in order to make GI being synced automatically to the given amount of snow.")]
	public Renderer[] SnowGIMasterRenderers;

	private void OnEnable()
	{
		SetupRippleRT();
	}

	private void SetupRippleRT()
	{
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Expected O, but got Unknown
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Expected O, but got Unknown
		if ((Object)(object)RainRipplesRenderTexture == (Object)null || (Object)(object)m_material == (Object)null)
		{
			RainRipplesRenderTexture = new RenderTexture(RenderTextureSize, RenderTextureSize, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)1);
			RainRipplesRenderTexture.useMipMap = true;
			((Texture)RainRipplesRenderTexture).wrapMode = (TextureWrapMode)0;
			m_material = new Material(Shader.Find("Hidden/Lux RainRipplesComposite"));
			GetPIDs();
		}
	}

	private void GetPIDs()
	{
		RainSnowIntensityPID = Shader.PropertyToID("_Lux_RainfallRainSnowIntensity");
		WaterFloodLevelPID = Shader.PropertyToID("_Lux_WaterFloodlevel");
		RainRipplesPID = Shader.PropertyToID("_Lux_RainRipples");
		RippleAnimSpeedPID = Shader.PropertyToID("_Lux_RippleAnimSpeed");
		RippleTilingPID = Shader.PropertyToID("_Lux_RippleTiling");
		RippleRefractionPID = Shader.PropertyToID("_Lux_RippleRefraction");
		SnowHeightParamsPID = Shader.PropertyToID("_Lux_SnowHeightParams");
		WaterToSnowPID = Shader.PropertyToID("_Lux_WaterToSnow");
		SnowMeltPID = Shader.PropertyToID("_Lux_SnowMelt");
		SnowAmountPID = Shader.PropertyToID("_Lux_SnowAmount");
		SnowColorPID = Shader.PropertyToID("_Lux_SnowColor");
		SnowSpecColorPID = Shader.PropertyToID("_Lux_SnowSpecColor");
		SnowScatterColorPID = Shader.PropertyToID("_Lux_SnowScatterColor");
		SnowScatteringBiasPID = Shader.PropertyToID("_Lux_SnowScatteringBias");
		SnowSnowScatteringContractionPID = Shader.PropertyToID("_Lux_SnowScatteringContraction");
		WorldMappedSnowTilingPID = Shader.PropertyToID("_Lux_WorldMappedSnowTiling");
		WorldMappedSnowStrengthPID = Shader.PropertyToID("_Lux_WorldMappedSnowStrength");
		SnowMaskPID = Shader.PropertyToID("_Lux_SnowMask");
		SnowWaterBumpPID = Shader.PropertyToID("_Lux_SnowWaterBump");
	}

	private void Start()
	{
	}

	private void Update()
	{
		//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0421: Unknown result type (might be due to invalid IL or missing references)
		//IL_0443: Unknown result type (might be due to invalid IL or missing references)
		//IL_0448: Unknown result type (might be due to invalid IL or missing references)
		//IL_0498: Unknown result type (might be due to invalid IL or missing references)
		//IL_053c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0565: Unknown result type (might be due to invalid IL or missing references)
		//IL_0576: Unknown result type (might be due to invalid IL or missing references)
		//IL_0587: 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_05d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0679: Unknown result type (might be due to invalid IL or missing references)
		//IL_067e: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b3: Unknown result type (might be due to invalid IL or missing references)
		if (ScriptControlledWeather)
		{
			float num = Mathf.Lerp(0f, EvaporationRateWetness, Temperature / 40f);
			float num2 = Mathf.Lerp(0f, EvaporationRateCracks, Temperature / 40f);
			float num3 = Mathf.Lerp(0f, EvaporationRatePuddles, Mathf.Abs(Temperature) / 40f);
			float num4 = Mathf.Abs(Temperature);
			num4 = Mathf.Lerp(0f, 1f, num4 / 40f);
			if (Temperature > 0f)
			{
				WaterToSnow -= num4 * Time.deltaTime * TimeScale * WaterToSnowTimeScale;
				WaterToSnow = Mathf.Clamp01(WaterToSnow);
				float num5 = Mathf.Clamp01((1f - WaterToSnow) * AccumulatedSnow * Time.deltaTime * TimeScale * WaterToSnowTimeScale * 4f);
				float num6 = RainIntensity * Time.deltaTime * TimeScale;
				AccumulatedWetness += num6 * AccumulationRateWetness + num5;
				AccumulatedCracks += num6 * AccumulationRateCracks;
				AccumulatedPuddles += num6 * AccumulationRatePuddles;
				if (Rainfall == 0f)
				{
					AccumulatedWetness -= num * Time.deltaTime * TimeScale;
					AccumulatedCracks -= num2 * Time.deltaTime * TimeScale;
					AccumulatedPuddles -= num3 * Time.deltaTime * TimeScale;
				}
				AccumulatedSnow -= num5;
			}
			else
			{
				WaterToSnow += num4 * Time.deltaTime * TimeScale * WaterToSnowTimeScale;
				WaterToSnow = Mathf.Clamp01(WaterToSnow);
				AccumulatedSnow += SnowIntensity * AccumulationRateSnow * Time.deltaTime * TimeScale + WaterToSnow * Mathf.Clamp01(AccumulatedWater) * Time.deltaTime * TimeScale * WaterToSnowTimeScale;
				AccumulatedWetness -= WaterToSnow * Time.deltaTime * TimeScale * WaterToSnowTimeScale;
				AccumulatedCracks -= WaterToSnow * Time.deltaTime * TimeScale * WaterToSnowTimeScale;
				AccumulatedPuddles -= WaterToSnow * Time.deltaTime * TimeScale * WaterToSnowTimeScale;
			}
			AccumulatedSnow = Mathf.Clamp01(AccumulatedSnow);
			AccumulatedWetness = Mathf.Clamp01(AccumulatedWetness);
			AccumulatedCracks = Mathf.Clamp01(AccumulatedCracks);
			AccumulatedPuddles = Mathf.Clamp01(AccumulatedPuddles);
			AccumulatedWater = Mathf.Max(AccumulatedCracks, AccumulatedPuddles);
			SnowMelt = 1f - WaterToSnow;
			SnowIntensity = Rainfall * WaterToSnow;
			RainIntensity = Rainfall - SnowIntensity;
		}
		else
		{
			SnowIntensity = Rainfall;
			RainIntensity = Rainfall;
		}
		float num7 = WaterToSnowCurve.Evaluate(WaterToSnow);
		WaterToSnow = Mathf.Clamp(WaterToSnow, 0f, 1f);
		Shader.SetGlobalVector(WaterToSnowPID, new Vector4(WaterToSnow, 1f - Mathf.Pow(2f, -10f * WaterToSnow), 0f, 0f));
		Shader.SetGlobalVector(SnowMeltPID, new Vector4(1f - num7, 1f - Mathf.Pow(2f, -10f * (1f - num7)), 0f, 0f));
		Shader.SetGlobalVector(RainSnowIntensityPID, Vector4.op_Implicit(new Vector3(Rainfall, RainIntensity, SnowIntensity)));
		Shader.SetGlobalVector(WaterFloodLevelPID, new Vector4(AccumulatedCracks, AccumulatedPuddles, AccumulatedWetness * WetnessInfluenceOnAlbedo * (1f - WaterToSnow), AccumulatedWetness * WetnessInfluenceOnSmoothness * (1f - WaterToSnow)));
		Shader.SetGlobalTexture(SnowMaskPID, (Texture)(object)SnowMask);
		Shader.SetGlobalTexture(SnowWaterBumpPID, (Texture)(object)SnowAndWaterBump);
		if (Object.op_Implicit((Object)(object)RainRipples))
		{
			Shader.SetGlobalTexture(RainRipplesPID, (Texture)(object)RainRipples);
		}
		Shader.SetGlobalFloat(RippleAnimSpeedPID, RippleAnimSpeed);
		Shader.SetGlobalFloat(RippleTilingPID, RippleTiling);
		Shader.SetGlobalFloat(RippleRefractionPID, RippleRefraction);
		Shader.SetGlobalVector(SnowHeightParamsPID, new Vector4(SnowStartHeight, SnowHeightBlending * 1000f, 0f, 0f));
		Shader.SetGlobalFloat(SnowAmountPID, AccumulatedSnow * WaterToSnow);
		Shader.SetGlobalColor(SnowColorPID, SnowColor);
		Shader.SetGlobalColor(SnowSpecColorPID, SnowSpecularColor);
		Shader.SetGlobalVector(SnowScatterColorPID, Color.op_Implicit(SnowScatterColor));
		Shader.SetGlobalFloat(SnowScatteringBiasPID, SnowDiffuseScatteringBias);
		Shader.SetGlobalFloat(SnowSnowScatteringContractionPID, SnowDiffuseScatteringContraction);
		Shader.SetGlobalVector(WorldMappedSnowTilingPID, new Vector4(SnowTiling, SnowDetailTiling, SnowMaskTiling, SnowMaskDetailTiling));
		Shader.SetGlobalVector(WorldMappedSnowStrengthPID, Vector4.op_Implicit(new Vector2(SnowNormalStregth, SnowNormalDetailStrength)));
		if (SnowGIMasterRenderers != null && SnowGIMasterRenderers.Length > 0)
		{
			for (int i = 0; i < SnowGIMasterRenderers.Length; i++)
			{
				if ((Object)(object)SnowGIMasterRenderers[i] != (Object)null)
				{
					RendererExtensions.UpdateGIMaterials(SnowGIMasterRenderers[i]);
				}
			}
		}
		if ((Object)(object)SnowParticleSystem != (Object)null)
		{
			EmissionModule emission = SnowParticleSystem.emission;
			((EmissionModule)(ref emission)).rateOverTimeMultiplier = (float)MaxSnowParticlesEmissionRate * SnowIntensity;
		}
		if ((Object)(object)RainParticleSystem != (Object)null)
		{
			EmissionModule emission2 = RainParticleSystem.emission;
			((EmissionModule)(ref emission2)).rateOverTimeMultiplier = (float)MaxRainParticlesEmissionRate * RainIntensity;
		}
		if (Object.op_Implicit((Object)(object)RainRipples))
		{
			GL.sRGBWrite = true;
			m_material.SetFloat(RainSnowIntensityPID, RainIntensity);
			m_material.SetFloat(RippleAnimSpeedPID, RippleAnimSpeed);
			Graphics.Blit((Texture)(object)RainRipples, RainRipplesRenderTexture, m_material);
			RainRipplesRenderTexture.SetGlobalShaderProperty("_Lux_RainRipplesRT");
		}
	}
}
[ExecuteInEditMode]
public class LuxSetup : MonoBehaviour
{
	[Header("Detail Distance")]
	[Space(2f)]
	[Range(10f, 100f)]
	public float DetailDistance = 50f;

	[Range(1f, 25f)]
	public float DetailFadeRange = 15f;

	[Header("Area Lights")]
	[Space(2f)]
	public bool enableAreaLights = false;

	[Header("Translucent Lighting")]
	[Space(2f)]
	[Tooltip("Distort translucent lighting by surface normals.")]
	[CustomLabelRange(0f, 1f, "Distortion")]
	public float BumpDistortion_T = 0.1f;

	[CustomLabelRange(1f, 8f, "Scale")]
	public float Scale_T = 4f;

	[CustomLabelRange(0f, 1f, "Shadow Strength")]
	public float ShadowStrength_T = 0.7f;

	[CustomLabelRange(0f, 1f, "Shadow Strength NdotL")]
	public float ShadowStrength_NdotL = 0.7f;

	[Header("Skin Lighting")]
	[Space(2f)]
	public Texture BRDFTexture;

	[Space(5f)]
	public Color SubsurfaceColor = new Color(1f, 0.4f, 0.25f, 1f);

	[CustomLabelRange(1f, 8f, "Power")]
	public float Power_S = 2f;

	[CustomLabelRange(0f, 1f, "Distortion")]
	public float Distortion_S = 0.1f;

	[CustomLabelRange(0f, 8f, "Scale")]
	public float Scale_S = 2f;

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

	[Range(0f, 50f)]
	public float SkinLightingDistance = 20f;

	[Range(0f, 20f)]
	public float SkinLightingFadeRange = 8f;

	[Header("Anisotropic Lighting")]
	[Space(2f)]
	[Tooltip("Distort translucent lighting by surface normals.")]
	[CustomLabelRange(1f, 8f, "Power")]
	public float Power_A = 2f;

	[CustomLabelRange(0f, 1f, "Distortion")]
	public float BumpDistortion_A = 0.1f;

	[CustomLabelRange(1f, 8f, "Scale")]
	public float Scale_A = 4f;

	[CustomLabelRange(0f, 1f, "Shadow Strength")]
	public float ShadowStrength_A = 0.7f;

	private void UpdateLuxGlobalShaderVariables()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: 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_0169: Unknown result type (might be due to invalid IL or missing references)
		Shader.SetGlobalVector("_Lux_DetailDistanceFade", Vector4.op_Implicit(new Vector2(DetailDistance, DetailFadeRange)));
		if (enableAreaLights)
		{
			Shader.EnableKeyword("LUX_AREALIGHTS");
		}
		else
		{
			Shader.DisableKeyword("LUX_AREALIGHTS");
		}
		if ((Object)(object)BRDFTexture == (Object)null)
		{
			ref Texture bRDFTexture = ref BRDFTexture;
			Object obj = Resources.Load("DiffuseScatteringOnRing");
			bRDFTexture = (Texture)(object)((obj is Texture) ? obj : null);
		}
		Shader.SetGlobalTexture("_BRDFTex", BRDFTexture);
		Shader.SetGlobalColor("_SubColor", ((Color)(ref SubsurfaceColor)).linear);
		Shader.SetGlobalVector("_Lux_Skin_DeepSubsurface", new Vector4(Power_S, Distortion_S, Scale_S, 0f));
		if (EnableSkinLightingFade)
		{
			Shader.EnableKeyword("LUX_LIGHTINGFADE");
		}
		else
		{
			Shader.DisableKeyword("LUX_LIGHTINGFADE");
		}
		Shader.SetGlobalVector("_Lux_Skin_DistanceRange", Vector4.op_Implicit(new Vector2(SkinLightingDistance, SkinLightingFadeRange)));
		Shader.SetGlobalVector("_Lux_Tanslucent_Settings", new Vector4(BumpDistortion_T, 0f, 1f - ShadowStrength_T, Scale_T));
		Shader.SetGlobalFloat("_Lux_Translucent_NdotL_Shadowstrength", 1f - ShadowStrength_NdotL);
		Shader.SetGlobalVector("_Lux_Anisotropic_Settings", new Vector4(BumpDistortion_A, Power_A, 1f - ShadowStrength_A, Scale_A));
	}

	private void Start()
	{
		UpdateLuxGlobalShaderVariables();
	}

	private void OnValidate()
	{
		UpdateLuxGlobalShaderVariables();
	}

	private void Update()
	{
		Shader.SetGlobalFloat("_Lux_ShadowDistance", QualitySettings.shadowDistance);
	}
}
namespace SoulCannibal.SR_dod_bleakhill2;

[BepInPlugin("SoulCannibal.SR_dod_bleakhill2", "SR_dod_bleakhill2", "0.9.5")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("nrgill28.Atlas", "1.0.1")]
public class SR_dod_bleakhill2Plugin : BaseUnityPlugin
{
	private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

	internal static ManualLogSource Logger;

	private void Awake()
	{
		Logger = ((BaseUnityPlugin)this).Logger;
		LoadAssets();
	}

	private void LoadAssets()
	{
		Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "SoulCannibal.SR_dod_bleakhill2");
		AtlasPlugin.RegisterScene(Path.Combine(BasePath, "bleakhill2"));
	}
}