@ -7,6 +7,7 @@ namespace UnityEngine.Rendering.PostProcessing
protected override string VariantName = > "SGSR2 2-Pass Fragment" ;
protected override string VariantName = > "SGSR2 2-Pass Fragment" ;
private Material _material ;
private Material _material ;
private readonly RenderTargetIdentifier [ ] _mrt = new RenderTargetIdentifier [ 2 ] ;
public override void CreateContext ( PostProcessRenderContext context , Upscaling config )
public override void CreateContext ( PostProcessRenderContext context , Upscaling config )
{
{
@ -26,14 +27,19 @@ namespace UnityEngine.Rendering.PostProcessing
{
{
uint frameIndex = _frameCount % 2 ;
uint frameIndex = _frameCount % 2 ;
// TODO: try using a PropertySheet here again, now that PPV2 is functional
cmd . SetGlobalTexture ( "InputColor" , context . source ) ;
cmd . SetGlobalTexture ( "InputColor" , context . source ) ;
cmd . SetGlobalTexture ( "MotionDepthClipAlphaBuffer" , _motionDepthClipAlpha ) ;
cmd . SetGlobalTexture ( "MotionDepthClipAlphaBuffer" , _motionDepthClipAlpha ) ;
cmd . SetGlobalTexture ( "PrevOutput" , _upscaleHistory [ frameIndex ^ 1 ] ) ;
cmd . SetGlobalTexture ( "PrevOutput" , _upscaleHistory [ frameIndex ^ 1 ] ) ;
cmd . SetGlobalConstantBuffer ( _paramsBuffer , "cbSGSR2" , 0 , Marshal . SizeOf < SGSR2 . Params > ( ) ) ;
cmd . SetGlobalConstantBuffer ( _paramsBuffer , "cbSGSR2" , 0 , Marshal . SizeOf < SGSR2 . Params > ( ) ) ;
cmd . SetRenderTarget ( _motionDepthClipAlpha , context . source ) ;
cmd . DrawMesh ( RuntimeUtilities . fullscreenTriangle , Matrix4x4 . identity , _material , 0 , 0 ) ;
cmd . Blit ( BuiltinRenderTextureType . None , _motionDepthClipAlpha , _material , 0 ) ;
cmd . Blit ( BuiltinRenderTextureType . None , _upscaleHistory [ frameIndex ] , _material , 1 ) ;
cmd . Blit ( _upscaleHistory [ frameIndex ] , context . destination ) ;
_mrt [ 0 ] = context . destination ;
_mrt [ 1 ] = _upscaleHistory [ frameIndex ] ;
cmd . SetRenderTarget ( _mrt , context . destination ) ;
cmd . DrawMesh ( RuntimeUtilities . fullscreenTriangle , Matrix4x4 . identity , _material , 0 , 1 ) ;
}
}
}
}
}
}