
using Godot;
using Godot.Collections;
using System.Collections.Generic;

namespace Rokojori
{  
  [Tool]
  [GlobalClass]
  public partial class VignetteEffect:SingleShaderCompositorEffect
  {
    public static readonly string shaderPath = Path( "Vignette/VignetteShader.glsl" );

    [Export( PropertyHint.Range, "0,1")]
    public float amount = 1.0f;

    [Export( PropertyHint.Range, "0.01,10")]
    public float radius = 0.5f;

    [Export]
    public float power = 1.0f;

    [Export]
    public float offset = 1.0f;
    
    [Export]
    public Color colorTop;

    [Export]
    public Color colorBottom;

    [Export]
    public string info = "";

    protected override void OnConfigure()
    {
      EffectCallbackType = EffectCallbackTypeEnum.PostTransparent;
      _shaderPath = shaderPath;
      _groupSize = 8;
    }

    protected override void SetConstants()
    {     
      constants.Set(        
        amount,
        radius,
        power,
        offset,
        (Vector2) context.internalSize
      );

      info = "constants: " + constants.info;


    }

    public override void ClearCaches()
    {
      base.ClearCaches();
    }

    protected override void RenderView()
    {
      context.AssignScreenColorTexture();

      context.pushConstants = constants;

      context.ProcessComputeProgram();

    }
  }
}