Effects/TiltShiftEffect.cs
using Sandbox.Rendering;
namespace Sandbox;
[Title( "Tilt Shift" )]
[Category( "Post Processing" )]
[Icon( "blur_on" )]
public sealed class TiltShiftEffect : BasePostProcess<TiltShiftEffect>
{
[Property] public float BlurStrength { get; set; } = 2.0f;
[Property] public float FocusCenterY { get; set; } = 0.5f;
[Property] public float FocusRange { get; set; } = 0.2f;
CommandList command = new CommandList();
public override void Render()
{
command.Reset();
command.Attributes.GrabFrameTexture( "ColorBuffer", true );
command.Attributes.Set( "blur_strength", BlurStrength );
command.Attributes.Set( "focus_center_y", FocusCenterY );
command.Attributes.Set( "focus_range", FocusRange );
command.Attributes.Set( "screen_width", Screen.Width );
command.Attributes.Set( "screen_height", Screen.Height );
command.Blit( Material.FromShader( "shaders/tilt_shift.shader" ) );
InsertCommandList( command, Stage.AfterTransparent, 1000, "TiltShift" );
}
}