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); } } } }