Files
Lorenz Junglas 12affe5ccb Reduce material creations/allocations (#3766)
* Make SpriteBatchSceneObject shaders static, so we don't create them per instance

* Avoid per frame shader/material creation in PostProcessing

* Avoid per frame shader/material creation in HudPainter

* Move a few more compute shaders into static members

* Reduce allocations in NormalizeFilename

* Reduce string allocations in Material.FromShader
2026-01-14 08:40:37 +01:00

28 lines
667 B
C#

using Sandbox.Rendering;
namespace Sandbox;
/// <summary>
/// Applies a blur effect to the camera.
/// </summary>
[Title( "Blur" )]
[Category( "Post Processing" )]
[Icon( "lens_blur" )]
public sealed class Blur : BasePostProcess<Blur>
{
[Range( 0, 1 ), Property] public float Size { get; set; } = 1.0f;
private static readonly Material Shader = Material.FromShader( "shaders/postprocess/pp_blur.shader" );
public override void Render()
{
float size = GetWeighted( x => x.Size );
if ( size <= 0f ) return;
Attributes.Set( "size", size );
var blit = BlitMode.WithBackbuffer( Shader, Stage.BeforePostProcess, 4000, true );
Blit( blit, "Blur" );
}
}