using System;
using UnityEngine;
using UnityEngine.Rendering.Universal;

namespace RebootKit.Engine.Graphics.Pixelize
{
    public class PixelizeFeature : ScriptableRendererFeature
    {
        [Serializable]
        public class PassSettings
        {
            public RenderPassEvent RenderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing;
            public int FrameHeight = 240;
        }

        [SerializeField]
        private PassSettings _settings;

        private PixelizePass _pass;

        public override void Create()
        {
            _pass = new PixelizePass(_settings);
        }

        public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
        {
#if UNITY_EDITOR
            if (renderingData.cameraData.isSceneViewCamera)
            {
                return;
            }
#endif
            renderer.EnqueuePass(_pass);
        }
    }
}