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

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

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

    RG_ScreenColorTexure screenColorTexture;
    RG_ImageTexture _curvesTexture;
    RG_HSLCurves _curves;    

    void Initialize()
    { 
      screenColorTexture = new RG_ScreenColorTexure( graph );
      _curvesTexture = new RG_ImageTexture( graph );
      _curves = new RG_HSLCurves( graph );


      graph.InitializeNodes();      

      
      _curves.SetTextureSlotInputs( screenColorTexture, screenColorTexture ); 
      _curves.SetCurvesTextureSlotInputs( _curvesTexture );

      _curvesTexture.SetImageTexture( curves );

      _curves.curves.sampler = context.Sampler( RenderingDevice.SamplerFilter.Linear, RenderingDevice.SamplerRepeatMode.ClampToEdge );

      graph.SetProcessOrder( 
        screenColorTexture, 
        _curves 
      );
    }
   

    protected override void ForAllViews()
    {
      _curvesTexture.SetImageTexture( curves );

      _curves.constants.Set(
        
        amount
      );
    }

   
  }
}