100 lines
2.8 KiB
C#
100 lines
2.8 KiB
C#
using System;
|
|
|
|
namespace XCEngine
|
|
{
|
|
public abstract class ScriptableRendererData : Object
|
|
{
|
|
private ScriptableRendererFeature[] m_rendererFeatures;
|
|
|
|
protected ScriptableRendererData()
|
|
{
|
|
}
|
|
|
|
internal ScriptableRenderer CreateRendererInstance()
|
|
{
|
|
return CreateRenderer();
|
|
}
|
|
|
|
internal ScriptableRendererFeature[] CreateRendererFeaturesInstance()
|
|
{
|
|
return GetRendererFeatures();
|
|
}
|
|
|
|
internal void ConfigureCameraRenderRequestInstance(
|
|
ScriptableRenderPipelineCameraRequestContext context)
|
|
{
|
|
ConfigureCameraRenderRequest(context);
|
|
|
|
ScriptableRendererFeature[] rendererFeatures =
|
|
GetRendererFeatures();
|
|
for (int i = 0; i < rendererFeatures.Length; ++i)
|
|
{
|
|
ScriptableRendererFeature rendererFeature =
|
|
rendererFeatures[i];
|
|
if (rendererFeature == null ||
|
|
!rendererFeature.isActive)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
rendererFeature.ConfigureCameraRenderRequest(
|
|
context);
|
|
}
|
|
}
|
|
|
|
internal void ConfigureCameraFramePlanInstance(
|
|
ScriptableRenderPipelinePlanningContext context)
|
|
{
|
|
ConfigureCameraFramePlan(context);
|
|
|
|
ScriptableRendererFeature[] rendererFeatures =
|
|
GetRendererFeatures();
|
|
for (int i = 0; i < rendererFeatures.Length; ++i)
|
|
{
|
|
ScriptableRendererFeature rendererFeature =
|
|
rendererFeatures[i];
|
|
if (rendererFeature == null ||
|
|
!rendererFeature.isActive)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
rendererFeature.ConfigureCameraFramePlan(
|
|
context);
|
|
}
|
|
}
|
|
|
|
protected virtual ScriptableRenderer CreateRenderer()
|
|
{
|
|
return null;
|
|
}
|
|
|
|
protected virtual void ConfigureCameraRenderRequest(
|
|
ScriptableRenderPipelineCameraRequestContext context)
|
|
{
|
|
}
|
|
|
|
protected virtual void ConfigureCameraFramePlan(
|
|
ScriptableRenderPipelinePlanningContext context)
|
|
{
|
|
}
|
|
|
|
protected virtual ScriptableRendererFeature[] CreateRendererFeatures()
|
|
{
|
|
return Array.Empty<ScriptableRendererFeature>();
|
|
}
|
|
|
|
private ScriptableRendererFeature[] GetRendererFeatures()
|
|
{
|
|
if (m_rendererFeatures == null)
|
|
{
|
|
m_rendererFeatures =
|
|
CreateRendererFeatures() ??
|
|
Array.Empty<ScriptableRendererFeature>();
|
|
}
|
|
|
|
return m_rendererFeatures;
|
|
}
|
|
}
|
|
}
|