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

296 lines
8.0 KiB
C#

using System;
using UnityEngine;
// Token: 0x02000073 RID: 115
[ExecuteInEditMode]
public class CaptureBackgrounds : MonoBehaviour
{
// Token: 0x06000B85 RID: 2949 RVA: 0x000DF670 File Offset: 0x000DD870
public void Setup()
{
if (this.normalsTexture)
{
this.normalsTexture.Release();
}
if (this.albedoTexture)
{
this.albedoTexture.Release();
}
if (this.smoothnessTexture)
{
this.smoothnessTexture.Release();
}
if (this.depthTexture)
{
this.depthTexture.Release();
}
if (this.pointLightTexture)
{
this.pointLightTexture.Release();
}
if (this.albedoTempTexture)
{
this.albedoTempTexture.Release();
}
if (this.directionalLightTexture)
{
this.directionalLightTexture.Release();
}
if (this.specularTexture)
{
this.specularTexture.Release();
}
if (this.specShadowsTexture)
{
this.specShadowsTexture.Release();
}
this.depthTexture = new RenderTexture(this.depthWidth, this.depthHeight, 24, RenderTextureFormat.ARGBFloat);
this.normalsTexture = new RenderTexture(this.normalWidth, this.normalHeight, 24, RenderTextureFormat.ARGBFloat);
this.albedoTexture = new RenderTexture(this.albedoWidth, this.albedoHeight, 24, RenderTextureFormat.ARGBFloat);
this.smoothnessTexture = new RenderTexture(this.albedoWidth, this.albedoHeight, 24, RenderTextureFormat.ARGBFloat);
this.pointLightTexture = new RenderTexture(this.depthWidth, this.depthHeight, 24, RenderTextureFormat.ARGBHalf);
this.directionalLightTexture = new RenderTexture(this.shadowWidth, this.shadowHeight, 24, RenderTextureFormat.ARGBFloat);
this.albedoTempTexture = new RenderTexture(this.albedoWidth, this.albedoHeight, 24, RenderTextureFormat.ARGBFloat);
this.specularTexture = new RenderTexture(this.shadowWidth, this.shadowHeight, 24, RenderTextureFormat.ARGBFloat);
this.specShadowsTexture = new RenderTexture(this.shadowWidth, this.shadowHeight, 24, RenderTextureFormat.ARGBFloat);
}
// Token: 0x06000B86 RID: 2950 RVA: 0x000DF848 File Offset: 0x000DDA48
private void OnDisable()
{
if (this.normalsTexture)
{
this.normalsTexture.Release();
}
if (this.albedoTexture)
{
this.albedoTexture.Release();
}
if (this.smoothnessTexture)
{
this.smoothnessTexture.Release();
}
if (this.depthTexture)
{
this.depthTexture.Release();
}
if (this.pointLightTexture)
{
this.pointLightTexture.Release();
}
if (this.albedoTempTexture)
{
this.albedoTempTexture.Release();
}
if (this.directionalLightTexture)
{
this.directionalLightTexture.Release();
}
if (this.specularTexture)
{
this.specularTexture.Release();
}
if (this.specShadowsTexture)
{
this.specShadowsTexture.Release();
}
}
// Token: 0x06000B87 RID: 2951 RVA: 0x000DF930 File Offset: 0x000DDB30
private void Update()
{
if (!this.cam)
{
this.cam = base.gameObject.GetComponent<Camera>();
}
if (!this.normalsTexture)
{
this.Setup();
}
if (!this.cam)
{
return;
}
if (this.albedo || this.directionalShadows)
{
this.cam.enabled = true;
}
else
{
this.cam.enabled = false;
}
if (this.normalsTexture.width != this.normalWidth || this.normalsTexture.height != this.normalHeight || this.albedoTexture.width != this.albedoWidth || this.albedoTexture.height != this.albedoHeight || this.depthTexture.height != this.depthHeight || this.pointLightTexture.height != this.depthHeight || this.directionalLightTexture.height != this.shadowHeight)
{
this.Setup();
}
if (this.directionalShadows)
{
if (!this.directionalLightShader)
{
this.directionalLightShader = Shader.Find("Hidden/ViewDirectionalShadows");
}
Shader.SetGlobalFloat("passNumber", 1f);
this.cam.targetTexture = this.directionalLightTexture;
this.cam.RenderWithShader(this.directionalLightShader, "RenderType");
this.cam.targetTexture = null;
Shader.SetGlobalFloat("passNumber", 0f);
this.cam.targetTexture = this.specularTexture;
this.cam.RenderWithShader(this.directionalLightShader, "RenderType");
this.cam.targetTexture = null;
}
if (this.normalsTexture && this.normals)
{
if (!this.normalsShader)
{
this.normalsShader = Shader.Find("Hidden/ViewNormals");
}
this.cam.targetTexture = this.normalsTexture;
this.cam.RenderWithShader(this.normalsShader, "RenderType");
this.cam.targetTexture = null;
Shader.SetGlobalTexture("_GlobalNormalsTex", this.normalsTexture);
}
if (this.depthTexture && this.depth)
{
if (!this.depthShader)
{
this.depthShader = Shader.Find("Hidden/ViewDepthOrtho");
}
this.cam.targetTexture = this.depthTexture;
this.cam.RenderWithShader(this.depthShader, "RenderType");
this.cam.targetTexture = null;
Shader.SetGlobalTexture("_GlobalDepthTex", this.depthTexture);
}
if (this.smoothnessTexture && this.albedo)
{
if (!this.smoothnessShader)
{
this.smoothnessShader = Shader.Find("Hidden/ViewSmoothness");
}
this.cam.targetTexture = this.smoothnessTexture;
this.cam.RenderWithShader(this.smoothnessShader, "RenderType");
this.cam.targetTexture = null;
this.doAlbedo = true;
this.cam.targetTexture = this.albedoTempTexture;
this.cam.Render();
this.cam.targetTexture = null;
this.doAlbedo = false;
}
}
// Token: 0x06000B88 RID: 2952 RVA: 0x000DFC68 File Offset: 0x000DDE68
private void OnRenderImage(RenderTexture src, RenderTexture dest)
{
if (this.albedoTexture && this.doAlbedo)
{
if (!this.albedoMaterial)
{
this.albedoMaterial = new Material(Shader.Find("Hidden/CombineCaptures"));
}
this.albedoMaterial.SetTexture("_SmoothnessTex", this.smoothnessTexture);
this.albedoMaterial.SetTexture("_AlbedoTex", this.albedoTempTexture);
Graphics.Blit(src, this.albedoTexture, this.albedoMaterial, 0);
}
if (this.specularTexture && this.directionalShadows)
{
if (!this.albedoMaterial)
{
this.albedoMaterial = new Material(Shader.Find("Hidden/CombineCaptures"));
}
this.albedoMaterial.SetTexture("_SpecTex", this.specularTexture);
this.albedoMaterial.SetTexture("_LightTex", this.directionalLightTexture);
Graphics.Blit(src, this.specShadowsTexture, this.albedoMaterial, 1);
}
Graphics.Blit(src, dest);
}
// Token: 0x0400117F RID: 4479
public bool normals;
// Token: 0x04001180 RID: 4480
public bool albedo = true;
// Token: 0x04001181 RID: 4481
public bool depth;
// Token: 0x04001182 RID: 4482
public bool directionalShadows;
// Token: 0x04001183 RID: 4483
private Camera cam;
// Token: 0x04001184 RID: 4484
public RenderTexture normalsTexture;
// Token: 0x04001185 RID: 4485
public RenderTexture albedoTexture;
// Token: 0x04001186 RID: 4486
public RenderTexture smoothnessTexture;
// Token: 0x04001187 RID: 4487
public RenderTexture pointLightTexture;
// Token: 0x04001188 RID: 4488
public RenderTexture directionalLightTexture;
// Token: 0x04001189 RID: 4489
public RenderTexture specularTexture;
// Token: 0x0400118A RID: 4490
public RenderTexture albedoTempTexture;
// Token: 0x0400118B RID: 4491
public RenderTexture depthTexture;
// Token: 0x0400118C RID: 4492
public RenderTexture specShadowsTexture;
// Token: 0x0400118D RID: 4493
public Shader normalsShader;
// Token: 0x0400118E RID: 4494
public Shader smoothnessShader;
// Token: 0x0400118F RID: 4495
public Shader depthShader;
// Token: 0x04001190 RID: 4496
public Shader pointBakeShader;
// Token: 0x04001191 RID: 4497
public Shader directionalLightShader;
// Token: 0x04001192 RID: 4498
private Material albedoMaterial;
// Token: 0x04001193 RID: 4499
public int depthWidth = 2048;
// Token: 0x04001194 RID: 4500
public int depthHeight = 2048;
// Token: 0x04001195 RID: 4501
public int albedoWidth = 2048;
// Token: 0x04001196 RID: 4502
public int albedoHeight = 2048;
// Token: 0x04001197 RID: 4503
public int normalWidth = 2048;
// Token: 0x04001198 RID: 4504
public int normalHeight = 2048;
// Token: 0x04001199 RID: 4505
public int shadowWidth = 2048;
// Token: 0x0400119A RID: 4506
public int shadowHeight = 2048;
// Token: 0x0400119B RID: 4507
private bool doAlbedo;
// Token: 0x0400119C RID: 4508
public Transform lightTransform;
}