Files
BepInEx/Projects/BanquetForFools/Source/Assembly-CSharp/CopyShadows.cs
2025-05-21 20:40:04 +02:00

110 lines
3.1 KiB
C#

using System;
using UnityEngine;
using UnityEngine.Rendering;
// Token: 0x02000074 RID: 116
[ExecuteInEditMode]
[RequireComponent(typeof(Light))]
public class CopyShadows : MonoBehaviour
{
// Token: 0x06000B8A RID: 2954 RVA: 0x000DFDDA File Offset: 0x000DDFDA
private void OnEnable()
{
this.lightComponent = base.GetComponent<Light>();
this.SetupCommandBuffer();
}
// Token: 0x06000B8B RID: 2955 RVA: 0x000DFDEE File Offset: 0x000DDFEE
private void OnDisable()
{
this.lightComponent.RemoveCommandBuffer(LightEvent.AfterShadowMap, this.commandBuffer);
this.lightComponent.RemoveCommandBuffer(LightEvent.AfterScreenspaceMask, this.commandBuffer2);
this.ReleaseCommandBuffer();
}
// Token: 0x06000B8C RID: 2956 RVA: 0x000DFE1C File Offset: 0x000DE01C
private void Update()
{
if (this.tex == null || this.w != (float)Screen.width || this.h != (float)Screen.height)
{
if (this.tex != null)
{
this.tex.Release();
}
this.w = (float)Screen.width;
this.h = (float)Screen.height;
this.tex = new RenderTexture(Screen.width, Screen.height, 24, RenderTextureFormat.ARGB32);
this.reset = true;
}
if (this.reset)
{
this.OnDisable();
this.OnEnable();
this.reset = false;
}
float num = 0f;
if (Links.x && Links.x.diorama && Links.x.cameraEffects.indoors)
{
num = 1f;
}
Shader.SetGlobalFloat("_UsePointLight", num);
}
// Token: 0x06000B8D RID: 2957 RVA: 0x000DFF04 File Offset: 0x000DE104
private void SetupCommandBuffer()
{
this.commandBuffer = new CommandBuffer();
RenderTargetIdentifier renderTargetIdentifier = BuiltinRenderTextureType.CurrentActive;
this.commandBuffer.SetGlobalTexture(this.textureSemanticName, renderTargetIdentifier);
this.lightComponent.AddCommandBuffer(LightEvent.AfterShadowMap, this.commandBuffer);
this.commandBuffer2 = new CommandBuffer();
RenderTargetIdentifier renderTargetIdentifier2 = BuiltinRenderTextureType.CurrentActive;
this.commandBuffer2.Blit(renderTargetIdentifier2, this.tex, this.material);
this.commandBuffer2.SetGlobalTexture(this.textureSemanticName2, this.tex);
this.lightComponent.AddCommandBuffer(LightEvent.AfterScreenspaceMask, this.commandBuffer2);
}
// Token: 0x06000B8E RID: 2958 RVA: 0x000DFFA4 File Offset: 0x000DE1A4
private void ReleaseCommandBuffer()
{
this.commandBuffer2.Clear();
this.commandBuffer.Clear();
}
// Token: 0x0400119D RID: 4509
public string textureSemanticName = "_EnvironmentShadows";
// Token: 0x0400119E RID: 4510
public string textureSemanticName2 = "_EnvironmentShadowsScreenSpace";
// Token: 0x0400119F RID: 4511
public bool reset;
// Token: 0x040011A0 RID: 4512
private CommandBuffer commandBuffer;
// Token: 0x040011A1 RID: 4513
private CommandBuffer commandBuffer2;
// Token: 0x040011A2 RID: 4514
private Light lightComponent;
// Token: 0x040011A3 RID: 4515
public RenderTexture tex;
// Token: 0x040011A4 RID: 4516
public RenderTexture pointLightTexture;
// Token: 0x040011A5 RID: 4517
public Material material;
// Token: 0x040011A6 RID: 4518
private float w;
// Token: 0x040011A7 RID: 4519
private float h;
// Token: 0x040011A8 RID: 4520
public Transform pointLight;
}