2025-04-24 13:39:00 +00:00
|
|
|
|
|
|
|
using Godot;
|
|
|
|
using Godot.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
namespace Rokojori
|
|
|
|
{
|
|
|
|
[Tool]
|
|
|
|
[GlobalClass]
|
|
|
|
public partial class TemporalSmearEffect:SingleShaderCompositorEffect
|
|
|
|
{
|
|
|
|
public static readonly string shaderPath =
|
|
|
|
RokojoriPlugin.Path( "Runtime/Rendering/CompositorEffects/TemporalSmear/TemporalSmear.glsl" );
|
|
|
|
|
|
|
|
[Export( PropertyHint.Range, "0,1")]
|
|
|
|
public float amount = 1f;
|
|
|
|
|
2025-04-25 08:13:22 +00:00
|
|
|
[Export( PropertyHint.Range, "0,600")]
|
|
|
|
public float smearingFrames = 30;
|
2025-04-24 13:39:00 +00:00
|
|
|
|
|
|
|
[Export( PropertyHint.Range, "0,1")]
|
|
|
|
public float lumaAmount = 0.5f;
|
|
|
|
|
|
|
|
[Export( PropertyHint.Range, "0,1")]
|
|
|
|
public float lumaTreshold = 0.5f;
|
|
|
|
|
|
|
|
[Export( PropertyHint.Range, "0.5,5")]
|
|
|
|
public float lumaSaturate = 1.3f;
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnConfigure()
|
|
|
|
{
|
|
|
|
EffectCallbackType = EffectCallbackTypeEnum.PostTransparent;
|
|
|
|
_shaderPath = shaderPath;
|
|
|
|
_groupSize = 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void SetConstants()
|
|
|
|
{
|
|
|
|
constants.Set(
|
|
|
|
amount,
|
2025-04-25 08:13:22 +00:00
|
|
|
1.0f - FrameSmoothing.ComputeCoefficient( 1f/60f, smearingFrames ),
|
2025-04-24 13:39:00 +00:00
|
|
|
lumaAmount,
|
|
|
|
lumaTreshold,
|
|
|
|
lumaSaturate
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
RDTexture _bufferTexture;
|
|
|
|
|
|
|
|
protected override void RenderView()
|
|
|
|
{
|
2025-04-25 08:13:22 +00:00
|
|
|
_bufferTexture = RDTexture.EnsureScreenSizeTexture( _bufferTexture, this );
|
|
|
|
|
|
|
|
context.AssignTexture( _bufferTexture );
|
|
|
|
context.AssignScreenColorTexture();
|
2025-04-24 13:39:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
context.pushConstants = constants;
|
|
|
|
|
|
|
|
context.Render();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|