mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-05 04:48:19 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
40 lines
920 B
C#
40 lines
920 B
C#
using Sandbox.Rendering;
|
|
|
|
namespace Sandbox;
|
|
|
|
/// <summary>
|
|
/// Draw a material over the screen
|
|
/// </summary>
|
|
[Title( "Blit Overlay" )]
|
|
[Category( "Post Processing" )]
|
|
[Icon( "grain" )]
|
|
public sealed class BlitOverlay : BasePostProcess<BlitOverlay>
|
|
{
|
|
[Range( 0, 1 )]
|
|
[Property] public float Blend { get; set; } = 0.1f;
|
|
|
|
[Range( 0, 1 )]
|
|
[Property] public BlendMode BlendMode { get; set; } = BlendMode.Normal;
|
|
|
|
[Range( 0, 1 )]
|
|
[Property] public Material Material { get; set; }
|
|
|
|
[Property] public int Order { get; set; }
|
|
|
|
public override void Render()
|
|
{
|
|
if ( !Material.IsValid() ) return;
|
|
|
|
float blend = GetWeighted( x => x.Blend );
|
|
if ( blend.AlmostEqual( 0.0f ) ) return;
|
|
|
|
Attributes.Set( "blend", blend );
|
|
Attributes.SetComboEnum( "D_BLENDMODE", BlendMode );
|
|
|
|
var blit = BlitMode.WithBackbuffer( Material, Stage.AfterPostProcess, Order, true );
|
|
|
|
Blit( blit, $"Overlay ({Material.Name})" );
|
|
}
|
|
|
|
}
|