Browse Source

Added scaleRatio to unify the cbuffer definition for all shaders, including the fragment shader variant.

sgsr2_fs
Nico de Poel 1 year ago
parent
commit
d354d07d81
  1. 3
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/SGSR2.cs
  2. 2
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_cs/sgsr2_upscale.compute
  3. 27
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/sgsr2_common.hlsl
  4. 3
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2Upscaler.cs

3
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/SGSR2.cs

@ -23,7 +23,8 @@ public static class SGSR2
public float cameraFovAngleHor; public float cameraFovAngleHor;
public float cameraNear; public float cameraNear;
public float minLerpContribution; public float minLerpContribution;
public Vector2 scaleRatio;
public uint bSameCamera; public uint bSameCamera;
public uint reset; public uint reset;
} }

2
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_cs/sgsr2_upscale.compute

@ -263,7 +263,7 @@ void CS(uint3 gl_GlobalInvocationID : SV_DispatchThreadID)
rectboxmin = max(rectboxmin, boxmin); rectboxmin = max(rectboxmin, boxmin);
float3 clampedcolor = clamp(HistoryColor, rectboxmin, rectboxmax); float3 clampedcolor = clamp(HistoryColor, rectboxmin, rectboxmax);
float startLerpValue = MinLerpContribution; //MinLerpContribution; //MinLerpContribution;
float startLerpValue = minLerpContribution; //MinLerpContribution; //MinLerpContribution;
if ((abs(mda.x) + abs(mda.y)) > 0.000001) startLerpValue = 0.0; if ((abs(mda.x) + abs(mda.y)) > 0.000001) startLerpValue = 0.0;
float lerpcontribution = (any(rectboxmin > HistoryColor) || any(HistoryColor > rectboxmax)) ? startLerpValue : 1.0f; float lerpcontribution = (any(rectboxmin > HistoryColor) || any(HistoryColor > rectboxmax)) ? startLerpValue : 1.0f;

27
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/sgsr2_common.hlsl

@ -14,19 +14,20 @@
cbuffer Params : register(b0) cbuffer Params : register(b0)
{ {
uint2 renderSize;
uint2 displaySize;
float2 renderSizeRcp;
float2 displaySizeRcp;
float2 jitterOffset;
float2 padding1;
float4 clipToPrevClip[4];
float preExposure;
float cameraFovAngleHor;
float cameraNear;
float MinLerpContribution;
uint bSameCamera;
uint reset;
uint2 renderSize;
uint2 displaySize;
float2 renderSizeRcp;
float2 displaySizeRcp;
float2 jitterOffset;
float2 padding1;
float4 clipToPrevClip[4];
float preExposure;
float cameraFovAngleHor;
float cameraNear;
float minLerpContribution;
float2 scaleRatio;
uint bSameCamera;
uint reset;
}; };
float FastLanczos(float base) float FastLanczos(float base)

3
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2Upscaler.cs

@ -67,9 +67,10 @@ namespace UnityEngine.Rendering.PostProcessing
parms.jitterOffset = config.JitterOffset; parms.jitterOffset = config.JitterOffset;
parms.clipToPrevClip = clipToPrevClip; parms.clipToPrevClip = clipToPrevClip;
parms.preExposure = config.preExposure; parms.preExposure = config.preExposure;
parms.cameraFovAngleHor = Mathf.Tan(context.camera.fieldOfView * Mathf.Deg2Rad * 0.5f) * (float)parms.renderSize.x / parms.renderSize.y;
parms.cameraFovAngleHor = Mathf.Tan(context.camera.fieldOfView * Mathf.Deg2Rad * 0.5f) * parms.renderSize.x * parms.renderSizeRcp.y;
parms.cameraNear = context.camera.nearClipPlane; parms.cameraNear = context.camera.nearClipPlane;
parms.minLerpContribution = 0f; parms.minLerpContribution = 0f;
parms.scaleRatio = new Vector2(parms.renderSize.x * parms.displaySizeRcp.x, parms.renderSize.y * parms.displaySizeRcp.y);
parms.bSameCamera = isCameraStill ? 1u : 0u; parms.bSameCamera = isCameraStill ? 1u : 0u;
parms.reset = config.Reset ? 1u : 0u; parms.reset = config.Reset ? 1u : 0u;
_paramsBuffer.UpdateBufferData(cmd); _paramsBuffer.UpdateBufferData(cmd);

Loading…
Cancel
Save