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. 1
      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. 3
      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

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

@ -24,6 +24,7 @@ public static class SGSR2
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;

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

@ -24,7 +24,8 @@ cbuffer Params : register(b0)
float preExposure; float preExposure;
float cameraFovAngleHor; float cameraFovAngleHor;
float cameraNear; float cameraNear;
float MinLerpContribution;
float minLerpContribution;
float2 scaleRatio;
uint bSameCamera; uint bSameCamera;
uint reset; uint reset;
}; };

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