using System.Collections.Generic;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering.RenderGraphModule;
using RendererList = UnityEngine.Rendering.RendererList;
using RendererListDesc = UnityEngine.Rendering.RendererUtils.RendererListDesc;
namespace UnityEngine.Rendering.HighDefinition
{
///
/// Enum that defines the sets of scale which Compute Thickness.
///
public enum ComputeThicknessResolution
{
///
/// The Compute Thickness will be rendered on Full resolution.
///
Full,
///
/// The Compute Thickness will be rendered on Half resolution.
///
Half,
///
/// The Compute Thickness will be rendered on Quarter resolution.
///
Quarter
}
///
/// Class handling the generation of fullscreen thickness
///
public sealed class HDComputeThickness
{
private static HDComputeThickness m_Instance = null;
private TextureHandle m_ThicknessArrayRT;
private GraphicsBuffer m_ReindexMapCB;
private uint m_UsedLayersCountCurrentFrame;
///
/// Max RT of Thickness we can computed in a single frame
///
// Should be paired with: COMPUTE_THICKNESS_MAX_LAYER_COUNT in
// 'Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl'
public static uint computeThicknessMaxLayer = 32; // bitscount(LayerMask)
///
/// Current unique instance
///
public static HDComputeThickness Instance
{
get
{
if (m_Instance == null)
{
m_Instance = new HDComputeThickness();
}
return m_Instance;
}
}
private HDComputeThickness()
{
}
///
/// TextureArray of thicknesses computed.
///
/// TextureArray of thicknesses computed.
public void SetTextureArray(TextureHandle rt)
{
m_ThicknessArrayRT = rt;
}
///
/// Return a TextureArrayHandle of thicknesses computed, the slices count are the layer needed.
///
/// TextureArray of thicknesses computed.
public TextureHandle GetThicknessTextureArray()
{
return m_ThicknessArrayRT;
}
///
/// Set a ComputeBuffer To reindex from LayerIndex to SliceIndex of the TextureArray of Thicknesses.
///
/// The ComputeBuffer (StructuredArray<uint>[computeThicknessMaxLayer]
public void SetReindexMap(GraphicsBuffer cb)
{
m_ReindexMapCB = cb;
}
///
/// Get a GraphicsBuffer To reindex from LayerIndex to SliceIndex of the TextureArray of Thicknesses.
///
/// The GraphicsBuffer (StructuredArray<uint>[computeThicknessMaxLayer]
public GraphicsBuffer GetReindexMap()
{
return m_ReindexMapCB;
}
}
}