8 changed files with 67 additions and 94 deletions
-
52Runtime/Common/FfxUtils.cs
-
11Runtime/Common/FfxUtils.cs.meta
-
45Runtime/FSR2/Fsr2.cs
-
2Runtime/FSR2/Fsr2Context.cs
-
2Runtime/FSR2/Fsr2Resources.cs
-
45Runtime/FSR3/Fsr3Upscaler.cs
-
2Runtime/FSR3/Fsr3UpscalerContext.cs
-
2Runtime/FSR3/Fsr3UpscalerResources.cs
@ -0,0 +1,52 @@ |
|||||
|
using UnityEngine; |
||||
|
|
||||
|
namespace FidelityFX |
||||
|
{ |
||||
|
public static class FfxUtils |
||||
|
{ |
||||
|
public static float GetMipmapBiasOffset(int renderWidth, int displayWidth) |
||||
|
{ |
||||
|
return Mathf.Log((float)renderWidth / displayWidth, 2.0f) - 1.0f; |
||||
|
} |
||||
|
|
||||
|
public static int GetJitterPhaseCount(int renderWidth, int displayWidth) |
||||
|
{ |
||||
|
const float basePhaseCount = 8.0f; |
||||
|
int jitterPhaseCount = (int)(basePhaseCount * Mathf.Pow((float)displayWidth / renderWidth, 2.0f)); |
||||
|
return jitterPhaseCount; |
||||
|
} |
||||
|
|
||||
|
public static void GetJitterOffset(out float outX, out float outY, int index, int phaseCount) |
||||
|
{ |
||||
|
outX = Halton((index % phaseCount) + 1, 2) - 0.5f; |
||||
|
outY = Halton((index % phaseCount) + 1, 3) - 0.5f; |
||||
|
} |
||||
|
|
||||
|
// Calculate halton number for index and base.
|
||||
|
private static float Halton(int index, int @base) |
||||
|
{ |
||||
|
float f = 1.0f, result = 0.0f; |
||||
|
|
||||
|
for (int currentIndex = index; currentIndex > 0;) { |
||||
|
|
||||
|
f /= @base; |
||||
|
result += f * (currentIndex % @base); |
||||
|
currentIndex = (int)Mathf.Floor((float)currentIndex / @base); |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
public static float Lanczos2(float value) |
||||
|
{ |
||||
|
return Mathf.Abs(value) < Mathf.Epsilon ? 1.0f : Mathf.Sin(Mathf.PI * value) / (Mathf.PI * value) * (Mathf.Sin(0.5f * Mathf.PI * value) / (0.5f * Mathf.PI * value)); |
||||
|
} |
||||
|
|
||||
|
#if !UNITY_2021_1_OR_NEWER
|
||||
|
internal static void SetBufferData(this CommandBuffer commandBuffer, ComputeBuffer computeBuffer, Array data) |
||||
|
{ |
||||
|
commandBuffer.SetComputeBufferData(computeBuffer, data); |
||||
|
} |
||||
|
#endif
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 9c5c0f0b987cca64c8dfd8051e09962e |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue