rj-action-library/Runtime/Rendering/Compositor/CompositorEffects/Vignette/VignetteEffect.cs

61 lines
1.1 KiB
C#
Raw Normal View History

2025-07-22 14:08:22 +00:00
using Godot;
using Godot.Collections;
using System.Collections.Generic;
namespace Rokojori
{
[Tool]
[GlobalClass]
public partial class VignetteEffect:SingleShaderCompositorEffect
{
public static readonly string shaderPath = Path( "Vignette/VignetteShader.glsl" );
[Export( PropertyHint.Range, "0,1")]
public float amount = 1.0f;
[Export( PropertyHint.Range, "0.1,2")]
public float radius = 0.5f;
[Export]
public float power = 1.0f;
[Export]
public float offset = 1.0f;
[Export]
public Color colorTop;
[Export]
public Color colorBottom;
protected override void OnConfigure()
{
EffectCallbackType = EffectCallbackTypeEnum.PostTransparent;
_shaderPath = shaderPath;
_groupSize = 8;
}
protected override void SetConstants()
{
constants.Set(
amount,
radius,
power,
offset,
(Vector2) context.internalSize
);
}
protected override void RenderView()
{
context.AssignScreenColorTexture();
context.pushConstants = constants;
context.ProcessComputeProgram();
}
}
}