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

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

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

    [Export( PropertyHint.Range, "0,600")]
    public float smearingFrames = 30;


    RG_BufferTexture _bufferTexture;
    RG_ScreenColorTexure _screenColorTexure;
    RG_TemporalBlur _temporalBlur;

    void Initialize()
    { 
      _screenColorTexure = new RG_ScreenColorTexure( graph );
      _bufferTexture = RG_BufferTexture.ScreenSize( graph );

      _temporalBlur = new RG_TemporalBlur( graph );

      graph.InitializeNodes();

      _temporalBlur.SetTextureSlotInputs( _bufferTexture, _screenColorTexure );

      graph.SetProcessOrder(
        _screenColorTexure, 
        _bufferTexture, 
        _temporalBlur
      );
      
    }

    protected override void ForAllViews()    
    {     
      _temporalBlur.constants.Set(
        amount,
        1.0f - FrameSmoothing.ComputeCoefficient( 1f/60f, smearingFrames )
      );
    }


    
  }
}