Browse Source
Working SGSR2 2-pass FS implementation, bit dirty but good enough for testing.
sgsr2_fs
Working SGSR2 2-pass FS implementation, bit dirty but good enough for testing.
sgsr2_fs
12 changed files with 79 additions and 16 deletions
-
2Packages/com.unity.postprocessing@3.2.2/PostProcessing/PostProcessResources.asset
-
2Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling.cs
-
6Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/SGSR2.cs
-
14Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_fs/sgsr2.shader
-
7Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_fs/sgsr2_convert.hlsl
-
5Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_fs/sgsr2_upscale.hlsl
-
2Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/sgsr2_common.hlsl
-
4Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2Upscaler_2PassCS.cs
-
39Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2Upscaler_2PassFS.cs
-
3Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2Upscaler_2PassFS.cs.meta
-
6Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2Upscaler_3PassCS.cs
-
5Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/PostProcessResources.cs
@ -0,0 +1,39 @@ |
|||||
|
using System.Runtime.InteropServices; |
||||
|
|
||||
|
namespace UnityEngine.Rendering.PostProcessing |
||||
|
{ |
||||
|
internal class SGSR2Upscaler_2PassFS: SGSR2Upscaler |
||||
|
{ |
||||
|
protected override string VariantName => "SGSR2 2-Pass Fragment"; |
||||
|
|
||||
|
private Material _material; |
||||
|
|
||||
|
public override void CreateContext(PostProcessRenderContext context, Upscaling config) |
||||
|
{ |
||||
|
base.CreateContext(context, config); |
||||
|
|
||||
|
_material = new Material(context.resources.shaders.sgsr2Upscaler.twoPassFragment); |
||||
|
} |
||||
|
|
||||
|
public override void DestroyContext() |
||||
|
{ |
||||
|
RuntimeUtilities.Destroy(_material); |
||||
|
|
||||
|
base.DestroyContext(); |
||||
|
} |
||||
|
|
||||
|
protected override void DoRender(CommandBuffer cmd, PostProcessRenderContext context, Upscaling config) |
||||
|
{ |
||||
|
uint frameIndex = _frameCount % 2; |
||||
|
|
||||
|
cmd.SetGlobalTexture("InputColor", context.source); |
||||
|
cmd.SetGlobalTexture("MotionDepthClipAlphaBuffer", _motionDepthClipAlpha); |
||||
|
cmd.SetGlobalTexture("PrevOutput", _upscaleHistory[frameIndex ^ 1]); |
||||
|
cmd.SetGlobalConstantBuffer(_paramsBuffer, "cbSGSR2", 0, Marshal.SizeOf<SGSR2.Params>()); |
||||
|
|
||||
|
cmd.Blit(BuiltinRenderTextureType.None, _motionDepthClipAlpha, _material, 0); |
||||
|
cmd.Blit(BuiltinRenderTextureType.None, _upscaleHistory[frameIndex], _material, 1); |
||||
|
cmd.Blit(_upscaleHistory[frameIndex], context.destination); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,3 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 50ebaec17d8940c0ac51a8721f9f9419 |
||||
|
timeCreated: 1734977118 |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue