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

namespace Rokojori
{  
  [Tool]
  [GlobalClass]
  public partial class RadialBlur2:BlurOrSharpenEffect
  {
    public RadialBlur2():base()
    {
      Initialize();
    }

    [Export]
    public Vector2 center = new Vector2( 0.5f, 0.5f );

    [Export]
    public float radius = 0.01f;

    [Export]
    public float intensity =1f;

    [Export]
    public float samples = 8f;


    RG_ScreenColorTexure screenColorTexture;
    RG_BufferTexture bufferTexture;    

    CEG_Copy copy;
    RG_RadialBlur radialBlur;    

    void Initialize()
    { 
      screenColorTexture = new RG_ScreenColorTexure( graph );
      bufferTexture = RG_BufferTexture.ScreenSize( graph );

      copy = new CEG_Copy( graph );
      radialBlur = new RG_RadialBlur( graph );


      graph.InitializeNodes();      

      

      copy.SetTextureSlotInputs( screenColorTexture, bufferTexture );
      radialBlur.SetTextureSlotInputs( copy.output, copy.input ); 


      graph.SetProcessOrder( 
        screenColorTexture, bufferTexture, 
        copy, radialBlur 
      );
    }
   

    protected override void ForAllViews()
    {
      radialBlur.constants.Set(
        center, 
        radius, 
        intensity,
        samples,
        Vector2.Zero
      );
    }

   
  }
}