using UnityEngine.Scripting.APIUpdating;
namespace UnityEngine.Rendering.RenderGraphModule
{
///
/// Helper class allowing access to default resources (black or white texture, etc.) during render passes.
///
[MovedFrom(true, "UnityEngine.Experimental.Rendering.RenderGraphModule", "UnityEngine.Rendering.RenderGraphModule")]
public class RenderGraphDefaultResources
{
// We need to keep around a RTHandle version of default regular 2D textures since RenderGraph API is all RTHandle.
RTHandle m_BlackTexture2D;
RTHandle m_WhiteTexture2D;
RTHandle m_ShadowTexture2D;
/// Default black 2D texture.
public TextureHandle blackTexture { get; private set; }
/// Default white 2D texture.
public TextureHandle whiteTexture { get; private set; }
/// Default clear color XR 2D texture.
public TextureHandle clearTextureXR { get; private set; }
/// Default magenta XR 2D texture.
public TextureHandle magentaTextureXR { get; private set; }
/// Default black XR 2D texture.
public TextureHandle blackTextureXR { get; private set; }
/// Default black XR 2D Array texture.
public TextureHandle blackTextureArrayXR { get; private set; }
/// Default black (UInt) XR 2D texture.
public TextureHandle blackUIntTextureXR { get; private set; }
/// Default black XR 3D texture.
public TextureHandle blackTexture3DXR { get; private set; }
/// Default white XR 2D texture.
public TextureHandle whiteTextureXR { get; private set; }
/// Default 1x1 shadow texture.
public TextureHandle defaultShadowTexture { get; private set; }
internal RenderGraphDefaultResources()
{
m_BlackTexture2D = RTHandles.Alloc(Texture2D.blackTexture);
m_WhiteTexture2D = RTHandles.Alloc(Texture2D.whiteTexture);
m_ShadowTexture2D = RTHandles.Alloc(1, 1, Experimental.Rendering.GraphicsFormat.D32_SFloat, isShadowMap: true, name: "DefaultShadowTexture");
}
internal void Cleanup()
{
m_BlackTexture2D.Release();
m_WhiteTexture2D.Release();
m_ShadowTexture2D.Release();
}
internal void InitializeForRendering(RenderGraph renderGraph)
{
blackTexture = renderGraph.ImportTexture(m_BlackTexture2D, true);
whiteTexture = renderGraph.ImportTexture(m_WhiteTexture2D, true);
defaultShadowTexture = renderGraph.ImportTexture(m_ShadowTexture2D, true);
clearTextureXR = renderGraph.ImportTexture(TextureXR.GetClearTexture(), true);
magentaTextureXR = renderGraph.ImportTexture(TextureXR.GetMagentaTexture(), true);
blackTextureXR = renderGraph.ImportTexture(TextureXR.GetBlackTexture(), true);
blackTextureArrayXR = renderGraph.ImportTexture(TextureXR.GetBlackTextureArray(), true);
blackUIntTextureXR = renderGraph.ImportTexture(TextureXR.GetBlackUIntTexture(), true);
blackTexture3DXR = renderGraph.ImportTexture(TextureXR.GetBlackTexture3D(), true);
whiteTextureXR = renderGraph.ImportTexture(TextureXR.GetWhiteTexture(), true);
}
}
}