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

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

    [Export]
    public float pixelSize = 1f;

    [Export]
    public float pixelSizePower = 1f;

    RG_ScreenColorTexure _screenColorTexture;
    RG_Pixelation _pixelation;

    void Initialize()
    {
      _screenColorTexture = new RG_ScreenColorTexure( graph );
      _pixelation = new RG_Pixelation( graph );

      graph.InitializeNodes();

      _pixelation.SetTextureSlotInputs( _screenColorTexture, _screenColorTexture );

      graph.SetProcessOrder(
        _screenColorTexture,

        _pixelation
      );
    }

    protected override void ForAllViews()
    {     
      _pixelation.constants.Set(
        (Vector2)context.internalSize, 
        Mathf.Pow( pixelSize, pixelSizePower )
      );
    }
    
  }
}