rj-action-library/Runtime/Rendering/Compositor/CompositorEffects/DepthView/DepthViewEffect.cs

59 lines
1.3 KiB
C#

using Godot;
using Godot.Collections;
using System.Collections.Generic;
namespace Rokojori
{
[Tool]
[GlobalClass]
public partial class DepthViewEffect:SingleShaderCompositorEffect
{
public static readonly string shaderPath = Path( "DepthView/DepthViewShader.glsl" );
RDSampler sampler;
[Export( PropertyHint.Range, "0,1") ]
public float greyAmount;
[Export( PropertyHint.Range, "0,1") ]
public float depthAmount;
[Export( PropertyHint.Range, "0.001,3") ]
public float depthPower;
protected override void OnConfigure()
{
EffectCallbackType = EffectCallbackTypeEnum.PostTransparent;
_shaderPath = shaderPath;
_groupSize = 8;
}
protected override void OnInitialize()
{
base.OnInitialize();
sampler = context.Sampler( RenderingDevice.SamplerFilter.Nearest, RenderingDevice.SamplerRepeatMode.ClampToEdge );
}
protected override void SetConstants()
{
constants.Set(
(Vector2)context.internalSize,
new Vector2( greyAmount, depthAmount ),
depthPower
);
}
protected override void RenderView()
{
context.AssignScreenColorTexture();
context.AssignScreenDepthTexture( sampler );
context.pushConstants = constants;
context.ProcessComputeProgram();
}
}
}