mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-09 06:48:34 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
29 lines
680 B
C#
29 lines
680 B
C#
using Sandbox.Rendering;
|
|
|
|
namespace Sandbox;
|
|
|
|
/// <summary>
|
|
/// Applies a pixelate effect to the camera
|
|
/// </summary>
|
|
[Title( "Pixelate" )]
|
|
[Category( "Post Processing" )]
|
|
[Icon( "apps" )]
|
|
public sealed class Pixelate : BasePostProcess<Pixelate>
|
|
{
|
|
[Range( 0, 1 )]
|
|
[Property] public float Scale { get; set; } = 0.25f;
|
|
|
|
public override void Render()
|
|
{
|
|
var shader = Material.FromShader( "shaders/postprocess/pp_pixelate.shader" );
|
|
|
|
float scale = GetWeighted( x => x.Scale );
|
|
if ( scale.AlmostEqual( 0.0f ) ) return;
|
|
|
|
Attributes.Set( "scale", scale );
|
|
|
|
var blit = BlitMode.WithBackbuffer( shader, Stage.AfterPostProcess, 10000, true );
|
|
Blit( blit, "Pixelate" );
|
|
}
|
|
}
|