mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-08-02 08:50:18 -04:00
* Camera motion vectors for static geometry A full screen pass that creates a motion vector texture from depth + previous frame view projection. This is only good for objects that have moved due to camera motion, per object motion is not captured here - so this is good for static geometry that does not move, which is the majority of draw calls. Also this layer only executes if "WantsMotionVectors" is true in the pipeline's render attributes. * Add upscaling infrastructure and a simple bilinear stretch upscaler For stretch upscaler, the scene renders into a low-resolution RT, then is upscaled to display resolution before post-processing. * Add FSR upscaler (non temporal) * Add FSR3 upscaler (temporal) Temporal upscaler using FSR3 with explicitly no frame generation Maps to the standard resolution scale factors: * Native - 1x * Quality - 1.5x * Balanced - 1.7x * Performance - 2x * Ultra Performance - 3x * Add all the upscaler cvars to the settings menu https://files.facepunch.com/matt/1b1311b1/sbox_jIRwaBdWwJ.png * Add FidelityFX SDK to third-party legal notices * Add FSR3 reactive mask for viewmodel and overlay objects * Compiled shaders
56 lines
1.3 KiB
C#
56 lines
1.3 KiB
C#
using NativeEngine;
|
|
|
|
namespace Sandbox.Rendering;
|
|
|
|
internal class MotionVectorLayer : ProceduralRenderLayer
|
|
{
|
|
private static Material MotionVectorMaterial = Material.FromShader( "shaders/motion_vectors.shader" );
|
|
|
|
RenderViewport Viewport;
|
|
RenderTarget MotionVectorRT;
|
|
|
|
public MotionVectorLayer()
|
|
{
|
|
Name = "Static Motion Vectors";
|
|
Flags |= LayerFlags.NeverRemove;
|
|
}
|
|
|
|
public void Setup( RenderViewport viewport, ISceneView view )
|
|
{
|
|
Viewport = viewport;
|
|
|
|
MotionVectorRT = RenderTarget.GetTemporary(
|
|
(int)Viewport.Rect.Width,
|
|
(int)Viewport.Rect.Height,
|
|
colorFormat: ImageFormat.RGBA16161616F,
|
|
depthFormat: ImageFormat.None,
|
|
targetName: "MotionVectors" );
|
|
|
|
ColorAttachment = MotionVectorRT.ToColorHandle( view );
|
|
ClearFlags = ClearFlags.Color;
|
|
|
|
view.GetRenderAttributesPtr().SetTextureValue( "MotionVectors", MotionVectorRT.ColorTarget.native, -1 );
|
|
}
|
|
|
|
internal override void OnRender()
|
|
{
|
|
Graphics.Blit( MotionVectorMaterial );
|
|
}
|
|
}
|
|
|
|
internal class MotionVectorDebugLayer : ProceduralRenderLayer
|
|
{
|
|
private static Material DebugMaterial = Material.FromShader( "shaders/motion_vectors_debug.shader" );
|
|
|
|
public MotionVectorDebugLayer()
|
|
{
|
|
Name = "Motion Vectors Debug";
|
|
Flags |= LayerFlags.NeverRemove;
|
|
}
|
|
|
|
internal override void OnRender()
|
|
{
|
|
Graphics.Blit( DebugMaterial );
|
|
}
|
|
}
|