Browse Source

Reorganized shader code such that standard BiRP and PPV2 can share the same common code with only some light wrappers to implement the differences

sgsr2_fs
Nico de Poel 1 year ago
parent
commit
df58df61d6
  1. 2
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/PostProcessResources.asset
  2. 49
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_fs/sgsr2_birp.shader
  3. 3
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_fs/sgsr2_birp.shader.meta
  4. 4
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_fs/sgsr2_convert.hlsl
  5. 25
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_fs/sgsr2_ppv2.shader
  6. 5
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_fs/sgsr2_upscale.hlsl

2
Packages/com.unity.postprocessing@3.2.2/PostProcessing/PostProcessResources.asset

@ -115,7 +115,7 @@ MonoBehaviour:
multiScaleAO: {fileID: 4800000, guid: 67f9497810829eb4791ec19e95781e51, type: 3}
screenSpaceReflections: {fileID: 4800000, guid: f997a3dc9254c44459323cced085150c, type: 3}
sgsr2Upscaler:
twoPassFragment: {fileID: 4800000, guid: 9e367486dadedbc4da8313a481aa8a27, type: 3}
twoPassFragment: {fileID: 4800000, guid: 59bc1035dd975f64d8141148a7088d0a, type: 3}
computeShaders:
autoExposure: {fileID: 7200000, guid: 34845e0ca016b7448842e965db5890a5, type: 3}
exposureHistogram: {fileID: 7200000, guid: 8c2fcbdf9bc58664f89917f7b9d79501, type: 3}

49
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_fs/sgsr2_birp.shader

@ -0,0 +1,49 @@
Shader "TND/sgsr2_2pass_fs"
{
SubShader
{
Cull Off ZWrite Off ZTest Always
Pass
{
Name "Convert"
HLSLPROGRAM
#pragma vertex vert_img
#pragma fragment frag_convert
#pragma target 4.5
#pragma enable_d3d11_debug_symbols
#include "../sgsr2_birp.hlsl"
#include "sgsr2_convert.hlsl"
void frag_convert(v2f_img i, out float4 MotionDepthClipAlphaBuffer: SV_Target)
{
sgsr2_convert(i.uv, MotionDepthClipAlphaBuffer);
}
ENDHLSL
}
Pass
{
Name "Upscale"
HLSLPROGRAM
#pragma vertex vert_img
#pragma fragment frag_upscale
#pragma target 4.5
#pragma enable_d3d11_debug_symbols
#include "../sgsr2_birp.hlsl"
#include "sgsr2_upscale.hlsl"
void frag_upscale(v2f_img i, out half4 OutputColor: SV_Target)
{
sgsr2_upscale(i.uv, OutputColor);
}
ENDHLSL
}
}
}

3
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_fs/sgsr2_birp.shader.meta

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4451c8b25af942ccaa8d6d0bb46a8e60
timeCreated: 1735392260

4
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_fs/sgsr2_convert.hlsl

@ -1,4 +1,3 @@
#include "../sgsr2_birp.hlsl"
#include "../sgsr2_common.hlsl"
//============================================================================================================
@ -18,9 +17,8 @@ TYPED_TEXTURE2D_X(half2, _CameraMotionVectorsTexture);
#define InputDepth _CameraDepthTexture
#define InputVelocity _CameraMotionVectorsTexture
void sgsr2_convert(VaryingsDefault i, out float4 MotionDepthClipAlphaBuffer: SV_Target)
void sgsr2_convert(const half2 texCoord, out float4 MotionDepthClipAlphaBuffer)
{
const half2 texCoord = i.texcoord;
uint2 InputPos = uint2(texCoord * renderSize);
float2 gatherCoord = texCoord - 0.5f * renderSizeRcp;

25
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_fs/sgsr2_ppv2.shader

@ -4,35 +4,52 @@ Shader "TND/PPV2/sgsr2_2pass_fs"
{
Cull Off ZWrite Off ZTest Always
Pass // Convert
Pass
{
Name "Convert"
HLSLPROGRAM
#pragma vertex VertDefault
#pragma fragment sgsr2_convert
#pragma fragment FragConvert
#pragma target 4.5
#pragma enable_d3d11_debug_symbols
#define UNITY_CG_INCLUDED
#include "Packages/com.unity.postprocessing/PostProcessing/Shaders/StdLib.hlsl"
#undef EPSILON
#include "../sgsr2_birp.hlsl"
#include "sgsr2_convert.hlsl"
void FragConvert(VaryingsDefault i, out float4 MotionDepthClipAlphaBuffer: SV_Target)
{
sgsr2_convert(i.texcoord, MotionDepthClipAlphaBuffer);
}
ENDHLSL
}
Pass // Upscale
Pass
{
Name "Upscale"
HLSLPROGRAM
#pragma vertex VertDefault
#pragma fragment sgsr2_upscale
#pragma fragment FragUpscale
#pragma target 4.5
#pragma enable_d3d11_debug_symbols
#define UNITY_CG_INCLUDED
#include "Packages/com.unity.postprocessing/PostProcessing/Shaders/StdLib.hlsl"
#undef EPSILON
#include "../sgsr2_birp.hlsl"
#include "sgsr2_upscale.hlsl"
void FragUpscale(VaryingsDefault i, out half4 OutputColor: SV_Target0, out half4 HistoryOutput: SV_Target1)
{
sgsr2_upscale(i.texcoord, OutputColor);
HistoryOutput = OutputColor;
}
ENDHLSL
}
}

5
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_fs/sgsr2_upscale.hlsl

@ -1,4 +1,3 @@
#include "../sgsr2_birp.hlsl"
#include "../sgsr2_common.hlsl"
//============================================================================================================
@ -21,9 +20,8 @@ SamplerState samplerPrevOutput;
SamplerState samplerMotionDepthClipAlphaBuffer;
SamplerState samplerInputColor;
void sgsr2_upscale(VaryingsDefault i, out half4 Output: SV_Target0, out half4 HistoryOutput: SV_Target1)
void sgsr2_upscale(const half2 texCoord, out half4 Output)
{
const half2 texCoord = i.texcoord;
half Biasmax_viewportXScale = scaleRatio.x;
half scalefactor = scaleRatio.y;
@ -262,5 +260,4 @@ void sgsr2_upscale(VaryingsDefault i, out half4 Output: SV_Target0, out half4 Hi
Upsampledcw.xyz = lerp(HistoryColor, Upsampledcw.xyz, alpha);
Output = half4(Upsampledcw.xyz, 0.0);
HistoryOutput = Output;
}
Loading…
Cancel
Save