Files
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

34 lines
883 B
C#

using Sandbox.Rendering;
namespace Sandbox;
/// <summary>
/// Applies a film grain effect to the camera
/// </summary>
[Title( "FilmGrain" )]
[Category( "Post Processing" )]
[Icon( "grain" )]
public sealed class FilmGrain : BasePostProcess<FilmGrain>
{
[Range( 0, 1 )]
[Property] public float Intensity { get; set; } = 0.1f;
[Range( 0, 1 )]
[Property] public float Response { get; set; } = 0.5f;
public override void Render()
{
float intensity = GetWeighted( x => x.Intensity );
if ( intensity.AlmostEqual( 0.0f ) ) return;
float response = GetWeighted( x => x.Response, 1 );
Attributes.Set( "intensity", intensity );
Attributes.Set( "response", GetWeighted( x => x.Response, 1 ) );
var blit = BlitMode.WithBackbuffer( Material.FromShader( "shaders/postprocess/pp_filmgrain.shader" ), Stage.AfterPostProcess, 200, false );
Blit( blit, "FilmGrain" );
}
}