First Commit

This commit is contained in:
2025-05-18 22:39:39 +03:00
commit 042ede7228
440 changed files with 103153 additions and 0 deletions

View File

@@ -0,0 +1,99 @@
#if UNITY_EDITOR
using UnityEditor;
#endif
using Golems.RenderFeatures;
using UnityEngine;
using UnityEngine.Rendering.Universal;
namespace Golems
{
public class AlbertGhostMemoryComposite : SourceToDestinationBlitRenderFeature
{
[Header("Compose things")]
[SerializeField] private bool m_IsEnabled = true;
[SerializeField] private AlbertGhostMemoryCompositeSettings m_FallbackSettings;
private AlbertGhostMemoryCompositePass m_Pass;
private AlbertGhostMemoryCompositeSettings m_SettingsLoader;
[SerializeField]
private float m_TimeBeforeSettingsFailureLog = 10.0f;
private float m_CreationTime;
private bool m_LoggedSettingsFailure;
public override void Create()
{
m_LoggedSettingsFailure = false;
m_CreationTime = Time.unscaledTime;
bool logFallback = true;
#if UNITY_EDITOR
if (!EditorApplication.isPlayingOrWillChangePlaymode)
{
//
// Cannot use Addressables in editor outside of playmode so use fallback
//
logFallback = false;
}
#endif
m_SettingsLoader = m_FallbackSettings;
DoCreate();
m_Pass = new AlbertGhostMemoryCompositePass(m_SettingsLoader);
}
private void DebugSetEnabledState(bool state)
{
m_IsEnabled = state;
}
private bool DebugGetEnabledState()
{
return m_IsEnabled;
}
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
{
if (m_Pass == null)
{
return;
}
//
// If the source and destination are not the same then have to at least perform a copy.
//
var doRender = !IsSourceAndDestinationSame();
if (!doRender)
{
//
// Source and destination are different so
// see if there is something to render.
//
if (m_IsEnabled)
{
doRender = renderingData.cameraData.camera.isActiveAndEnabled &&
GhostObjectCollection.Instance.NumberOfObjectsRendered > 0 &&
GhostObjectCollection.Instance.HasSomethingToRender();
}
}
if (!doRender)
{
return;
}
m_Pass.Setup(m_IsEnabled, m_WhenToInsert, renderer.cameraColorTarget,
m_SourceTextureSourceType, m_SourceNamedTemporaryNameHash,
m_DestinationTextureSourceType, m_DestinationNamedTemporaryNameHash,
m_TempCopyNamedTemporaryNameHash);
renderer.EnqueuePass(m_Pass);
}
}
}