Publish verified live restoration source snapshot and known limits

This commit is contained in:
0xcjy
2026-10-01 19:42:22 +08:00
parent 0dd0d3bdaa
commit d70a65c7ce
896 changed files with 105420 additions and 12745 deletions
@@ -1,125 +1,100 @@
using System.Collections;
using System.Collections.Generic;
using Gallop.RenderPipeline;
using UnityEngine;
namespace Gallop.Live
{
[DisallowMultipleComponent]
[RequireComponent(typeof(Camera), typeof(MultiCameraComposite))]
public class MultiCamera : MonoBehaviour
{
private RenderTexture _framebufferCompositeTexture; // 0x18
private RenderTexture _compositeTexture; // 0x20
[SerializeField] // RVA: 0xEBE0 Offset: 0xEBE0 VA: 0x7FF85CCBEBE0
private Material[] _compositeMaterial; // 0x28
public Vector2 MaskOffset;
public float MaskRoll;
//From DereViewer
private const float NearClipOffset = 0.01f;
private Camera _camera;
private RenderTexture _captureTexture;
private RenderTexture _originalTarget;
private bool _ownsTarget;
private int _maskIndex = -1;
private Transform _myTransform;
private Transform _maskTransform;
private Renderer[] _maskRenderer;
public Vector3 maskPosition { get; set; }
public Quaternion maskRotation { get; set; }
public Vector3 maskScale { get; set; }
public int maskIndex => _maskIndex;
public MultiCameraComposite Composite { get; private set; }
public MultiCameraFinalComposite FinalComposite { get; private set; }
public RenderTexture CaptureTexture => _captureTexture;
public int TimelineIndex { get; private set; } = -1;
public PostImageEffectFeature.Parameter PostEffectParameter { get; } = new PostImageEffectFeature.Parameter();
public Camera GetCamera()
{
if (_camera == null) _camera = GetComponent<Camera>();
return _camera;
}
public Transform GetMaskTransform()
public void Initialize(MultiCameraFinalComposite owner, int timelineIndex)
{
return _maskTransform;
FinalComposite = owner;
TimelineIndex = timelineIndex;
Composite = GetComponent<MultiCameraComposite>();
Composite.Initialize(owner, timelineIndex);
PostEffectParameter.TargetCamera = GetCamera();
}
public void DetachMask()
// Native MakeRenderTexture (0x1a7c710) uses virtual-resolution ARGB32,
// no MSAA/mips. URP scene captures additionally need their own depth attachment.
public void MakeRenderTexture(int width, int height)
{
_maskTransform = null;
_maskRenderer = null;
_maskIndex = -1;
}
public void Initialize()
{
if (!(_camera != null))
Camera camera = GetCamera();
if (_captureTexture == null || _captureTexture.width != width ||
_captureTexture.height != height || !_captureTexture.IsCreated())
{
_myTransform = base.transform;
_camera = base.gameObject.AddComponent<Camera>();
_camera.enabled = false;
_camera.depth = -3;
ResetRenderTexture();
if (_captureTexture != null)
{
_captureTexture.Release();
Destroy(_captureTexture);
}
_captureTexture = new RenderTexture(width, height, 24, RenderTextureFormat.ARGB32)
{
name = "MultiCameraCapture_" + TimelineIndex,
filterMode = FilterMode.Bilinear,
wrapMode = TextureWrapMode.Clamp,
antiAliasing = 1,
useMipMap = false,
autoGenerateMips = false,
hideFlags = HideFlags.DontSave
};
_captureTexture.Create();
}
}
public void Setup(int cameraDepth, RenderTexture colorBuffer, RenderTexture depthBuffer)
{
if (!(_camera == null))
if (!_ownsTarget)
{
_camera.depth = cameraDepth;
//_camera.cullingMask = StageUtil.Background3dAllLayers() | StageUtil.CharaAllLayers();
_camera.clearFlags = CameraClearFlags.Depth;
_camera.allowHDR = false;
_camera.SetTargetBuffers(colorBuffer.colorBuffer, depthBuffer.depthBuffer);
_originalTarget = camera.targetTexture;
_ownsTarget = true;
}
camera.targetTexture = _captureTexture;
}
private void Release()
public void ResetRenderTexture()
{
DetachMask();
_myTransform = null;
_camera = null;
Camera camera = GetCamera();
if (_ownsTarget && camera.targetTexture == _captureTexture)
camera.targetTexture = _originalTarget;
_originalTarget = null;
_ownsTarget = false;
}
public void DisableCameraTimeline()
{
if (Composite != null) Composite.FadeValue = 0f;
gameObject.SetActive(false);
}
private void OnDisable()
{
ResetRenderTexture();
}
private void OnDestroy()
{
Release();
}
private void UpdateTransform()
{
Vector3 forward = _myTransform.forward;
Vector3 vector = _myTransform.localRotation * maskPosition + forward * (_camera.nearClipPlane + 0.01f);
_maskTransform.localPosition = _myTransform.localPosition + vector;
_maskTransform.localRotation = Quaternion.LookRotation(forward) * maskRotation;
_maskTransform.localScale = maskScale;
}
private void OnPreCull()
{
if (_maskIndex != -1)
ResetRenderTexture();
if (_captureTexture != null)
{
UpdateTransform();
Renderer[] maskRenderer = _maskRenderer;
for (int i = 0; i < maskRenderer.Length; i++)
{
maskRenderer[i].enabled = true;
}
}
}
private void OnPostRender()
{
if (_maskIndex != -1)
{
Renderer[] maskRenderer = _maskRenderer;
for (int i = 0; i < maskRenderer.Length; i++)
{
maskRenderer[i].enabled = false;
}
_captureTexture.Release();
Destroy(_captureTexture);
_captureTexture = null;
}
}
}