55 lines
1.7 KiB
C#
Raw Normal View History

using System;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
namespace X.Rendering.Feature
{
public class HziCullingFeature : ScriptableRendererFeature
{
[Serializable]
public class Settings
{
//TODO: 通过使用上一帧的摄像机位置包括矩阵和上一帧的深度图做剔除储存已经被剔除的物体和未被剔除的物体然后绘制未被剔除的物体到GBuffer包含深度图
//再二次生成HiZ DepthTexture并对已经被剔除的物体使用一遍新的深度和当前摄像机的位置做一次剔除判断
public bool UseTowCullPass;
}
[SerializeField]
private Settings settings;
private CullPass cullPass;
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
{
if (renderingData.cameraData.cameraType == CameraType.Game)
{
renderer.EnqueuePass(cullPass);
}
}
public override void Create()
{
cullPass = new(settings);
}
internal class CullPass : ScriptableRenderPass
{
private Settings settings;
private ProfilingSampler profiler;
public CullPass(Settings settings)
{
profiler = new("Hi-Z Culling");
this.settings = settings;
}
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
{
var cmd = renderingData.commandBuffer;
using var soc = new ProfilingScope(cmd, profiler);
}
}
}
}