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

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

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

    [Export( PropertyHint.Range, "1,100") ]
    public float steps = 10;

    [Export( PropertyHint.Range, "1,10") ]
    public float stepsMultiplier = 1;

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

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


    RG_ScreenColorTexure screenColorTexture;
    RG_Posterization posterization;    

    void Initialize()
    { 
      screenColorTexture = new RG_ScreenColorTexure( graph );
      posterization = new RG_Posterization( graph );


      graph.InitializeNodes();      

      
      posterization.SetTextureSlotInputs( screenColorTexture, screenColorTexture ); 


      graph.SetProcessOrder( 
        screenColorTexture, 
        posterization 
      );
    }
   

    protected override void ForAllViews()
    {
      posterization.constants.Set(
        amount, 
        steps * stepsMultiplier,
        Mathf.Pow( 5f, gamma ),
        offset
      );
    }

   
  }
}