using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.Universal;

public enum BufferType
{
    CameraColor,
    Custom
}

public class DrawFullscreenFeature : ScriptableRendererFeature
{
    [Serializable]
    public class Settings
    {
        public RenderPassEvent renderPassEvent = RenderPassEvent.AfterRenderingOpaques;
        public Material blitMaterial = null;
        public int blitMaterialPassIndex = -1;
        public BufferType sourceType = BufferType.CameraColor;
        public BufferType destinationType = BufferType.CameraColor;
        public string sourceTextureId = "_SourceTexture";
        public string destinationTextureId = "_DestinationTexture";
    }

    [SerializeField] private Settings _settings = new Settings();
    private DrawFullscreenPass _blitPass;
    
    public override void Create()
    {
        _blitPass = new DrawFullscreenPass(name);
    }

    public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        if (_settings.blitMaterial == null)
        {
            Debug.LogWarning($"missing blit material. {GetType().Name} blit pass will not execute. check for missing references.");
            return;
        }

        _blitPass.renderPassEvent = _settings.renderPassEvent;
        _blitPass.Settings = _settings;
        renderer.EnqueuePass(_blitPass);
    }
}
