mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-17 10:49:21 -05:00
* 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
35 lines
816 B
C#
35 lines
816 B
C#
using Sandbox.Rendering;
|
|
|
|
namespace Sandbox;
|
|
|
|
/// <summary>
|
|
/// Applies a sharpen effect to the camera
|
|
/// </summary>
|
|
[Title( "Sharpen" )]
|
|
[Category( "Post Processing" )]
|
|
[Icon( "deblur" )]
|
|
public sealed class Sharpen : BasePostProcess<Sharpen>
|
|
{
|
|
[Range( 0, 5 )]
|
|
[Property] public float Scale { get; set; } = 2;
|
|
|
|
[Range( 0, 5 )]
|
|
[Property] public float TexelSize { get; set; } = 1;
|
|
|
|
private static readonly Material Shader = Material.FromShader( "shaders/postprocess/pp_sharpen.shader" );
|
|
|
|
public override void Render()
|
|
{
|
|
float scale = GetWeighted( x => x.Scale );
|
|
|
|
if ( scale <= 0f )
|
|
return;
|
|
|
|
Attributes.Set( "strength", scale );
|
|
Attributes.Set( "size", GetWeighted( x => x.TexelSize ) );
|
|
|
|
var blit = BlitMode.WithBackbuffer( Shader, Stage.AfterPostProcess, 1 );
|
|
Blit( blit, "Sharpen" );
|
|
}
|
|
}
|