rj-action-library/Runtime/Rendering/CompositorEffects/Pixelation/PixelationEffect.cs

48 lines
1.0 KiB
C#

using Godot;
using Godot.Collections;
using System.Collections.Generic;
namespace Rokojori
{
[Tool]
[GlobalClass]
public partial class PixelationEffect:SingleShaderCompositorEffect
{
public static readonly string shaderPath =
RokojoriPlugin.Path( "Runtime/Rendering/CompositorEffects/Pixelation/PixelationShader.glsl" );
[Export]
public float pixelSize = 1f;
[Export]
public float pixelSizePower = 1f;
protected override void OnConfigure()
{
EffectCallbackType = EffectCallbackTypeEnum.PostTransparent;
_shaderPath = shaderPath;
_groupSize = 8;
}
RDPushConstants constants = new RDPushConstants();
protected override void ForAllViews()
{
constants.Set(
(Vector2)context.internalSize,
Mathf.Pow( pixelSize, pixelSizePower )
);
}
protected override void RenderView()
{
context.Assign_ScreenColorTexture();
context.pushConstants = constants;
context.Render();
}
}
}