Compare commits
merge into: ndepoel:master
ndepoel:2019
ndepoel:cas
ndepoel:framework
ndepoel:fsr3.1.1
ndepoel:fsr3.1.4
ndepoel:fsr3framegen
ndepoel:master
pull from: ndepoel:fsr3framegen
ndepoel:2019
ndepoel:cas
ndepoel:framework
ndepoel:fsr3.1.1
ndepoel:fsr3.1.4
ndepoel:fsr3framegen
ndepoel:master
77 Commits
master
...
fsr3frameg
199 changed files with 11047 additions and 1094 deletions
-
57Runtime/Common/FfxContextBase.cs
-
11Runtime/Common/FfxContextBase.cs.meta
-
9Runtime/Common/FfxEnums.cs
-
11Runtime/Common/FfxEnums.cs.meta
-
79Runtime/Common/FfxPassBase.cs
-
11Runtime/Common/FfxPassBase.cs.meta
-
96Runtime/Common/FfxResourcesBase.cs
-
11Runtime/Common/FfxResourcesBase.cs.meta
-
46Runtime/Common/FfxSpd.cs
-
11Runtime/Common/FfxSpd.cs.meta
-
118Runtime/Common/FfxUtils.cs
-
11Runtime/Common/FfxUtils.cs.meta
-
90Runtime/FSR2/Fsr2.cs
-
265Runtime/FSR2/Fsr2Context.cs
-
259Runtime/FSR2/Fsr2Pass.cs
-
89Runtime/FSR2/Fsr2Resources.cs
-
90Runtime/FSR3/Fsr3Upscaler.cs
-
1Runtime/FSR3/Fsr3UpscalerAssets.cs
-
295Runtime/FSR3/Fsr3UpscalerContext.cs
-
322Runtime/FSR3/Fsr3UpscalerPass.cs
-
93Runtime/FSR3/Fsr3UpscalerResources.cs
-
8Runtime/FrameInterpolation.meta
-
162Runtime/FrameInterpolation/FrameInterpolation.cs
-
11Runtime/FrameInterpolation/FrameInterpolation.cs.meta
-
176Runtime/FrameInterpolation/FrameInterpolationAssets.cs
-
11Runtime/FrameInterpolation/FrameInterpolationAssets.cs.meta
-
260Runtime/FrameInterpolation/FrameInterpolationContext.cs
-
11Runtime/FrameInterpolation/FrameInterpolationContext.cs.meta
-
333Runtime/FrameInterpolation/FrameInterpolationPass.cs
-
11Runtime/FrameInterpolation/FrameInterpolationPass.cs.meta
-
64Runtime/FrameInterpolation/FrameInterpolationResources.cs
-
11Runtime/FrameInterpolation/FrameInterpolationResources.cs.meta
-
60Runtime/FrameInterpolation/FrameInterpolationShaderIDs.cs
-
11Runtime/FrameInterpolation/FrameInterpolationShaderIDs.cs.meta
-
8Runtime/OpticalFlow.meta
-
102Runtime/OpticalFlow/OpticalFlow.cs
-
11Runtime/OpticalFlow/OpticalFlow.cs.meta
-
144Runtime/OpticalFlow/OpticalFlowAssets.cs
-
11Runtime/OpticalFlow/OpticalFlowAssets.cs.meta
-
228Runtime/OpticalFlow/OpticalFlowContext.cs
-
11Runtime/OpticalFlow/OpticalFlowContext.cs.meta
-
200Runtime/OpticalFlow/OpticalFlowPass.cs
-
11Runtime/OpticalFlow/OpticalFlowPass.cs.meta
-
76Runtime/OpticalFlow/OpticalFlowResources.cs
-
11Runtime/OpticalFlow/OpticalFlowResources.cs.meta
-
33Runtime/OpticalFlow/OpticalFlowShaderIDs.cs
-
11Runtime/OpticalFlow/OpticalFlowShaderIDs.cs.meta
-
33Shaders/ffx_frameinterpolation_compute_game_vector_field_inpainting_pyramid_pass.compute
-
8Shaders/ffx_frameinterpolation_compute_game_vector_field_inpainting_pyramid_pass.compute.meta
-
33Shaders/ffx_frameinterpolation_compute_inpainting_pyramid_pass.compute
-
8Shaders/ffx_frameinterpolation_compute_inpainting_pyramid_pass.compute.meta
-
33Shaders/ffx_frameinterpolation_debug_view_pass.compute
-
8Shaders/ffx_frameinterpolation_debug_view_pass.compute.meta
-
33Shaders/ffx_frameinterpolation_disocclusion_mask_pass.compute
-
8Shaders/ffx_frameinterpolation_disocclusion_mask_pass.compute.meta
-
33Shaders/ffx_frameinterpolation_game_motion_vector_field_pass.compute
-
8Shaders/ffx_frameinterpolation_game_motion_vector_field_pass.compute.meta
-
33Shaders/ffx_frameinterpolation_inpainting_pass.compute
-
8Shaders/ffx_frameinterpolation_inpainting_pass.compute.meta
-
33Shaders/ffx_frameinterpolation_optical_flow_vector_field_pass.compute
-
8Shaders/ffx_frameinterpolation_optical_flow_vector_field_pass.compute.meta
-
33Shaders/ffx_frameinterpolation_pass.compute
-
8Shaders/ffx_frameinterpolation_pass.compute.meta
-
34Shaders/ffx_frameinterpolation_reconstruct_and_dilate_pass.compute
-
8Shaders/ffx_frameinterpolation_reconstruct_and_dilate_pass.compute.meta
-
33Shaders/ffx_frameinterpolation_reconstruct_previous_depth_pass.compute
-
8Shaders/ffx_frameinterpolation_reconstruct_previous_depth_pass.compute.meta
-
33Shaders/ffx_frameinterpolation_setup_pass.compute
-
8Shaders/ffx_frameinterpolation_setup_pass.compute.meta
-
4Shaders/ffx_fsr2_accumulate_pass.compute
-
4Shaders/ffx_fsr2_autogen_reactive_pass.compute
-
4Shaders/ffx_fsr2_compute_luminance_pyramid_pass.compute
-
4Shaders/ffx_fsr2_depth_clip_pass.compute
-
4Shaders/ffx_fsr2_lock_pass.compute
-
4Shaders/ffx_fsr2_rcas_pass.compute
-
4Shaders/ffx_fsr2_reconstruct_previous_depth_pass.compute
-
4Shaders/ffx_fsr2_tcr_autogen_pass.compute
-
4Shaders/ffx_fsr3upscaler_accumulate_pass.compute
-
4Shaders/ffx_fsr3upscaler_autogen_reactive_pass.compute
-
4Shaders/ffx_fsr3upscaler_debug_view_pass.compute
-
4Shaders/ffx_fsr3upscaler_luma_instability_pass.compute
-
4Shaders/ffx_fsr3upscaler_luma_pyramid_pass.compute
-
4Shaders/ffx_fsr3upscaler_prepare_inputs_pass.compute
-
4Shaders/ffx_fsr3upscaler_prepare_reactivity_pass.compute
-
4Shaders/ffx_fsr3upscaler_rcas_pass.compute
-
4Shaders/ffx_fsr3upscaler_shading_change_pass.compute
-
4Shaders/ffx_fsr3upscaler_shading_change_pyramid_pass.compute
-
4Shaders/ffx_fsr3upscaler_tcr_autogen_pass.compute
-
30Shaders/ffx_opticalflow_compute_luminance_pyramid_pass.compute
-
8Shaders/ffx_opticalflow_compute_luminance_pyramid_pass.compute.meta
-
30Shaders/ffx_opticalflow_compute_optical_flow_advanced_pass_v5.compute
-
8Shaders/ffx_opticalflow_compute_optical_flow_advanced_pass_v5.compute.meta
-
30Shaders/ffx_opticalflow_compute_scd_divergence_pass.compute
-
8Shaders/ffx_opticalflow_compute_scd_divergence_pass.compute.meta
-
30Shaders/ffx_opticalflow_filter_optical_flow_pass_v5.compute
-
8Shaders/ffx_opticalflow_filter_optical_flow_pass_v5.compute.meta
-
30Shaders/ffx_opticalflow_generate_scd_histogram_pass.compute
-
8Shaders/ffx_opticalflow_generate_scd_histogram_pass.compute.meta
-
30Shaders/ffx_opticalflow_prepare_luma_pass.compute
-
8Shaders/ffx_opticalflow_prepare_luma_pass.compute.meta
@ -0,0 +1,57 @@ |
|||||
|
using System; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using UnityEngine; |
||||
|
using UnityEngine.Rendering; |
||||
|
|
||||
|
namespace FidelityFX |
||||
|
{ |
||||
|
public abstract class FfxContextBase |
||||
|
{ |
||||
|
protected static void DestroyPass<TPass>(ref TPass pass) |
||||
|
where TPass: class, IDisposable |
||||
|
{ |
||||
|
if (pass == null) |
||||
|
return; |
||||
|
|
||||
|
pass.Dispose(); |
||||
|
pass = null; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Convenience class for handling a constants buffer containing a single struct item.
|
||||
|
/// This wraps the compute buffer and the value array, as well as providing easy access to both.
|
||||
|
/// </summary>
|
||||
|
protected class ConstantsBuffer<TConst> |
||||
|
where TConst: struct |
||||
|
{ |
||||
|
private ComputeBuffer _computeBuffer; |
||||
|
|
||||
|
private readonly TConst[] _constArray = { new TConst() }; |
||||
|
public ref TConst Value => ref _constArray[0]; |
||||
|
|
||||
|
public void Create() |
||||
|
{ |
||||
|
_computeBuffer = new ComputeBuffer(1, Marshal.SizeOf<TConst>(), ComputeBufferType.Constant); |
||||
|
} |
||||
|
|
||||
|
public void UpdateBufferData(CommandBuffer commandBuffer) |
||||
|
{ |
||||
|
commandBuffer.SetBufferData(_computeBuffer, _constArray); |
||||
|
} |
||||
|
|
||||
|
public void Destroy() |
||||
|
{ |
||||
|
if (_computeBuffer == null) |
||||
|
return; |
||||
|
|
||||
|
_computeBuffer.Release(); |
||||
|
_computeBuffer = null; |
||||
|
} |
||||
|
|
||||
|
public static implicit operator ComputeBuffer(ConstantsBuffer<TConst> constants) |
||||
|
{ |
||||
|
return constants._computeBuffer; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: f4aeccbeb6e61434eb2e50b7190fda8d |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,9 @@ |
|||||
|
namespace FidelityFX |
||||
|
{ |
||||
|
public enum BackbufferTransferFunction |
||||
|
{ |
||||
|
LDR_sRGB, |
||||
|
HDR_PQ, |
||||
|
HDR_scRGB, |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: d71b9fd70a8fb26439d07bf3fbb6bd65 |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,79 @@ |
|||||
|
using System; |
||||
|
using UnityEngine; |
||||
|
using UnityEngine.Profiling; |
||||
|
using UnityEngine.Rendering; |
||||
|
|
||||
|
namespace FidelityFX |
||||
|
{ |
||||
|
internal abstract class FfxPassBase: IDisposable |
||||
|
{ |
||||
|
private readonly string _techName; |
||||
|
private string _passName; |
||||
|
|
||||
|
protected ComputeShader ComputeShader; |
||||
|
protected int KernelIndex; |
||||
|
|
||||
|
protected FfxPassBase(string techName) |
||||
|
{ |
||||
|
_techName = techName; |
||||
|
} |
||||
|
|
||||
|
protected virtual void InitComputeShader(string passName, ComputeShader shader, string kernelName = "CS") |
||||
|
{ |
||||
|
if (shader == null) |
||||
|
{ |
||||
|
throw new MissingReferenceException($"Shader for {_techName} pass '{passName}' could not be loaded! Please ensure it is included in the project correctly."); |
||||
|
} |
||||
|
|
||||
|
_passName = passName; |
||||
|
ComputeShader = shader; |
||||
|
KernelIndex = ComputeShader.FindKernel(kernelName); |
||||
|
} |
||||
|
|
||||
|
public virtual void Dispose() |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
protected ProfilerSampler ProfilerSample(CommandBuffer commandBuffer) |
||||
|
{ |
||||
|
return new ProfilerSampler(_passName, commandBuffer); |
||||
|
} |
||||
|
|
||||
|
protected readonly struct ProfilerSampler : IDisposable |
||||
|
{ |
||||
|
private readonly string _name; |
||||
|
private readonly CommandBuffer _commandBuffer; |
||||
|
|
||||
|
public ProfilerSampler(string name, CommandBuffer commandBuffer) |
||||
|
{ |
||||
|
_name = name; |
||||
|
_commandBuffer = commandBuffer; |
||||
|
_commandBuffer.BeginSample(_name); |
||||
|
} |
||||
|
|
||||
|
public void Dispose() |
||||
|
{ |
||||
|
_commandBuffer.EndSample(_name); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
internal abstract class FfxPassWithFlags<TFlags> : FfxPassBase |
||||
|
where TFlags: Enum |
||||
|
{ |
||||
|
protected readonly TFlags Flags; |
||||
|
|
||||
|
protected FfxPassWithFlags(string techName, TFlags flags) : base(techName) |
||||
|
{ |
||||
|
Flags = flags; |
||||
|
} |
||||
|
|
||||
|
protected override void InitComputeShader(string passName, ComputeShader shader, string kernelName = "CS") |
||||
|
{ |
||||
|
base.InitComputeShader(passName, shader, kernelName); |
||||
|
SetupShaderKeywords(); |
||||
|
} |
||||
|
|
||||
|
protected abstract void SetupShaderKeywords(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: deac9cc5a4c6df64db05956030e79425 |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,96 @@ |
|||||
|
using System; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using UnityEngine; |
||||
|
using UnityEngine.Experimental.Rendering; |
||||
|
|
||||
|
namespace FidelityFX |
||||
|
{ |
||||
|
internal abstract class FfxResourcesBase |
||||
|
{ |
||||
|
protected static ComputeBuffer CreateBuffer<TElem>(string name, int count) |
||||
|
{ |
||||
|
return new ComputeBuffer(count, Marshal.SizeOf<TElem>()); |
||||
|
} |
||||
|
|
||||
|
protected static Texture2D CreateLookup(string name, GraphicsFormat format, Color data) |
||||
|
{ |
||||
|
var tex = new Texture2D(1, 1, format, TextureCreationFlags.None) { name = name }; |
||||
|
tex.SetPixel(0, 0, data); |
||||
|
tex.Apply(); |
||||
|
return tex; |
||||
|
} |
||||
|
|
||||
|
protected static Texture2D CreateLookup<T>(string name, in Vector2Int size, GraphicsFormat format, T[] data) |
||||
|
{ |
||||
|
var tex = new Texture2D(size.x, size.y, format, TextureCreationFlags.None) { name = name }; |
||||
|
tex.SetPixelData(data, 0); |
||||
|
tex.Apply(); |
||||
|
return tex; |
||||
|
} |
||||
|
|
||||
|
protected static RenderTexture CreateResource(string name, in Vector2Int size, GraphicsFormat format) |
||||
|
{ |
||||
|
var rt = new RenderTexture(size.x, size.y, 0, format) { name = name, enableRandomWrite = true }; |
||||
|
rt.Create(); |
||||
|
return rt; |
||||
|
} |
||||
|
|
||||
|
protected static RenderTexture CreateResourceMips(string name, in Vector2Int size, GraphicsFormat format) |
||||
|
{ |
||||
|
int mipCount = 1 + Mathf.FloorToInt(Mathf.Log(Math.Max(size.x, size.y), 2.0f)); |
||||
|
var rt = new RenderTexture(size.x, size.y, 0, format, mipCount) { name = name, enableRandomWrite = true, useMipMap = true, autoGenerateMips = false }; |
||||
|
rt.Create(); |
||||
|
return rt; |
||||
|
} |
||||
|
|
||||
|
protected static void CreateDoubleBufferedResource(RenderTexture[] resource, string name, in Vector2Int size, GraphicsFormat format, int numElements = 2) |
||||
|
{ |
||||
|
numElements = Math.Min(resource.Length, numElements); |
||||
|
for (int i = 0; i < numElements; ++i) |
||||
|
{ |
||||
|
resource[i] = new RenderTexture(size.x, size.y, 0, format) { name = name + (i + 1), enableRandomWrite = true }; |
||||
|
resource[i].Create(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected static void DestroyResource(ref Texture2D resource) |
||||
|
{ |
||||
|
if (resource == null) |
||||
|
return; |
||||
|
|
||||
|
#if UNITY_EDITOR
|
||||
|
if (Application.isPlaying && !UnityEditor.EditorApplication.isPaused) |
||||
|
UnityEngine.Object.Destroy(resource); |
||||
|
else |
||||
|
UnityEngine.Object.DestroyImmediate(resource); |
||||
|
#else
|
||||
|
UnityEngine.Object.Destroy(resource); |
||||
|
#endif
|
||||
|
resource = null; |
||||
|
} |
||||
|
|
||||
|
protected static void DestroyResource(ref RenderTexture resource) |
||||
|
{ |
||||
|
if (resource == null) |
||||
|
return; |
||||
|
|
||||
|
resource.Release(); |
||||
|
resource = null; |
||||
|
} |
||||
|
|
||||
|
protected static void DestroyResource(ref ComputeBuffer resource) |
||||
|
{ |
||||
|
if (resource == null) |
||||
|
return; |
||||
|
|
||||
|
resource.Release(); |
||||
|
resource = null; |
||||
|
} |
||||
|
|
||||
|
protected static void DestroyResource(RenderTexture[] resource) |
||||
|
{ |
||||
|
for (int i = 0; i < resource.Length; ++i) |
||||
|
DestroyResource(ref resource[i]); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 2a46b97ac72c45545a80a896462e1112 |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,46 @@ |
|||||
|
using System; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using UnityEngine; |
||||
|
|
||||
|
namespace FidelityFX |
||||
|
{ |
||||
|
public static class FfxSpd |
||||
|
{ |
||||
|
public static void SetupSpdConstants(Vector2Int resolution, ref SpdConstants spdConstants, out Vector2Int dispatchThreadGroupCount, int mips = -1) |
||||
|
{ |
||||
|
RectInt rectInfo = new RectInt(0, 0, resolution.x, resolution.y); |
||||
|
SpdSetup(rectInfo, out dispatchThreadGroupCount, out Vector2Int workGroupOffset, out Vector2Int numWorkGroupsAndMips, mips); |
||||
|
|
||||
|
spdConstants.numWorkGroups = (uint)numWorkGroupsAndMips.x; |
||||
|
spdConstants.mips = (uint)numWorkGroupsAndMips.y; |
||||
|
spdConstants.workGroupOffsetX = (uint)workGroupOffset.x; |
||||
|
spdConstants.workGroupOffsetY = (uint)workGroupOffset.y; |
||||
|
} |
||||
|
|
||||
|
public static void SpdSetup(RectInt rectInfo, out Vector2Int dispatchThreadGroupCount, out Vector2Int workGroupOffset, out Vector2Int numWorkGroupsAndMips, int mips = -1) |
||||
|
{ |
||||
|
workGroupOffset = new Vector2Int(rectInfo.x / 64, rectInfo.y / 64); |
||||
|
|
||||
|
int endIndexX = (rectInfo.x + rectInfo.width - 1) / 64; |
||||
|
int endIndexY = (rectInfo.y + rectInfo.height - 1) / 64; |
||||
|
|
||||
|
dispatchThreadGroupCount = new Vector2Int(endIndexX + 1 - workGroupOffset.x, endIndexY + 1 - workGroupOffset.y); |
||||
|
|
||||
|
numWorkGroupsAndMips = new Vector2Int(dispatchThreadGroupCount.x * dispatchThreadGroupCount.y, mips); |
||||
|
if (mips < 0) |
||||
|
{ |
||||
|
float resolution = Math.Max(rectInfo.width, rectInfo.height); |
||||
|
numWorkGroupsAndMips.y = Math.Min(Mathf.FloorToInt(Mathf.Log(resolution, 2.0f)), 12); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
[Serializable, StructLayout(LayoutKind.Sequential)] |
||||
|
public struct SpdConstants |
||||
|
{ |
||||
|
public uint mips; |
||||
|
public uint numWorkGroups; |
||||
|
public uint workGroupOffsetX; |
||||
|
public uint workGroupOffsetY; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: aee0f42dc1676ab4db5c01520b0b925a |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,118 @@ |
|||||
|
using System; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using UnityEngine; |
||||
|
using UnityEngine.Rendering; |
||||
|
|
||||
|
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)); |
||||
|
} |
||||
|
|
||||
|
public static float[] GenerateLanczos2Table(int width) |
||||
|
{ |
||||
|
float[] lanczos2Weights = new float[width]; |
||||
|
for (int currentLanczosWidthIndex = 0; currentLanczosWidthIndex < width; ++currentLanczosWidthIndex) |
||||
|
{ |
||||
|
float x = 2.0f * currentLanczosWidthIndex / (width - 1); |
||||
|
float y = Lanczos2(x); |
||||
|
lanczos2Weights[currentLanczosWidthIndex] = y; |
||||
|
} |
||||
|
|
||||
|
return lanczos2Weights; |
||||
|
} |
||||
|
|
||||
|
public static Vector4 SetupDeviceDepthToViewSpaceDepthParams(Vector2Int renderSize, float cameraNear, float cameraFar, float cameraFovAngleVertical, bool inverted, bool infinite) |
||||
|
{ |
||||
|
// make sure it has no impact if near and far plane values are swapped in dispatch params
|
||||
|
// the flags "inverted" and "infinite" will decide what transform to use
|
||||
|
float min = Mathf.Min(cameraNear, cameraFar); |
||||
|
float max = Mathf.Max(cameraNear, cameraFar); |
||||
|
|
||||
|
if (inverted) |
||||
|
{ |
||||
|
(min, max) = (max, min); |
||||
|
} |
||||
|
|
||||
|
float q = max / (min - max); |
||||
|
float d = -1.0f; |
||||
|
|
||||
|
Vector4 matrixElemC = new Vector4(q, -1.0f - Mathf.Epsilon, q, 0.0f + Mathf.Epsilon); |
||||
|
Vector4 matrixElemE = new Vector4(q * min, -min - Mathf.Epsilon, q * min, max); |
||||
|
|
||||
|
// Revert x and y coords
|
||||
|
float aspect = (float)renderSize.x / renderSize.y; |
||||
|
float cotHalfFovY = Mathf.Cos(0.5f * cameraFovAngleVertical) / Mathf.Sin(0.5f * cameraFovAngleVertical); |
||||
|
|
||||
|
int matrixIndex = (inverted ? 2 : 0) + (infinite ? 1 : 0); |
||||
|
return new Vector4( |
||||
|
d * matrixElemC[matrixIndex], |
||||
|
matrixElemE[matrixIndex], |
||||
|
aspect / cotHalfFovY, |
||||
|
1.0f / cotHalfFovY); |
||||
|
} |
||||
|
|
||||
|
#if !UNITY_2021_1_OR_NEWER
|
||||
|
internal static void SetBufferData(this CommandBuffer commandBuffer, ComputeBuffer computeBuffer, Array data) |
||||
|
{ |
||||
|
commandBuffer.SetComputeBufferData(computeBuffer, data); |
||||
|
} |
||||
|
#endif
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Alternative for CommandBuffer.SetComputeTextureParam that guards against attempts to bind mip levels that don't exist.
|
||||
|
/// </summary>
|
||||
|
internal static void SetComputeTextureMipParam(this CommandBuffer commandBuffer, ComputeShader computeShader, int kernelIndex, int nameID, Texture texture, int mipLevel) |
||||
|
{ |
||||
|
mipLevel = Math.Min(mipLevel, texture.mipmapCount - 1); |
||||
|
commandBuffer.SetComputeTextureParam(computeShader, kernelIndex, nameID, texture, mipLevel); |
||||
|
} |
||||
|
|
||||
|
internal static void SetComputeResourceParam(this CommandBuffer commandBuffer, ComputeShader computeShader, int kernelIndex, int nameID, in ResourceView resource) |
||||
|
{ |
||||
|
commandBuffer.SetComputeTextureParam(computeShader, kernelIndex, nameID, resource.RenderTarget, resource.MipLevel, resource.SubElement); |
||||
|
} |
||||
|
|
||||
|
internal static void SetComputeConstantBufferParam<TBuf>(this CommandBuffer commandBuffer, ComputeShader computeShader, int nameID, ComputeBuffer buffer) |
||||
|
where TBuf: struct |
||||
|
{ |
||||
|
commandBuffer.SetComputeConstantBufferParam(computeShader, nameID, buffer, 0, Marshal.SizeOf<TBuf>()); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 9c5c0f0b987cca64c8dfd8051e09962e |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: bd29728b817dd3f478a426dcb34e360b |
||||
|
folderAsset: yes |
||||
|
DefaultImporter: |
||||
|
externalObjects: {} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,162 @@ |
|||||
|
using System; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using UnityEngine; |
||||
|
using UnityEngine.Experimental.Rendering; |
||||
|
|
||||
|
namespace FidelityFX.FrameGen |
||||
|
{ |
||||
|
public static class FrameInterpolation |
||||
|
{ |
||||
|
public static FrameInterpolationContext CreateContext(Vector2Int displaySize, Vector2Int maxRenderSize, FrameInterpolationShaders shaders, GraphicsFormat backBufferFormat, InitializationFlags flags = 0) |
||||
|
{ |
||||
|
if (SystemInfo.usesReversedZBuffer) |
||||
|
flags |= InitializationFlags.EnableDepthInverted; |
||||
|
else |
||||
|
flags &= ~InitializationFlags.EnableDepthInverted; |
||||
|
|
||||
|
var contextDescription = new ContextDescription |
||||
|
{ |
||||
|
flags = flags, |
||||
|
maxRenderSize = maxRenderSize, |
||||
|
displaySize = displaySize, |
||||
|
backBufferFormat = backBufferFormat, |
||||
|
shaders = shaders, |
||||
|
}; |
||||
|
|
||||
|
Debug.Log($"Setting up Frame Interpolation with render size: {maxRenderSize.x}x{maxRenderSize.y}, display size: {displaySize.x}x{displaySize.y}, backbuffer format: {backBufferFormat}, flags: {flags}"); |
||||
|
|
||||
|
var context = new FrameInterpolationContext(); |
||||
|
context.Create(contextDescription); |
||||
|
return context; |
||||
|
} |
||||
|
|
||||
|
public struct ContextDescription |
||||
|
{ |
||||
|
public InitializationFlags flags; |
||||
|
public Vector2Int maxRenderSize; |
||||
|
public Vector2Int displaySize; |
||||
|
public GraphicsFormat backBufferFormat; |
||||
|
public FrameInterpolationShaders shaders; |
||||
|
} |
||||
|
|
||||
|
public struct PrepareDescription |
||||
|
{ |
||||
|
public DispatchFlags flags; |
||||
|
public Vector2Int renderSize; |
||||
|
public Vector2 jitterOffset; |
||||
|
public Vector2 motionVectorScale; |
||||
|
|
||||
|
public float frameTimeDelta; |
||||
|
public float cameraNear; |
||||
|
public float cameraFar; |
||||
|
public float viewSpaceToMetersFactor; |
||||
|
public float cameraFovAngleVertical; |
||||
|
|
||||
|
public ResourceView depth; |
||||
|
public ResourceView motionVectors; |
||||
|
public ulong frameID; |
||||
|
} |
||||
|
|
||||
|
public struct DispatchDescription |
||||
|
{ |
||||
|
public DispatchFlags flags; |
||||
|
public Vector2Int displaySize; |
||||
|
public Vector2Int renderSize; |
||||
|
public ResourceView currentBackBuffer; |
||||
|
public ResourceView currentBackBuffer_HUDLess; // Optional
|
||||
|
public ResourceView output; |
||||
|
|
||||
|
public RectInt interpolationRect; |
||||
|
|
||||
|
public ResourceView opticalFlowVector; |
||||
|
public ResourceView opticalFlowSceneChangeDetection; |
||||
|
public Vector2Int opticalFlowBufferSize; |
||||
|
public Vector2 opticalFlowScale; |
||||
|
public int opticalFlowBlockSize; |
||||
|
|
||||
|
public float cameraNear; |
||||
|
public float cameraFar; |
||||
|
public float cameraFovAngleVertical; |
||||
|
public float viewSpaceToMetersFactor; |
||||
|
|
||||
|
public float frameTimeDelta; |
||||
|
public bool reset; |
||||
|
|
||||
|
public BackbufferTransferFunction backbufferTransferFunction; |
||||
|
public Vector2 minMaxLuminance; |
||||
|
public ulong frameID; |
||||
|
|
||||
|
public ResourceView InterpolationSource |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
if (currentBackBuffer_HUDLess.IsValid) |
||||
|
return currentBackBuffer_HUDLess; |
||||
|
|
||||
|
return currentBackBuffer; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
[Flags] |
||||
|
public enum InitializationFlags |
||||
|
{ |
||||
|
EnableDepthInverted = 1 << 0, |
||||
|
EnableDepthInfinite = 1 << 1, |
||||
|
EnableHDRColorInput = 1 << 3, |
||||
|
EnableDisplayResolutionMotionVectors = 1 << 4, |
||||
|
EnableJitterMotionVectors = 1 << 5, |
||||
|
EnableAsyncSupport = 1 << 6, |
||||
|
} |
||||
|
|
||||
|
[Flags] |
||||
|
public enum DispatchFlags |
||||
|
{ |
||||
|
DrawDebugTearLines = 1 << 0, |
||||
|
DrawDebugResetIndicators = 1 << 1, |
||||
|
DrawDebugView = 1 << 2, |
||||
|
} |
||||
|
|
||||
|
[Serializable, StructLayout(LayoutKind.Sequential)] |
||||
|
internal struct Constants |
||||
|
{ |
||||
|
public Vector2Int renderSize; |
||||
|
public Vector2Int displaySize; |
||||
|
|
||||
|
public Vector2 displaySizeRcp; |
||||
|
public float cameraNear; |
||||
|
public float cameraFar; |
||||
|
|
||||
|
public Vector2Int upscalerTargetSize; |
||||
|
public int mode; |
||||
|
public int reset; |
||||
|
|
||||
|
public Vector4 deviceToViewDepth; |
||||
|
|
||||
|
public float deltaTime; |
||||
|
public int HUDLessAttachedFactor; |
||||
|
public Vector2 unused; |
||||
|
|
||||
|
public Vector2 opticalFlowScale; |
||||
|
public int opticalFlowBlockSize; |
||||
|
public uint dispatchFlags; |
||||
|
|
||||
|
public Vector2Int maxRenderSize; |
||||
|
public int opticalFlowHalfResMode; |
||||
|
public int numInstances; |
||||
|
|
||||
|
public Vector2Int interpolationRectBase; |
||||
|
public Vector2Int interpolationRectSize; |
||||
|
|
||||
|
public Vector3 debugBarColor; |
||||
|
public uint backBufferTransferFunction; |
||||
|
|
||||
|
public Vector2 minMaxLuminance; |
||||
|
public float tanHalfFOV; |
||||
|
public float pad; |
||||
|
|
||||
|
public Vector2 jitter; |
||||
|
public Vector2 motionVectorScale; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 463b39d7227b18b40946829a3c68a462 |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,176 @@ |
|||||
|
// Copyright (c) 2024 Nico de Poel
|
||||
|
//
|
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
// in the Software without restriction, including without limitation the rights
|
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||
|
// furnished to do so, subject to the following conditions:
|
||||
|
//
|
||||
|
// The above copyright notice and this permission notice shall be included in all
|
||||
|
// copies or substantial portions of the Software.
|
||||
|
//
|
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
|
// THE SOFTWARE.
|
||||
|
|
||||
|
using UnityEngine; |
||||
|
|
||||
|
namespace FidelityFX.FrameGen |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Scriptable object containing all shader resources required by FidelityFX Frame Interpolation.
|
||||
|
/// These can be stored in an asset file and referenced from a scene or prefab, avoiding the need to load the shaders from a Resources folder.
|
||||
|
/// </summary>
|
||||
|
[CreateAssetMenu(fileName = "Frame Interpolation Assets", menuName = "FidelityFX/Frame Interpolation Assets", order = 1112)] |
||||
|
public class FrameInterpolationAssets : ScriptableObject |
||||
|
{ |
||||
|
public FrameInterpolationShaders shaders; |
||||
|
|
||||
|
#if UNITY_EDITOR
|
||||
|
private void Reset() |
||||
|
{ |
||||
|
shaders = new FrameInterpolationShaders |
||||
|
{ |
||||
|
reconstructAndDilate = FindComputeShader("ffx_frameinterpolation_reconstruct_and_dilate_pass"), |
||||
|
setup = FindComputeShader("ffx_frameinterpolation_setup_pass"), |
||||
|
reconstructPreviousDepth = FindComputeShader("ffx_frameinterpolation_reconstruct_previous_depth_pass"), |
||||
|
gameMotionVectorField = FindComputeShader("ffx_frameinterpolation_game_motion_vector_field_pass"), |
||||
|
opticalFlowVectorField = FindComputeShader("ffx_frameinterpolation_optical_flow_vector_field_pass"), |
||||
|
disocclusionMask = FindComputeShader("ffx_frameinterpolation_disocclusion_mask_pass"), |
||||
|
interpolation = FindComputeShader("ffx_frameinterpolation_pass"), |
||||
|
inpaintingPyramid = FindComputeShader("ffx_frameinterpolation_compute_inpainting_pyramid_pass"), |
||||
|
inpainting = FindComputeShader("ffx_frameinterpolation_inpainting_pass"), |
||||
|
gameVectorFieldInpaintingPyramid = FindComputeShader("ffx_frameinterpolation_compute_game_vector_field_inpainting_pyramid_pass"), |
||||
|
debugView = FindComputeShader("ffx_frameinterpolation_debug_view_pass"), |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
private static ComputeShader FindComputeShader(string name) |
||||
|
{ |
||||
|
string[] assetGuids = UnityEditor.AssetDatabase.FindAssets($"t:ComputeShader {name}"); |
||||
|
if (assetGuids == null || assetGuids.Length == 0) |
||||
|
return null; |
||||
|
|
||||
|
string assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(assetGuids[0]); |
||||
|
return UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>(assetPath); |
||||
|
} |
||||
|
#endif
|
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// All the compute shaders used by Frame Interpolation.
|
||||
|
/// </summary>
|
||||
|
[System.Serializable] |
||||
|
public class FrameInterpolationShaders |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// The compute shader used by the reconstruct and dilate pass.
|
||||
|
/// </summary>
|
||||
|
public ComputeShader reconstructAndDilate; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The compute shader used by the setup pass.
|
||||
|
/// </summary>
|
||||
|
public ComputeShader setup; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The compute shader used by the reconstruct previous depth pass.
|
||||
|
/// </summary>
|
||||
|
public ComputeShader reconstructPreviousDepth; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The compute shader used by the game motion vector field pass.
|
||||
|
/// </summary>
|
||||
|
public ComputeShader gameMotionVectorField; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The compute shader used by the optical flow vector field pass.
|
||||
|
/// </summary>
|
||||
|
public ComputeShader opticalFlowVectorField; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The compute shader used by the disocclusion mask pass.
|
||||
|
/// </summary>
|
||||
|
public ComputeShader disocclusionMask; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The compute shader used by the interpolation pass.
|
||||
|
/// </summary>
|
||||
|
public ComputeShader interpolation; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The compute shader used by the inpainting pyramid pass.
|
||||
|
/// </summary>
|
||||
|
public ComputeShader inpaintingPyramid; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The compute shader used by the inpainting pass.
|
||||
|
/// </summary>
|
||||
|
public ComputeShader inpainting; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The compute shader used by the game vector field inpainting pyramid pass.
|
||||
|
/// </summary>
|
||||
|
public ComputeShader gameVectorFieldInpaintingPyramid; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The compute shader used by the debug view pass.
|
||||
|
/// </summary>
|
||||
|
public ComputeShader debugView; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Returns a copy of this class and its contents.
|
||||
|
/// </summary>
|
||||
|
public FrameInterpolationShaders Clone() |
||||
|
{ |
||||
|
return (FrameInterpolationShaders)MemberwiseClone(); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Returns a copy of this class with clones of all its shaders.
|
||||
|
/// This can be useful if you're running multiple Frame Interpolation instances with different shader configurations.
|
||||
|
/// Be sure to clean up these clones through Dispose once you're done with them.
|
||||
|
/// </summary>
|
||||
|
public FrameInterpolationShaders DeepCopy() |
||||
|
{ |
||||
|
return new FrameInterpolationShaders |
||||
|
{ |
||||
|
reconstructAndDilate = Object.Instantiate(reconstructAndDilate), |
||||
|
setup = Object.Instantiate(setup), |
||||
|
reconstructPreviousDepth = Object.Instantiate(reconstructPreviousDepth), |
||||
|
gameMotionVectorField = Object.Instantiate(gameMotionVectorField), |
||||
|
opticalFlowVectorField = Object.Instantiate(opticalFlowVectorField), |
||||
|
disocclusionMask = Object.Instantiate(disocclusionMask), |
||||
|
interpolation = Object.Instantiate(interpolation), |
||||
|
inpaintingPyramid = Object.Instantiate(inpaintingPyramid), |
||||
|
inpainting = Object.Instantiate(inpainting), |
||||
|
gameVectorFieldInpaintingPyramid = Object.Instantiate(gameVectorFieldInpaintingPyramid), |
||||
|
debugView = Object.Instantiate(debugView), |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Destroy all the shaders within this instance.
|
||||
|
/// Use this only on clones created through DeepCopy.
|
||||
|
/// </summary>
|
||||
|
public void Dispose() |
||||
|
{ |
||||
|
Object.Destroy(debugView); |
||||
|
Object.Destroy(gameVectorFieldInpaintingPyramid); |
||||
|
Object.Destroy(inpainting); |
||||
|
Object.Destroy(inpaintingPyramid); |
||||
|
Object.Destroy(interpolation); |
||||
|
Object.Destroy(disocclusionMask); |
||||
|
Object.Destroy(opticalFlowVectorField); |
||||
|
Object.Destroy(gameMotionVectorField); |
||||
|
Object.Destroy(reconstructPreviousDepth); |
||||
|
Object.Destroy(setup); |
||||
|
Object.Destroy(reconstructAndDilate); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 1f0e52bd03044d74f8e7ea17af3c8d7b |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,260 @@ |
|||||
|
using System; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using UnityEngine; |
||||
|
using UnityEngine.Assertions; |
||||
|
using UnityEngine.Profiling; |
||||
|
using UnityEngine.Rendering; |
||||
|
|
||||
|
namespace FidelityFX.FrameGen |
||||
|
{ |
||||
|
public class FrameInterpolationContext: FfxContextBase |
||||
|
{ |
||||
|
private FrameInterpolation.ContextDescription _contextDescription; |
||||
|
|
||||
|
private FrameInterpolationReconstructAndDilatePass _reconstructAndDilatePass; |
||||
|
private FrameInterpolationSetupPass _setupPass; |
||||
|
private FrameInterpolationReconstructPreviousDepthPass _reconstructPreviousDepthPass; |
||||
|
private FrameInterpolationGameMotionVectorFieldPass _gameMotionVectorFieldPass; |
||||
|
private FrameInterpolationOpticalFlowVectorFieldPass _opticalFlowVectorFieldPass; |
||||
|
private FrameInterpolationDisocclusionMaskPass _disocclusionMaskPass; |
||||
|
private FrameInterpolationInterpolationPass _interpolationPass; |
||||
|
private FrameInterpolationInpaintingPyramidPass _inpaintingPyramidPass; |
||||
|
private FrameInterpolationInpaintingPass _inpaintingPass; |
||||
|
private FrameInterpolationGameVectorFieldInpaintingPyramidPass _gameVectorFieldInpaintingPyramidPass; |
||||
|
private FrameInterpolationDebugViewPass _debugViewPass; |
||||
|
|
||||
|
private readonly FrameInterpolationResources _resources = new FrameInterpolationResources(); |
||||
|
|
||||
|
private readonly ConstantsBuffer<FrameInterpolation.Constants> _frameInterpolationConstants = new ConstantsBuffer<FrameInterpolation.Constants>(); |
||||
|
private readonly ConstantsBuffer<FfxSpd.SpdConstants> _spdConstants = new ConstantsBuffer<FfxSpd.SpdConstants>(); |
||||
|
|
||||
|
private readonly CustomSampler _sampler = CustomSampler.Create("Frame Interpolation"); |
||||
|
private readonly CustomSampler _prepareSampler = CustomSampler.Create("Frame Interpolation - Prepare"); |
||||
|
|
||||
|
private bool _firstExecution; |
||||
|
private bool _asyncSupported; |
||||
|
private ulong _previousFrameID; |
||||
|
|
||||
|
public void Create(in FrameInterpolation.ContextDescription contextDescription) |
||||
|
{ |
||||
|
_contextDescription = contextDescription; |
||||
|
|
||||
|
_frameInterpolationConstants.Create(); |
||||
|
_spdConstants.Create(); |
||||
|
|
||||
|
_firstExecution = true; |
||||
|
_previousFrameID = 0; |
||||
|
_asyncSupported = (_contextDescription.flags & FrameInterpolation.InitializationFlags.EnableAsyncSupport) == FrameInterpolation.InitializationFlags.EnableAsyncSupport; |
||||
|
|
||||
|
ref var constants = ref _frameInterpolationConstants.Value; |
||||
|
constants.maxRenderSize = _contextDescription.maxRenderSize; |
||||
|
constants.displaySize = _contextDescription.displaySize; |
||||
|
constants.displaySizeRcp.x = 1.0f / _contextDescription.displaySize.x; |
||||
|
constants.displaySizeRcp.y = 1.0f / _contextDescription.displaySize.y; |
||||
|
constants.interpolationRectBase = Vector2Int.zero; |
||||
|
constants.interpolationRectSize = _contextDescription.displaySize; |
||||
|
|
||||
|
_resources.Create(_contextDescription); |
||||
|
CreatePasses(); |
||||
|
} |
||||
|
|
||||
|
private void CreatePasses() |
||||
|
{ |
||||
|
_reconstructAndDilatePass = new FrameInterpolationReconstructAndDilatePass(_contextDescription, _resources, _frameInterpolationConstants); |
||||
|
_setupPass = new FrameInterpolationSetupPass(_contextDescription, _resources, _frameInterpolationConstants); |
||||
|
_reconstructPreviousDepthPass = new FrameInterpolationReconstructPreviousDepthPass(_contextDescription, _resources, _frameInterpolationConstants); |
||||
|
_gameMotionVectorFieldPass = new FrameInterpolationGameMotionVectorFieldPass(_contextDescription, _resources, _frameInterpolationConstants); |
||||
|
_opticalFlowVectorFieldPass = new FrameInterpolationOpticalFlowVectorFieldPass(_contextDescription, _resources, _frameInterpolationConstants); |
||||
|
_disocclusionMaskPass = new FrameInterpolationDisocclusionMaskPass(_contextDescription, _resources, _frameInterpolationConstants); |
||||
|
_interpolationPass = new FrameInterpolationInterpolationPass(_contextDescription, _resources, _frameInterpolationConstants); |
||||
|
_inpaintingPyramidPass = new FrameInterpolationInpaintingPyramidPass(_contextDescription, _resources, _frameInterpolationConstants, _spdConstants); |
||||
|
_inpaintingPass = new FrameInterpolationInpaintingPass(_contextDescription, _resources, _frameInterpolationConstants); |
||||
|
_gameVectorFieldInpaintingPyramidPass = new FrameInterpolationGameVectorFieldInpaintingPyramidPass(_contextDescription, _resources, _frameInterpolationConstants, _spdConstants); |
||||
|
_debugViewPass = new FrameInterpolationDebugViewPass(_contextDescription, _resources, _frameInterpolationConstants); |
||||
|
} |
||||
|
|
||||
|
public void Destroy() |
||||
|
{ |
||||
|
DestroyPass(ref _debugViewPass); |
||||
|
DestroyPass(ref _gameVectorFieldInpaintingPyramidPass); |
||||
|
DestroyPass(ref _inpaintingPass); |
||||
|
DestroyPass(ref _inpaintingPyramidPass); |
||||
|
DestroyPass(ref _interpolationPass); |
||||
|
DestroyPass(ref _disocclusionMaskPass); |
||||
|
DestroyPass(ref _opticalFlowVectorFieldPass); |
||||
|
DestroyPass(ref _gameMotionVectorFieldPass); |
||||
|
DestroyPass(ref _reconstructPreviousDepthPass); |
||||
|
DestroyPass(ref _setupPass); |
||||
|
DestroyPass(ref _reconstructAndDilatePass); |
||||
|
|
||||
|
_resources.Destroy(); |
||||
|
|
||||
|
_spdConstants.Destroy(); |
||||
|
_frameInterpolationConstants.Destroy(); |
||||
|
} |
||||
|
|
||||
|
public void Prepare(CommandBuffer commandBuffer, in FrameInterpolation.PrepareDescription prepareDescription) |
||||
|
{ |
||||
|
commandBuffer.BeginSample(_prepareSampler); |
||||
|
|
||||
|
int doubleBufferId = _asyncSupported ? (int)(prepareDescription.frameID & 1) : 0; |
||||
|
|
||||
|
ref var constants = ref _frameInterpolationConstants.Value; |
||||
|
constants.renderSize = prepareDescription.renderSize; |
||||
|
constants.jitter = prepareDescription.jitterOffset; |
||||
|
Vector2Int motionVectorsTargetSize = (_contextDescription.flags & FrameInterpolation.InitializationFlags.EnableDisplayResolutionMotionVectors) != 0 ? constants.displaySize : constants.renderSize; |
||||
|
constants.motionVectorScale.x = prepareDescription.motionVectorScale.x / motionVectorsTargetSize.x; |
||||
|
constants.motionVectorScale.y = prepareDescription.motionVectorScale.y / motionVectorsTargetSize.y; |
||||
|
|
||||
|
_frameInterpolationConstants.UpdateBufferData(commandBuffer); |
||||
|
|
||||
|
Assert.IsTrue(prepareDescription.depth.IsValid); |
||||
|
Assert.IsTrue(prepareDescription.motionVectors.IsValid); |
||||
|
|
||||
|
// clear estimated depth resources
|
||||
|
{ |
||||
|
bool inverted = (_contextDescription.flags & FrameInterpolation.InitializationFlags.EnableDepthInverted) == FrameInterpolation.InitializationFlags.EnableDepthInverted; |
||||
|
commandBuffer.SetRenderTarget(_resources.ReconstructedDepth[doubleBufferId]); |
||||
|
commandBuffer.ClearRenderTarget(false, true, inverted ? Color.clear : Color.white); |
||||
|
} |
||||
|
|
||||
|
int renderDispatchSizeX = (prepareDescription.renderSize.x + 7) / 8; |
||||
|
int renderDispatchSizeY = (prepareDescription.renderSize.y + 7) / 8; |
||||
|
_reconstructAndDilatePass.ScheduleDispatch(commandBuffer, prepareDescription, doubleBufferId, renderDispatchSizeX, renderDispatchSizeY); |
||||
|
|
||||
|
commandBuffer.EndSample(_prepareSampler); |
||||
|
} |
||||
|
|
||||
|
public void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchDescription) |
||||
|
{ |
||||
|
commandBuffer.BeginSample(_sampler); |
||||
|
|
||||
|
bool reset = _firstExecution || dispatchDescription.reset; |
||||
|
_firstExecution = false; |
||||
|
Assert.IsTrue(!_asyncSupported || reset || dispatchDescription.frameID > _previousFrameID, |
||||
|
"When async support is enabled, and the reset flag is not set, frame ID must increment in each dispatch."); |
||||
|
|
||||
|
bool frameIdDecreased = dispatchDescription.frameID < _previousFrameID; |
||||
|
bool frameIdSkipped = (dispatchDescription.frameID - _previousFrameID) > 1; |
||||
|
bool disjointFrameId = frameIdDecreased || frameIdSkipped; |
||||
|
_previousFrameID = dispatchDescription.frameID; |
||||
|
|
||||
|
ref var constants = ref _frameInterpolationConstants.Value; |
||||
|
constants.renderSize = dispatchDescription.renderSize; |
||||
|
constants.displaySize = dispatchDescription.displaySize; |
||||
|
constants.displaySizeRcp.x = 1.0f / dispatchDescription.displaySize.x; |
||||
|
constants.displaySizeRcp.y = 1.0f / dispatchDescription.displaySize.y; |
||||
|
constants.upscalerTargetSize = dispatchDescription.interpolationRect.size; |
||||
|
constants.mode = 0; |
||||
|
constants.reset = (reset || disjointFrameId) ? 1 : 0; |
||||
|
constants.deltaTime = dispatchDescription.frameTimeDelta; |
||||
|
constants.HUDLessAttachedFactor = dispatchDescription.currentBackBuffer_HUDLess.IsValid ? 1 : 0; |
||||
|
|
||||
|
constants.opticalFlowScale = dispatchDescription.opticalFlowScale; |
||||
|
constants.opticalFlowBlockSize = dispatchDescription.opticalFlowBlockSize; |
||||
|
constants.dispatchFlags = (uint)dispatchDescription.flags; |
||||
|
|
||||
|
constants.cameraNear = dispatchDescription.cameraNear; |
||||
|
constants.cameraFar = dispatchDescription.cameraFar; |
||||
|
|
||||
|
constants.interpolationRectBase = dispatchDescription.interpolationRect.position; |
||||
|
constants.interpolationRectSize = dispatchDescription.interpolationRect.size; |
||||
|
|
||||
|
// Debug bar
|
||||
|
constants.debugBarColor.x = DebugBarColorSequence[_debugIndex * 3 + 0]; |
||||
|
constants.debugBarColor.y = DebugBarColorSequence[_debugIndex * 3 + 1]; |
||||
|
constants.debugBarColor.z = DebugBarColorSequence[_debugIndex * 3 + 2]; |
||||
|
_debugIndex = (_debugIndex + 1) % (DebugBarColorSequence.Length / 3); |
||||
|
|
||||
|
constants.backBufferTransferFunction = (uint)dispatchDescription.backbufferTransferFunction; |
||||
|
constants.minMaxLuminance = dispatchDescription.minMaxLuminance; |
||||
|
|
||||
|
float aspectRatio = dispatchDescription.renderSize.x / (float)dispatchDescription.renderSize.y; |
||||
|
float cameraAngleHorizontal = Mathf.Atan(Mathf.Tan(dispatchDescription.cameraFovAngleVertical / 2) * aspectRatio) * 2; |
||||
|
constants.tanHalfFOV = Mathf.Tan(cameraAngleHorizontal * 0.5f); |
||||
|
|
||||
|
bool inverted = (_contextDescription.flags & FrameInterpolation.InitializationFlags.EnableDepthInverted) != 0; |
||||
|
bool infinite = (_contextDescription.flags & FrameInterpolation.InitializationFlags.EnableDepthInfinite) != 0; |
||||
|
constants.deviceToViewDepth = FfxUtils.SetupDeviceDepthToViewSpaceDepthParams( |
||||
|
dispatchDescription.renderSize, dispatchDescription.cameraNear, dispatchDescription.cameraFar, dispatchDescription.cameraFovAngleVertical, inverted, infinite); |
||||
|
|
||||
|
_frameInterpolationConstants.UpdateBufferData(commandBuffer); |
||||
|
|
||||
|
int doubleBufferId = _asyncSupported ? (int)(dispatchDescription.frameID & 1) : 0; |
||||
|
|
||||
|
int displayDispatchSizeX = (dispatchDescription.displaySize.x + 7) / 8; |
||||
|
int displayDispatchSizeY = (dispatchDescription.displaySize.y + 7) / 8; |
||||
|
|
||||
|
int renderDispatchSizeX = (dispatchDescription.renderSize.x + 7) / 8; |
||||
|
int renderDispatchSizeY = (dispatchDescription.renderSize.y + 7) / 8; |
||||
|
|
||||
|
int opticalFlowDispatchSizeX = (int)(dispatchDescription.displaySize.x / (float)dispatchDescription.opticalFlowBlockSize + 7) / 8; |
||||
|
int opticalFlowDispatchSizeY = (int)(dispatchDescription.displaySize.y / (float)dispatchDescription.opticalFlowBlockSize + 7) / 8; |
||||
|
|
||||
|
bool executePreparationPasses = (constants.reset == 0); |
||||
|
|
||||
|
// Schedule work for the interpolation command list
|
||||
|
_setupPass.ScheduleDispatch(commandBuffer, dispatchDescription, doubleBufferId, renderDispatchSizeX, renderDispatchSizeY); |
||||
|
|
||||
|
// Only execute FG data preparation passes when reset wasn't triggered
|
||||
|
if (executePreparationPasses) |
||||
|
{ |
||||
|
// Clear estimated depth resources
|
||||
|
commandBuffer.SetRenderTarget(_resources.ReconstructedDepthInterpolatedFrame); |
||||
|
commandBuffer.ClearRenderTarget(false, true, inverted ? Color.clear : Color.white); |
||||
|
|
||||
|
_reconstructPreviousDepthPass.ScheduleDispatch(commandBuffer, dispatchDescription, doubleBufferId, renderDispatchSizeX, renderDispatchSizeY); |
||||
|
_gameMotionVectorFieldPass.ScheduleDispatch(commandBuffer, dispatchDescription, doubleBufferId, renderDispatchSizeX, renderDispatchSizeY); |
||||
|
DispatchGameVectorFieldInpaintingPyramid(commandBuffer, dispatchDescription, doubleBufferId); |
||||
|
_opticalFlowVectorFieldPass.ScheduleDispatch(commandBuffer, dispatchDescription, doubleBufferId, opticalFlowDispatchSizeX, opticalFlowDispatchSizeY); |
||||
|
_disocclusionMaskPass.ScheduleDispatch(commandBuffer, dispatchDescription, doubleBufferId, renderDispatchSizeX, renderDispatchSizeY); |
||||
|
} |
||||
|
|
||||
|
_interpolationPass.ScheduleDispatch(commandBuffer, dispatchDescription, doubleBufferId, displayDispatchSizeX, displayDispatchSizeY); |
||||
|
|
||||
|
// Inpainting pyramid
|
||||
|
SetupSpdConstants(dispatchDescription.displaySize, out var dispatchThreadGroupCount); |
||||
|
_spdConstants.UpdateBufferData(commandBuffer); |
||||
|
_inpaintingPyramidPass.ScheduleDispatch(commandBuffer, dispatchDescription, doubleBufferId, dispatchThreadGroupCount.x, dispatchThreadGroupCount.y); |
||||
|
|
||||
|
_inpaintingPass.ScheduleDispatch(commandBuffer, dispatchDescription, doubleBufferId, displayDispatchSizeX, displayDispatchSizeY); |
||||
|
|
||||
|
if ((dispatchDescription.flags & FrameInterpolation.DispatchFlags.DrawDebugView) != 0) |
||||
|
{ |
||||
|
DispatchGameVectorFieldInpaintingPyramid(commandBuffer, dispatchDescription, doubleBufferId); |
||||
|
_debugViewPass.ScheduleDispatch(commandBuffer, dispatchDescription, doubleBufferId, displayDispatchSizeX, displayDispatchSizeY); |
||||
|
} |
||||
|
|
||||
|
// Store current buffer
|
||||
|
commandBuffer.CopyTexture(dispatchDescription.InterpolationSource.RenderTarget, _resources.PreviousInterpolationSource); |
||||
|
|
||||
|
commandBuffer.EndSample(_sampler); |
||||
|
} |
||||
|
|
||||
|
private void DispatchGameVectorFieldInpaintingPyramid(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchDescription, int doubleBufferId) |
||||
|
{ |
||||
|
SetupSpdConstants(dispatchDescription.renderSize, out var dispatchThreadGroupCount); |
||||
|
_spdConstants.UpdateBufferData(commandBuffer); |
||||
|
_gameVectorFieldInpaintingPyramidPass.ScheduleDispatch(commandBuffer, dispatchDescription, doubleBufferId, dispatchThreadGroupCount.x, dispatchThreadGroupCount.y); |
||||
|
} |
||||
|
|
||||
|
private void SetupSpdConstants(Vector2Int resolution, out Vector2Int dispatchThreadGroupCount) |
||||
|
{ |
||||
|
ref var spdConstants = ref _spdConstants.Value; |
||||
|
FfxSpd.SetupSpdConstants(resolution, ref spdConstants, out dispatchThreadGroupCount); |
||||
|
spdConstants.mips = Math.Min(spdConstants.mips, 7); |
||||
|
} |
||||
|
|
||||
|
private int _debugIndex = 0; |
||||
|
private static readonly float[] DebugBarColorSequence = |
||||
|
{ |
||||
|
0.0f, 1.0f, 1.0f, // teal
|
||||
|
1.0f, 0.42f, 0.0f, // orange
|
||||
|
0.0f, 0.16f, 1.0f, // blue
|
||||
|
0.74f, 1.0f, 0.0f, // lime
|
||||
|
0.68f, 0.0f, 1.0f, // purple
|
||||
|
0.0f, 1.0f, 0.1f, // green
|
||||
|
1.0f, 1.0f, 0.48f // bright yellow
|
||||
|
}; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: e5dd3cf3772023443982f14a66852110 |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,333 @@ |
|||||
|
using UnityEngine; |
||||
|
using UnityEngine.Rendering; |
||||
|
|
||||
|
namespace FidelityFX.FrameGen |
||||
|
{ |
||||
|
internal abstract class FrameInterpolationPass: FfxPassWithFlags<FrameInterpolation.InitializationFlags> |
||||
|
{ |
||||
|
protected readonly FrameInterpolationResources Resources; |
||||
|
protected readonly ComputeBuffer Constants; |
||||
|
|
||||
|
protected FrameInterpolationPass(in FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants) |
||||
|
: base("Frame Interpolation", contextDescription.flags) |
||||
|
{ |
||||
|
Resources = resources; |
||||
|
Constants = constants; |
||||
|
} |
||||
|
|
||||
|
public void ScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ = 1) |
||||
|
{ |
||||
|
using (ProfilerSample(commandBuffer)) |
||||
|
{ |
||||
|
Dispatch(commandBuffer, dispatchParams, frameIndex, dispatchX, dispatchY, dispatchZ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected abstract void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ); |
||||
|
|
||||
|
protected override void SetupShaderKeywords() |
||||
|
{ |
||||
|
if ((Flags & FrameInterpolation.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0) ComputeShader.EnableKeyword("FFX_FRAMEINTERPOLATION_OPTION_LOW_RES_MOTION_VECTORS"); |
||||
|
if ((Flags & FrameInterpolation.InitializationFlags.EnableJitterMotionVectors) != 0) ComputeShader.EnableKeyword("FFX_FRAMEINTERPOLATION_OPTION_JITTERED_MOTION_VECTORS"); |
||||
|
if ((Flags & FrameInterpolation.InitializationFlags.EnableDepthInverted) != 0) ComputeShader.EnableKeyword("FFX_FRAMEINTERPOLATION_OPTION_INVERTED_DEPTH"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
internal sealed class FrameInterpolationReconstructAndDilatePass : FrameInterpolationPass |
||||
|
{ |
||||
|
public FrameInterpolationReconstructAndDilatePass(in FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants) |
||||
|
: base(contextDescription, resources, constants) |
||||
|
{ |
||||
|
InitComputeShader("Reconstruct and Dilate", contextDescription.shaders.reconstructAndDilate); |
||||
|
} |
||||
|
|
||||
|
protected override void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public void ScheduleDispatch(CommandBuffer commandBuffer, FrameInterpolation.PrepareDescription prepareParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ = 1) |
||||
|
{ |
||||
|
using (ProfilerSample(commandBuffer)) |
||||
|
{ |
||||
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvInputMotionVectors, prepareParams.motionVectors); |
||||
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvInputDepth, prepareParams.depth); |
||||
|
|
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavReconstructedDepthPreviousFrame, Resources.ReconstructedDepth[frameIndex]); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavDilatedDepth, Resources.DilatedDepth[frameIndex]); |
||||
|
|
||||
|
commandBuffer.SetComputeConstantBufferParam<FrameInterpolation.Constants>(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants); |
||||
|
|
||||
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
internal sealed class FrameInterpolationSetupPass : FrameInterpolationPass |
||||
|
{ |
||||
|
public FrameInterpolationSetupPass(in FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants) |
||||
|
: base(contextDescription, resources, constants) |
||||
|
{ |
||||
|
InitComputeShader("Setup", contextDescription.shaders.setup); |
||||
|
} |
||||
|
|
||||
|
protected override void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
||||
|
{ |
||||
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowSceneChangeDetection, dispatchParams.opticalFlowSceneChangeDetection); |
||||
|
|
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavGameMotionVectorFieldX, Resources.GameMotionVectorFieldX); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavGameMotionVectorFieldY, Resources.GameMotionVectorFieldY); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavOpticalFlowMotionVectorFieldX, Resources.OpticalFlowMotionVectorFieldX); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavOpticalFlowMotionVectorFieldY, Resources.OpticalFlowMotionVectorFieldY); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavDisocclusionMask, Resources.DisocclusionMask); |
||||
|
commandBuffer.SetComputeBufferParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavCounters, Resources.Counters); |
||||
|
|
||||
|
commandBuffer.SetComputeConstantBufferParam<FrameInterpolation.Constants>(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants); |
||||
|
|
||||
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
internal sealed class FrameInterpolationReconstructPreviousDepthPass : FrameInterpolationPass |
||||
|
{ |
||||
|
public FrameInterpolationReconstructPreviousDepthPass(in FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants) |
||||
|
: base(contextDescription, resources, constants) |
||||
|
{ |
||||
|
InitComputeShader("Reconstruct Previous Depth", contextDescription.shaders.reconstructPreviousDepth); |
||||
|
} |
||||
|
|
||||
|
protected override void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
||||
|
{ |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDilatedDepth, Resources.DilatedDepth[frameIndex]); |
||||
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvCurrentInterpolationSource, dispatchParams.InterpolationSource); |
||||
|
|
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavReconstructedDepthInterpolatedFrame, Resources.ReconstructedDepthInterpolatedFrame); |
||||
|
|
||||
|
commandBuffer.SetComputeConstantBufferParam<FrameInterpolation.Constants>(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants); |
||||
|
|
||||
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
internal sealed class FrameInterpolationGameMotionVectorFieldPass : FrameInterpolationPass |
||||
|
{ |
||||
|
public FrameInterpolationGameMotionVectorFieldPass(in FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants) |
||||
|
: base(contextDescription, resources, constants) |
||||
|
{ |
||||
|
InitComputeShader("Game Motion Vector Field", contextDescription.shaders.gameMotionVectorField); |
||||
|
} |
||||
|
|
||||
|
protected override void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
||||
|
{ |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDilatedDepth, Resources.DilatedDepth[frameIndex]); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvPreviousInterpolationSource, Resources.PreviousInterpolationSource); |
||||
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvCurrentInterpolationSource, dispatchParams.InterpolationSource); |
||||
|
|
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavGameMotionVectorFieldX, Resources.GameMotionVectorFieldX); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavGameMotionVectorFieldY, Resources.GameMotionVectorFieldY); |
||||
|
|
||||
|
commandBuffer.SetComputeConstantBufferParam<FrameInterpolation.Constants>(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants); |
||||
|
|
||||
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
internal sealed class FrameInterpolationOpticalFlowVectorFieldPass : FrameInterpolationPass |
||||
|
{ |
||||
|
public FrameInterpolationOpticalFlowVectorFieldPass(in FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants) |
||||
|
: base(contextDescription, resources, constants) |
||||
|
{ |
||||
|
InitComputeShader("Optical Flow Vector Field", contextDescription.shaders.opticalFlowVectorField); |
||||
|
} |
||||
|
|
||||
|
protected override void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
||||
|
{ |
||||
|
if (dispatchParams.opticalFlowScale.x > 0f) |
||||
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowVector, dispatchParams.opticalFlowVector); |
||||
|
else |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowVector, BuiltinRenderTextureType.None); |
||||
|
|
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowConfidence, BuiltinRenderTextureType.None); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDilatedDepth, Resources.DilatedDepth[frameIndex]); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvPreviousInterpolationSource, Resources.PreviousInterpolationSource); |
||||
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvCurrentInterpolationSource, dispatchParams.InterpolationSource); |
||||
|
|
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavOpticalFlowMotionVectorFieldX, Resources.OpticalFlowMotionVectorFieldX); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavOpticalFlowMotionVectorFieldY, Resources.OpticalFlowMotionVectorFieldY); |
||||
|
|
||||
|
commandBuffer.SetComputeConstantBufferParam<FrameInterpolation.Constants>(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants); |
||||
|
|
||||
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
internal sealed class FrameInterpolationDisocclusionMaskPass : FrameInterpolationPass |
||||
|
{ |
||||
|
public FrameInterpolationDisocclusionMaskPass(in FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants) |
||||
|
: base(contextDescription, resources, constants) |
||||
|
{ |
||||
|
InitComputeShader("Disocclusion Mask", contextDescription.shaders.disocclusionMask); |
||||
|
} |
||||
|
|
||||
|
protected override void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
||||
|
{ |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldX, Resources.GameMotionVectorFieldX); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldY, Resources.GameMotionVectorFieldY); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvReconstructedDepthPreviousFrame, Resources.ReconstructedDepth[frameIndex]); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDilatedDepth, Resources.DilatedDepth[frameIndex]); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvReconstructedDepthInterpolatedFrame, Resources.ReconstructedDepthInterpolatedFrame); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvInpaintingPyramid, Resources.InpaintingPyramid); |
||||
|
|
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavDisocclusionMask, Resources.DisocclusionMask); |
||||
|
|
||||
|
commandBuffer.SetComputeConstantBufferParam<FrameInterpolation.Constants>(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants); |
||||
|
|
||||
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
internal sealed class FrameInterpolationInterpolationPass : FrameInterpolationPass |
||||
|
{ |
||||
|
public FrameInterpolationInterpolationPass(in FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants) |
||||
|
: base(contextDescription, resources, constants) |
||||
|
{ |
||||
|
InitComputeShader("Interpolation", contextDescription.shaders.interpolation); |
||||
|
} |
||||
|
|
||||
|
protected override void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
||||
|
{ |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldX, Resources.GameMotionVectorFieldX); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldY, Resources.GameMotionVectorFieldY); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowMotionVectorFieldX, Resources.OpticalFlowMotionVectorFieldX); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowMotionVectorFieldY, Resources.OpticalFlowMotionVectorFieldY); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvPreviousInterpolationSource, Resources.PreviousInterpolationSource); |
||||
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvCurrentInterpolationSource, dispatchParams.InterpolationSource); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDisocclusionMask, Resources.DisocclusionMask); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvInpaintingPyramid, Resources.InpaintingPyramid); |
||||
|
commandBuffer.SetComputeBufferParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvCounters, Resources.Counters); |
||||
|
|
||||
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavOutput, dispatchParams.output); |
||||
|
|
||||
|
commandBuffer.SetComputeConstantBufferParam<FrameInterpolation.Constants>(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants); |
||||
|
|
||||
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
internal sealed class FrameInterpolationInpaintingPyramidPass : FrameInterpolationPass |
||||
|
{ |
||||
|
private readonly ComputeBuffer _spdConstants; |
||||
|
|
||||
|
public FrameInterpolationInpaintingPyramidPass(in FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants, ComputeBuffer spdConstants) |
||||
|
: base(contextDescription, resources, constants) |
||||
|
{ |
||||
|
_spdConstants = spdConstants; |
||||
|
|
||||
|
InitComputeShader("Inpainting Pyramid", contextDescription.shaders.inpaintingPyramid); |
||||
|
} |
||||
|
|
||||
|
protected override void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
||||
|
{ |
||||
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOutput, dispatchParams.output); |
||||
|
|
||||
|
commandBuffer.SetComputeBufferParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavCounters, Resources.Counters); |
||||
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap0, Resources.InpaintingPyramid, 0); |
||||
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap1, Resources.InpaintingPyramid, 1); |
||||
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap2, Resources.InpaintingPyramid, 2); |
||||
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap3, Resources.InpaintingPyramid, 3); |
||||
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap4, Resources.InpaintingPyramid, 4); |
||||
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap5, Resources.InpaintingPyramid, 5); |
||||
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap6, Resources.InpaintingPyramid, 6); |
||||
|
|
||||
|
commandBuffer.SetComputeConstantBufferParam<FrameInterpolation.Constants>(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants); |
||||
|
commandBuffer.SetComputeConstantBufferParam<FfxSpd.SpdConstants>(ComputeShader, FrameInterpolationShaderIDs.CbInpaintingPyramid, _spdConstants); |
||||
|
|
||||
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
internal sealed class FrameInterpolationInpaintingPass : FrameInterpolationPass |
||||
|
{ |
||||
|
public FrameInterpolationInpaintingPass(in FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants) |
||||
|
: base(contextDescription, resources, constants) |
||||
|
{ |
||||
|
InitComputeShader("Inpainting", contextDescription.shaders.inpainting); |
||||
|
} |
||||
|
|
||||
|
protected override void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
||||
|
{ |
||||
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowSceneChangeDetection, dispatchParams.opticalFlowSceneChangeDetection); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvInpaintingPyramid, Resources.InpaintingPyramid); |
||||
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvPresentBackbuffer, dispatchParams.currentBackBuffer); |
||||
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvCurrentInterpolationSource, dispatchParams.InterpolationSource); |
||||
|
|
||||
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavOutput, dispatchParams.output); |
||||
|
|
||||
|
commandBuffer.SetComputeConstantBufferParam<FrameInterpolation.Constants>(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants); |
||||
|
|
||||
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
internal sealed class FrameInterpolationGameVectorFieldInpaintingPyramidPass : FrameInterpolationPass |
||||
|
{ |
||||
|
private readonly ComputeBuffer _spdConstants; |
||||
|
|
||||
|
public FrameInterpolationGameVectorFieldInpaintingPyramidPass(in FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants, ComputeBuffer spdConstants) |
||||
|
: base(contextDescription, resources, constants) |
||||
|
{ |
||||
|
_spdConstants = spdConstants; |
||||
|
|
||||
|
InitComputeShader("Game Vector Field Inpainting Pyramid", contextDescription.shaders.gameVectorFieldInpaintingPyramid); |
||||
|
} |
||||
|
|
||||
|
protected override void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
||||
|
{ |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldX, Resources.GameMotionVectorFieldX); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldY, Resources.GameMotionVectorFieldY); |
||||
|
|
||||
|
commandBuffer.SetComputeBufferParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavCounters, Resources.Counters); |
||||
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap0, Resources.InpaintingPyramid, 0); |
||||
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap1, Resources.InpaintingPyramid, 1); |
||||
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap2, Resources.InpaintingPyramid, 2); |
||||
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap3, Resources.InpaintingPyramid, 3); |
||||
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap4, Resources.InpaintingPyramid, 4); |
||||
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap5, Resources.InpaintingPyramid, 5); |
||||
|
commandBuffer.SetComputeTextureMipParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap6, Resources.InpaintingPyramid, 6); |
||||
|
|
||||
|
commandBuffer.SetComputeConstantBufferParam<FrameInterpolation.Constants>(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants); |
||||
|
commandBuffer.SetComputeConstantBufferParam<FfxSpd.SpdConstants>(ComputeShader, FrameInterpolationShaderIDs.CbInpaintingPyramid, _spdConstants); |
||||
|
|
||||
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
internal sealed class FrameInterpolationDebugViewPass : FrameInterpolationPass |
||||
|
{ |
||||
|
public FrameInterpolationDebugViewPass(in FrameInterpolation.ContextDescription contextDescription, FrameInterpolationResources resources, ComputeBuffer constants) |
||||
|
: base(contextDescription, resources, constants) |
||||
|
{ |
||||
|
InitComputeShader("Debug View", contextDescription.shaders.debugView); |
||||
|
} |
||||
|
|
||||
|
protected override void Dispatch(CommandBuffer commandBuffer, in FrameInterpolation.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY, int dispatchZ) |
||||
|
{ |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldX, Resources.GameMotionVectorFieldX); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvGameMotionVectorFieldY, Resources.GameMotionVectorFieldY); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowMotionVectorFieldX, Resources.OpticalFlowMotionVectorFieldX); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvOpticalFlowMotionVectorFieldY, Resources.OpticalFlowMotionVectorFieldY); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvDisocclusionMask, Resources.DisocclusionMask); |
||||
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvPresentBackbuffer, dispatchParams.currentBackBuffer); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvInpaintingPyramid, Resources.InpaintingPyramid); |
||||
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.SrvCurrentInterpolationSource, dispatchParams.InterpolationSource); |
||||
|
|
||||
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, FrameInterpolationShaderIDs.UavOutput, dispatchParams.output); |
||||
|
|
||||
|
commandBuffer.SetComputeConstantBufferParam<FrameInterpolation.Constants>(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants); |
||||
|
|
||||
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 923f12e91a899ce4f87665a073515a50 |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,64 @@ |
|||||
|
using System; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using UnityEngine; |
||||
|
using UnityEngine.Experimental.Rendering; |
||||
|
|
||||
|
namespace FidelityFX.FrameGen |
||||
|
{ |
||||
|
internal class FrameInterpolationResources: FfxResourcesBase |
||||
|
{ |
||||
|
public RenderTexture ReconstructedDepthInterpolatedFrame; |
||||
|
public RenderTexture GameMotionVectorFieldX; |
||||
|
public RenderTexture GameMotionVectorFieldY; |
||||
|
public RenderTexture InpaintingPyramid; |
||||
|
public ComputeBuffer Counters; |
||||
|
public RenderTexture OpticalFlowMotionVectorFieldX; |
||||
|
public RenderTexture OpticalFlowMotionVectorFieldY; |
||||
|
public RenderTexture PreviousInterpolationSource; |
||||
|
public RenderTexture DisocclusionMask; |
||||
|
|
||||
|
public readonly RenderTexture[] DilatedDepth = new RenderTexture[2]; |
||||
|
public readonly RenderTexture[] DilatedMotionVectors = new RenderTexture[2]; |
||||
|
public readonly RenderTexture[] ReconstructedDepth = new RenderTexture[2]; |
||||
|
|
||||
|
public void Create(in FrameInterpolation.ContextDescription contextDescription) |
||||
|
{ |
||||
|
Vector2Int displaySize = contextDescription.displaySize; |
||||
|
Vector2Int displaySizeDiv2 = new Vector2Int(displaySize.x / 2, displaySize.y / 2); |
||||
|
Vector2Int maxRenderSize = contextDescription.maxRenderSize; |
||||
|
|
||||
|
ReconstructedDepthInterpolatedFrame = CreateResource("FI_ReconstructedDepthInterpolatedFrame", maxRenderSize, GraphicsFormat.R32_UInt); |
||||
|
GameMotionVectorFieldX = CreateResource("FI_GameMotionVectorFieldX", maxRenderSize, GraphicsFormat.R32_UInt); |
||||
|
GameMotionVectorFieldY = CreateResource("FI_GameMotionVectorFieldY", maxRenderSize, GraphicsFormat.R32_UInt); |
||||
|
InpaintingPyramid = CreateResourceMips("FI_InpaintingPyramid", displaySizeDiv2, GraphicsFormat.R16G16B16A16_SFloat); |
||||
|
Counters = CreateBuffer<uint>("FI_Counters", 2); // structured buffer containing 2 UINT values
|
||||
|
OpticalFlowMotionVectorFieldX = CreateResource("FI_OpticalFlowMotionVectorFieldX", maxRenderSize, GraphicsFormat.R32_UInt); |
||||
|
OpticalFlowMotionVectorFieldY = CreateResource("FI_OpticalFlowMotionVectorFieldY", maxRenderSize, GraphicsFormat.R32_UInt); |
||||
|
PreviousInterpolationSource = CreateResource("FI_PreviousInterpolationSource", displaySize, contextDescription.backBufferFormat); |
||||
|
DisocclusionMask = CreateResource("FI_DisocclusionMask", maxRenderSize, GraphicsFormat.R8G8_UNorm); |
||||
|
|
||||
|
// Double buffering is used only when async support is enabled
|
||||
|
int numBuffers = (contextDescription.flags & FrameInterpolation.InitializationFlags.EnableAsyncSupport) != 0 ? 2 : 1; |
||||
|
CreateDoubleBufferedResource(DilatedDepth, "FI_DilatedDepth_", maxRenderSize, GraphicsFormat.R32_SFloat, numBuffers); |
||||
|
CreateDoubleBufferedResource(DilatedMotionVectors, "FI_DilatedMVs_", maxRenderSize, GraphicsFormat.R16G16_SFloat, numBuffers); |
||||
|
CreateDoubleBufferedResource(ReconstructedDepth, "FI_ReconstructedDepth_", maxRenderSize, GraphicsFormat.R32_UInt, numBuffers); |
||||
|
} |
||||
|
|
||||
|
public void Destroy() |
||||
|
{ |
||||
|
DestroyResource(ReconstructedDepth); |
||||
|
DestroyResource(DilatedMotionVectors); |
||||
|
DestroyResource(DilatedDepth); |
||||
|
|
||||
|
DestroyResource(ref DisocclusionMask); |
||||
|
DestroyResource(ref PreviousInterpolationSource); |
||||
|
DestroyResource(ref OpticalFlowMotionVectorFieldY); |
||||
|
DestroyResource(ref OpticalFlowMotionVectorFieldX); |
||||
|
DestroyResource(ref Counters); |
||||
|
DestroyResource(ref InpaintingPyramid); |
||||
|
DestroyResource(ref GameMotionVectorFieldY); |
||||
|
DestroyResource(ref GameMotionVectorFieldX); |
||||
|
DestroyResource(ref ReconstructedDepthInterpolatedFrame); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: c73ba9378b4e74b4db13de2812c61ad9 |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,60 @@ |
|||||
|
using UnityEngine; |
||||
|
|
||||
|
namespace FidelityFX.FrameGen |
||||
|
{ |
||||
|
public static class FrameInterpolationShaderIDs |
||||
|
{ |
||||
|
// Shader resource views, i.e. read-only bindings
|
||||
|
public static readonly int SrvInputDepth = Shader.PropertyToID("r_input_depth"); |
||||
|
public static readonly int SrvInputMotionVectors = Shader.PropertyToID("r_input_motion_vectors"); |
||||
|
public static readonly int SrvDilatedDepth = Shader.PropertyToID("r_dilated_depth"); |
||||
|
public static readonly int SrvDilatedMotionVectors = Shader.PropertyToID("r_dilated_motion_vectors"); |
||||
|
public static readonly int SrvReconstructedDepthPreviousFrame = Shader.PropertyToID("r_reconstructed_depth_previous_frame"); |
||||
|
public static readonly int SrvReconstructedDepthInterpolatedFrame = Shader.PropertyToID("r_reconstructed_depth_interpolated_frame"); |
||||
|
public static readonly int SrvPreviousInterpolationSource = Shader.PropertyToID("r_previous_interpolation_source"); |
||||
|
public static readonly int SrvCurrentInterpolationSource = Shader.PropertyToID("r_current_interpolation_source"); |
||||
|
public static readonly int SrvDisocclusionMask = Shader.PropertyToID("r_disocclusion_mask"); |
||||
|
public static readonly int SrvGameMotionVectorFieldX = Shader.PropertyToID("r_game_motion_vector_field_x"); |
||||
|
public static readonly int SrvGameMotionVectorFieldY = Shader.PropertyToID("r_game_motion_vector_field_y"); |
||||
|
public static readonly int SrvOpticalFlowMotionVectorFieldX = Shader.PropertyToID("r_optical_flow_motion_vector_field_x"); |
||||
|
public static readonly int SrvOpticalFlowMotionVectorFieldY = Shader.PropertyToID("r_optical_flow_motion_vector_field_y"); |
||||
|
public static readonly int SrvOpticalFlowVector = Shader.PropertyToID("r_optical_flow"); |
||||
|
public static readonly int SrvOpticalFlowConfidence = Shader.PropertyToID("r_optical_flow_confidence"); |
||||
|
public static readonly int SrvOpticalFlowGlobalMotion = Shader.PropertyToID("r_optical_flow_global_motion"); |
||||
|
public static readonly int SrvOpticalFlowSceneChangeDetection = Shader.PropertyToID("r_optical_flow_scd"); |
||||
|
public static readonly int SrvOutput = Shader.PropertyToID("r_output"); |
||||
|
public static readonly int SrvInpaintingPyramid = Shader.PropertyToID("r_inpainting_pyramid"); |
||||
|
public static readonly int SrvPresentBackbuffer = Shader.PropertyToID("r_present_backbuffer"); |
||||
|
public static readonly int SrvCounters = Shader.PropertyToID("r_counters"); |
||||
|
|
||||
|
// Unordered access views, i.e. random read/write bindings
|
||||
|
public static readonly int UavDilatedDepth = Shader.PropertyToID("rw_dilated_depth"); |
||||
|
public static readonly int UavDilatedMotionVectors = Shader.PropertyToID("rw_dilated_motion_vectors"); |
||||
|
public static readonly int UavReconstructedDepthPreviousFrame = Shader.PropertyToID("rw_reconstructed_depth_previous_frame"); |
||||
|
public static readonly int UavReconstructedDepthInterpolatedFrame = Shader.PropertyToID("rw_reconstructed_depth_interpolated_frame"); |
||||
|
public static readonly int UavOutput = Shader.PropertyToID("rw_output"); |
||||
|
public static readonly int UavDisocclusionMask = Shader.PropertyToID("rw_disocclusion_mask"); |
||||
|
public static readonly int UavGameMotionVectorFieldX = Shader.PropertyToID("rw_game_motion_vector_field_x"); |
||||
|
public static readonly int UavGameMotionVectorFieldY = Shader.PropertyToID("rw_game_motion_vector_field_y"); |
||||
|
public static readonly int UavOpticalFlowMotionVectorFieldX = Shader.PropertyToID("rw_optical_flow_motion_vector_field_x"); |
||||
|
public static readonly int UavOpticalFlowMotionVectorFieldY = Shader.PropertyToID("rw_optical_flow_motion_vector_field_y"); |
||||
|
public static readonly int UavCounters = Shader.PropertyToID("rw_counters"); |
||||
|
public static readonly int UavInpaintingPyramidMipmap0 = Shader.PropertyToID("rw_inpainting_pyramid0"); |
||||
|
public static readonly int UavInpaintingPyramidMipmap1 = Shader.PropertyToID("rw_inpainting_pyramid1"); |
||||
|
public static readonly int UavInpaintingPyramidMipmap2 = Shader.PropertyToID("rw_inpainting_pyramid2"); |
||||
|
public static readonly int UavInpaintingPyramidMipmap3 = Shader.PropertyToID("rw_inpainting_pyramid3"); |
||||
|
public static readonly int UavInpaintingPyramidMipmap4 = Shader.PropertyToID("rw_inpainting_pyramid4"); |
||||
|
public static readonly int UavInpaintingPyramidMipmap5 = Shader.PropertyToID("rw_inpainting_pyramid5"); |
||||
|
public static readonly int UavInpaintingPyramidMipmap6 = Shader.PropertyToID("rw_inpainting_pyramid6"); |
||||
|
public static readonly int UavInpaintingPyramidMipmap7 = Shader.PropertyToID("rw_inpainting_pyramid7"); |
||||
|
public static readonly int UavInpaintingPyramidMipmap8 = Shader.PropertyToID("rw_inpainting_pyramid8"); |
||||
|
public static readonly int UavInpaintingPyramidMipmap9 = Shader.PropertyToID("rw_inpainting_pyramid9"); |
||||
|
public static readonly int UavInpaintingPyramidMipmap10 = Shader.PropertyToID("rw_inpainting_pyramid10"); |
||||
|
public static readonly int UavInpaintingPyramidMipmap11 = Shader.PropertyToID("rw_inpainting_pyramid11"); |
||||
|
public static readonly int UavInpaintingPyramidMipmap12 = Shader.PropertyToID("rw_inpainting_pyramid12"); |
||||
|
|
||||
|
// Constant buffer bindings
|
||||
|
public static readonly int CbFrameInterpolation = Shader.PropertyToID("cbFI"); |
||||
|
public static readonly int CbInpaintingPyramid = Shader.PropertyToID("cbInpaintingPyramid"); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: ac109e3b6c9c55645a230f5e6ab9e49f |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 52b9ee437d2c45248a5410ed4160929e |
||||
|
folderAsset: yes |
||||
|
DefaultImporter: |
||||
|
externalObjects: {} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,102 @@ |
|||||
|
using System; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using UnityEngine; |
||||
|
|
||||
|
namespace FidelityFX.FrameGen |
||||
|
{ |
||||
|
public static class OpticalFlow |
||||
|
{ |
||||
|
internal const int MinBlockSize = 8; |
||||
|
internal const int OpticalFlowMaxPyramidLevels = 7; |
||||
|
internal const int HistogramBins = 256; |
||||
|
internal const int HistogramsPerDim = 3; |
||||
|
internal const int HistogramShifts = 3; |
||||
|
|
||||
|
public static OpticalFlowContext CreateContext(Vector2Int resolution, OpticalFlowShaders shaders) |
||||
|
{ |
||||
|
Debug.Log($"Setting up Optical Flow with resolution: {resolution.x}x{resolution.y}"); |
||||
|
|
||||
|
var contextDescription = new ContextDescription |
||||
|
{ |
||||
|
resolution = resolution, |
||||
|
shaders = shaders, |
||||
|
}; |
||||
|
|
||||
|
var context = new OpticalFlowContext(); |
||||
|
context.Create(contextDescription); |
||||
|
return context; |
||||
|
} |
||||
|
|
||||
|
public struct ContextDescription |
||||
|
{ |
||||
|
public Vector2Int resolution; |
||||
|
public OpticalFlowShaders shaders; |
||||
|
} |
||||
|
|
||||
|
public struct DispatchDescription |
||||
|
{ |
||||
|
public ResourceView color; |
||||
|
public ResourceView opticalFlowVector; |
||||
|
public ResourceView opticalFlowSCD; |
||||
|
public bool reset; |
||||
|
|
||||
|
public BackbufferTransferFunction backbufferTransferFunction; |
||||
|
public Vector2 minMaxLuminance; |
||||
|
} |
||||
|
|
||||
|
internal static Vector2Int GetOpticalFlowTextureSize(Vector2Int displaySize, int opticalFlowBlockSize) |
||||
|
{ |
||||
|
int width = (displaySize.x + opticalFlowBlockSize - 1) / opticalFlowBlockSize; |
||||
|
int height = (displaySize.y + opticalFlowBlockSize - 1) / opticalFlowBlockSize; |
||||
|
return new Vector2Int(width, height); |
||||
|
} |
||||
|
|
||||
|
internal static Vector2Int GetOpticalFlowHistogramSize(int level) |
||||
|
{ |
||||
|
const int searchRadius = 8; |
||||
|
int maxVelocity = searchRadius * (1 << (OpticalFlowMaxPyramidLevels - 1 - level)); |
||||
|
int binsPerDimension = 2 * maxVelocity + 1; |
||||
|
return new Vector2Int(binsPerDimension, binsPerDimension); |
||||
|
} |
||||
|
|
||||
|
internal static Vector2Int GetGlobalMotionSearchDispatchSize(int level) |
||||
|
{ |
||||
|
const int threadGroupSizeX = 16; |
||||
|
const int threadGroupSizeY = 16; |
||||
|
Vector2Int opticalFlowHistogramSize = GetOpticalFlowHistogramSize(level); |
||||
|
int additionalElementsDueToShiftsX = opticalFlowHistogramSize.x / threadGroupSizeX; |
||||
|
int additionalElementsDueToShiftsY = opticalFlowHistogramSize.y / threadGroupSizeY; |
||||
|
int dispatchX = (opticalFlowHistogramSize.x + additionalElementsDueToShiftsX + threadGroupSizeX - 1) / threadGroupSizeX; |
||||
|
int dispatchY = (opticalFlowHistogramSize.y + additionalElementsDueToShiftsY + threadGroupSizeY - 1) / threadGroupSizeY; |
||||
|
return new Vector2Int(dispatchX, dispatchY); |
||||
|
} |
||||
|
|
||||
|
internal static int GetSCDHistogramTextureWidth() |
||||
|
{ |
||||
|
return HistogramBins * (HistogramsPerDim * HistogramsPerDim); |
||||
|
} |
||||
|
|
||||
|
[Serializable, StructLayout(LayoutKind.Sequential)] |
||||
|
internal struct OpticalFlowConstants |
||||
|
{ |
||||
|
public Vector2Int inputLumaResolution; |
||||
|
public uint opticalFlowPyramidLevel; |
||||
|
public uint opticalFlowPyramidLevelCount; |
||||
|
|
||||
|
public int frameIndex; |
||||
|
public uint backbufferTransferFunction; |
||||
|
public Vector2 minMaxLuminance; |
||||
|
} |
||||
|
|
||||
|
[Serializable, StructLayout(LayoutKind.Sequential)] |
||||
|
internal struct SpdConstants |
||||
|
{ |
||||
|
public FfxSpd.SpdConstants spd; |
||||
|
|
||||
|
public uint numWorkGroupsOpticalFlowInputPyramid; |
||||
|
public uint pad0_; |
||||
|
public uint pad1_; |
||||
|
public uint pad2_; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: cb98adb74c696524e900d3b0b965e1dc |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,144 @@ |
|||||
|
// Copyright (c) 2024 Nico de Poel
|
||||
|
//
|
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
// in the Software without restriction, including without limitation the rights
|
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||
|
// furnished to do so, subject to the following conditions:
|
||||
|
//
|
||||
|
// The above copyright notice and this permission notice shall be included in all
|
||||
|
// copies or substantial portions of the Software.
|
||||
|
//
|
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
|
// THE SOFTWARE.
|
||||
|
|
||||
|
using UnityEngine; |
||||
|
|
||||
|
namespace FidelityFX.FrameGen |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Scriptable object containing all shader resources required by FidelityFX Optical Flow.
|
||||
|
/// These can be stored in an asset file and referenced from a scene or prefab, avoiding the need to load the shaders from a Resources folder.
|
||||
|
/// </summary>
|
||||
|
[CreateAssetMenu(fileName = "Optical Flow Assets", menuName = "FidelityFX/Optical Flow Assets", order = 1111)] |
||||
|
public class OpticalFlowAssets : ScriptableObject |
||||
|
{ |
||||
|
public OpticalFlowShaders shaders; |
||||
|
|
||||
|
#if UNITY_EDITOR
|
||||
|
private void Reset() |
||||
|
{ |
||||
|
shaders = new OpticalFlowShaders |
||||
|
{ |
||||
|
generateOpticalFlowInputPyramid = FindComputeShader("ffx_opticalflow_compute_luminance_pyramid_pass"), |
||||
|
prepareLuma = FindComputeShader("ffx_opticalflow_prepare_luma_pass"), |
||||
|
generateScdHistogram = FindComputeShader("ffx_opticalflow_generate_scd_histogram_pass"), |
||||
|
computeScdDivergence = FindComputeShader("ffx_opticalflow_compute_scd_divergence_pass"), |
||||
|
computeOpticalFlow = FindComputeShader("ffx_opticalflow_compute_optical_flow_advanced_pass_v5"), |
||||
|
filterOpticalFlow = FindComputeShader("ffx_opticalflow_filter_optical_flow_pass_v5"), |
||||
|
scaleOpticalFlow = FindComputeShader("ffx_opticalflow_scale_optical_flow_advanced_pass_v5"), |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
private static ComputeShader FindComputeShader(string name) |
||||
|
{ |
||||
|
string[] assetGuids = UnityEditor.AssetDatabase.FindAssets($"t:ComputeShader {name}"); |
||||
|
if (assetGuids == null || assetGuids.Length == 0) |
||||
|
return null; |
||||
|
|
||||
|
string assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(assetGuids[0]); |
||||
|
return UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>(assetPath); |
||||
|
} |
||||
|
#endif
|
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// All the compute shaders used by Optical Flow.
|
||||
|
/// </summary>
|
||||
|
[System.Serializable] |
||||
|
public class OpticalFlowShaders |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// The compute shader used by the generate optical flow input pass.
|
||||
|
/// </summary>
|
||||
|
public ComputeShader generateOpticalFlowInputPyramid; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The compute shader used by the prepare luma pass.
|
||||
|
/// </summary>
|
||||
|
public ComputeShader prepareLuma; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The compute shader used by the generate scene change detection histogram pass.
|
||||
|
/// </summary>
|
||||
|
public ComputeShader generateScdHistogram; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The compute shader used by the compute scene change detection divergence pass.
|
||||
|
/// </summary>
|
||||
|
public ComputeShader computeScdDivergence; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The compute shader used by the compute optical flow pass.
|
||||
|
/// </summary>
|
||||
|
public ComputeShader computeOpticalFlow; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The compute shader used by the filter optical flow pass.
|
||||
|
/// </summary>
|
||||
|
public ComputeShader filterOpticalFlow; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The compute shader used by the scale optical flow mask.
|
||||
|
/// </summary>
|
||||
|
public ComputeShader scaleOpticalFlow; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Returns a copy of this class and its contents.
|
||||
|
/// </summary>
|
||||
|
public OpticalFlowShaders Clone() |
||||
|
{ |
||||
|
return (OpticalFlowShaders)MemberwiseClone(); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Returns a copy of this class with clones of all its shaders.
|
||||
|
/// This can be useful if you're running multiple Optical Flow instances with different shader configurations.
|
||||
|
/// Be sure to clean up these clones through Dispose once you're done with them.
|
||||
|
/// </summary>
|
||||
|
public OpticalFlowShaders DeepCopy() |
||||
|
{ |
||||
|
return new OpticalFlowShaders |
||||
|
{ |
||||
|
generateOpticalFlowInputPyramid = Object.Instantiate(generateOpticalFlowInputPyramid), |
||||
|
prepareLuma = Object.Instantiate(prepareLuma), |
||||
|
generateScdHistogram = Object.Instantiate(generateScdHistogram), |
||||
|
computeScdDivergence = Object.Instantiate(computeScdDivergence), |
||||
|
computeOpticalFlow = Object.Instantiate(computeOpticalFlow), |
||||
|
filterOpticalFlow = Object.Instantiate(filterOpticalFlow), |
||||
|
scaleOpticalFlow = Object.Instantiate(scaleOpticalFlow), |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Destroy all the shaders within this instance.
|
||||
|
/// Use this only on clones created through DeepCopy.
|
||||
|
/// </summary>
|
||||
|
public void Dispose() |
||||
|
{ |
||||
|
Object.Destroy(scaleOpticalFlow); |
||||
|
Object.Destroy(filterOpticalFlow); |
||||
|
Object.Destroy(computeOpticalFlow); |
||||
|
Object.Destroy(computeScdDivergence); |
||||
|
Object.Destroy(generateScdHistogram); |
||||
|
Object.Destroy(prepareLuma); |
||||
|
Object.Destroy(generateOpticalFlowInputPyramid); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 0ac13db1d14fa3f498ce3c78c44dfb84 |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,228 @@ |
|||||
|
using System; |
||||
|
using UnityEngine; |
||||
|
using UnityEngine.Assertions; |
||||
|
using UnityEngine.Profiling; |
||||
|
using UnityEngine.Rendering; |
||||
|
|
||||
|
namespace FidelityFX.FrameGen |
||||
|
{ |
||||
|
public class OpticalFlowContext: FfxContextBase |
||||
|
{ |
||||
|
private const int MaxQueuedFrames = 16; |
||||
|
|
||||
|
public int BlockSize => OpticalFlow.MinBlockSize; |
||||
|
public Vector2Int TextureSize => OpticalFlow.GetOpticalFlowTextureSize(_contextDescription.resolution, OpticalFlow.MinBlockSize); |
||||
|
|
||||
|
private OpticalFlow.ContextDescription _contextDescription; |
||||
|
|
||||
|
private OpticalFlowPrepareLumaPass _prepareLumaPass; |
||||
|
private OpticalFlowGenerateInputPyramidPass _generateInputPyramidPass; |
||||
|
private OpticalFlowGenerateSCDHistogramPass _generateScdHistogramPass; |
||||
|
private OpticalFlowComputeSCDDivergencePass _computeScdDivergencePass; |
||||
|
private OpticalFlowComputePass _computeOpticalFlowPass; |
||||
|
private OpticalFlowFilterPass _filterOpticalFlowPass; |
||||
|
private OpticalFlowScalePass _scaleOpticalFlowPass; |
||||
|
|
||||
|
private readonly OpticalFlowResources _resources = new OpticalFlowResources(); |
||||
|
|
||||
|
private readonly ConstantsBuffer<OpticalFlow.OpticalFlowConstants> _opticalFlowConstants = new ConstantsBuffer<OpticalFlow.OpticalFlowConstants>(); |
||||
|
private readonly ConstantsBuffer<OpticalFlow.SpdConstants> _spdConstants = new ConstantsBuffer<OpticalFlow.SpdConstants>(); |
||||
|
|
||||
|
private bool _firstExecution; |
||||
|
private int _resourceFrameIndex; |
||||
|
private readonly Vector2Int[] _opticalFlowTextureSizes = new Vector2Int[OpticalFlow.OpticalFlowMaxPyramidLevels]; |
||||
|
|
||||
|
private readonly CustomSampler _sampler = CustomSampler.Create("Optical Flow"); |
||||
|
|
||||
|
public void Create(in OpticalFlow.ContextDescription contextDescription) |
||||
|
{ |
||||
|
_contextDescription = contextDescription; |
||||
|
|
||||
|
_opticalFlowConstants.Create(); |
||||
|
_spdConstants.Create(); |
||||
|
|
||||
|
_firstExecution = true; |
||||
|
_resourceFrameIndex = 0; |
||||
|
|
||||
|
_opticalFlowConstants.Value.inputLumaResolution = _contextDescription.resolution; |
||||
|
|
||||
|
_resources.Create(_contextDescription); |
||||
|
CreatePasses(); |
||||
|
} |
||||
|
|
||||
|
private void CreatePasses() |
||||
|
{ |
||||
|
_prepareLumaPass = new OpticalFlowPrepareLumaPass(_contextDescription, _resources, _opticalFlowConstants); |
||||
|
_generateInputPyramidPass = new OpticalFlowGenerateInputPyramidPass(_contextDescription, _resources, _opticalFlowConstants, _spdConstants); |
||||
|
_generateScdHistogramPass = new OpticalFlowGenerateSCDHistogramPass(_contextDescription, _resources, _opticalFlowConstants); |
||||
|
_computeScdDivergencePass = new OpticalFlowComputeSCDDivergencePass(_contextDescription, _resources, _opticalFlowConstants); |
||||
|
_computeOpticalFlowPass = new OpticalFlowComputePass(_contextDescription, _resources, _opticalFlowConstants); |
||||
|
_filterOpticalFlowPass = new OpticalFlowFilterPass(_contextDescription, _resources, _opticalFlowConstants); |
||||
|
_scaleOpticalFlowPass = new OpticalFlowScalePass(_contextDescription, _resources, _opticalFlowConstants); |
||||
|
} |
||||
|
|
||||
|
public void Destroy() |
||||
|
{ |
||||
|
DestroyPass(ref _scaleOpticalFlowPass); |
||||
|
DestroyPass(ref _filterOpticalFlowPass); |
||||
|
DestroyPass(ref _computeOpticalFlowPass); |
||||
|
DestroyPass(ref _computeScdDivergencePass); |
||||
|
DestroyPass(ref _generateScdHistogramPass); |
||||
|
DestroyPass(ref _generateInputPyramidPass); |
||||
|
DestroyPass(ref _prepareLumaPass); |
||||
|
|
||||
|
_resources.Destroy(); |
||||
|
|
||||
|
_spdConstants.Destroy(); |
||||
|
_opticalFlowConstants.Destroy(); |
||||
|
} |
||||
|
|
||||
|
public void Dispatch(CommandBuffer commandBuffer, OpticalFlow.DispatchDescription dispatchDescription) |
||||
|
{ |
||||
|
const int advancedAlgorithmIterations = 7; |
||||
|
const int opticalFlowBlockSize = 8; |
||||
|
|
||||
|
ref var constants = ref _opticalFlowConstants.Value; |
||||
|
constants.backbufferTransferFunction = (uint)dispatchDescription.backbufferTransferFunction; |
||||
|
constants.minMaxLuminance = dispatchDescription.minMaxLuminance; |
||||
|
|
||||
|
int frameIndex = _resourceFrameIndex % 2; |
||||
|
bool resetAccumulation = dispatchDescription.reset || _firstExecution; |
||||
|
_firstExecution = false; |
||||
|
|
||||
|
if (resetAccumulation) |
||||
|
constants.frameIndex = 0; |
||||
|
else |
||||
|
constants.frameIndex++; |
||||
|
|
||||
|
commandBuffer.BeginSample(_sampler); |
||||
|
|
||||
|
if (resetAccumulation) |
||||
|
{ |
||||
|
commandBuffer.SetRenderTarget(_resources.OpticalFlowSCDTemp); |
||||
|
commandBuffer.ClearRenderTarget(false, true, Color.clear); |
||||
|
commandBuffer.SetRenderTarget(dispatchDescription.opticalFlowSCD.RenderTarget); |
||||
|
commandBuffer.ClearRenderTarget(false, true, Color.clear); |
||||
|
commandBuffer.SetRenderTarget(_resources.OpticalFlowSCDHistogram); |
||||
|
commandBuffer.ClearRenderTarget(false, true, Color.clear); |
||||
|
commandBuffer.SetRenderTarget(_resources.OpticalFlowSCDPreviousHistogram); |
||||
|
commandBuffer.ClearRenderTarget(false, true, Color.clear); |
||||
|
for (int i = 0; i < 2; ++i) |
||||
|
{ |
||||
|
for (int level = 0; level < OpticalFlow.OpticalFlowMaxPyramidLevels; ++level) |
||||
|
{ |
||||
|
commandBuffer.SetRenderTarget(_resources.OpticalFlowInputLevels[level][i]); |
||||
|
commandBuffer.ClearRenderTarget(false, true, Color.clear); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
SetupSpdConstants(out var threadGroupSizeOpticalFlowInputPyramid); |
||||
|
|
||||
|
_opticalFlowConstants.UpdateBufferData(commandBuffer); |
||||
|
_spdConstants.UpdateBufferData(commandBuffer); |
||||
|
|
||||
|
{ |
||||
|
const int threadGroupSizeX = 16; |
||||
|
const int threadGroupSizeY = 16; |
||||
|
const int threadPixelsX = 2; |
||||
|
const int threadPixelsY = 2; |
||||
|
int dispatchX = ((_contextDescription.resolution.x + (threadPixelsX - 1)) / threadPixelsX + (threadGroupSizeX - 1)) / threadGroupSizeX; |
||||
|
int dispatchY = ((_contextDescription.resolution.y + (threadPixelsY - 1)) / threadPixelsY + (threadGroupSizeY - 1)) / threadGroupSizeY; |
||||
|
_prepareLumaPass.ScheduleDispatch(commandBuffer, dispatchDescription, frameIndex, 0, dispatchX, dispatchY); |
||||
|
} |
||||
|
|
||||
|
_generateInputPyramidPass.ScheduleDispatch(commandBuffer, dispatchDescription, frameIndex, 0, threadGroupSizeOpticalFlowInputPyramid.x, threadGroupSizeOpticalFlowInputPyramid.y); |
||||
|
|
||||
|
{ |
||||
|
const int threadGroupSizeX = 32; |
||||
|
//const int threadGroupSizeY = 8;
|
||||
|
int strataWidth = (_contextDescription.resolution.x / 4) / OpticalFlow.HistogramsPerDim; |
||||
|
int strataHeight = _contextDescription.resolution.y / OpticalFlow.HistogramsPerDim; |
||||
|
int dispatchX = (strataWidth + threadGroupSizeX - 1) / threadGroupSizeX; |
||||
|
const int dispatchY = 16; |
||||
|
const int dispatchZ = OpticalFlow.HistogramsPerDim * OpticalFlow.HistogramsPerDim; |
||||
|
_generateScdHistogramPass.ScheduleDispatch(commandBuffer, dispatchDescription, frameIndex, 0, dispatchX, dispatchY, dispatchZ); |
||||
|
} |
||||
|
{ |
||||
|
const int dispatchX = OpticalFlow.HistogramsPerDim * OpticalFlow.HistogramsPerDim; |
||||
|
const int dispatchY = OpticalFlow.HistogramShifts; |
||||
|
_computeScdDivergencePass.ScheduleDispatch(commandBuffer, dispatchDescription, frameIndex, 0, dispatchX, dispatchY); |
||||
|
} |
||||
|
|
||||
|
const int pyramidMaxIterations = advancedAlgorithmIterations; |
||||
|
Assert.IsTrue(pyramidMaxIterations <= OpticalFlow.OpticalFlowMaxPyramidLevels); |
||||
|
|
||||
|
_opticalFlowTextureSizes[0] = OpticalFlow.GetOpticalFlowTextureSize(_contextDescription.resolution, opticalFlowBlockSize); |
||||
|
for (int i = 1; i < pyramidMaxIterations; ++i) |
||||
|
{ |
||||
|
_opticalFlowTextureSizes[i] = new Vector2Int( |
||||
|
(_opticalFlowTextureSizes[i - 1].x + 1) / 2, |
||||
|
(_opticalFlowTextureSizes[i - 1].y + 1) / 2 |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
for (int level = pyramidMaxIterations - 1; level >= 0; --level) |
||||
|
{ |
||||
|
constants.opticalFlowPyramidLevel = (uint)level; |
||||
|
constants.opticalFlowPyramidLevelCount = pyramidMaxIterations; |
||||
|
_opticalFlowConstants.UpdateBufferData(commandBuffer); |
||||
|
|
||||
|
{ |
||||
|
int inputLumaWidth = Math.Max(_contextDescription.resolution.x >> level, 1); |
||||
|
int inputLumaHeight = Math.Max(_contextDescription.resolution.y >> level, 1); |
||||
|
|
||||
|
const int threadPixels = 4; |
||||
|
Assert.IsTrue(opticalFlowBlockSize >= threadPixels); |
||||
|
//const int threadGroupSizeX = 4;
|
||||
|
const int threadGroupSizeY = 16; |
||||
|
const int threadGroupSize = 64; |
||||
|
int dispatchX = ((inputLumaWidth + threadPixels - 1) / threadPixels * threadGroupSizeY + (threadGroupSize - 1)) / threadGroupSize; |
||||
|
int dispatchY = (inputLumaHeight + (threadGroupSizeY - 1)) / threadGroupSizeY; |
||||
|
|
||||
|
_computeOpticalFlowPass.ScheduleDispatch(commandBuffer, dispatchDescription, frameIndex, level, dispatchX, dispatchY); |
||||
|
} |
||||
|
|
||||
|
{ |
||||
|
int levelWidth = _opticalFlowTextureSizes[level].x; |
||||
|
int levelHeight = _opticalFlowTextureSizes[level].y; |
||||
|
|
||||
|
const int threadGroupSizeX = 16; |
||||
|
const int threadGroupSizeY = 4; |
||||
|
int dispatchX = (levelWidth + threadGroupSizeX - 1) / threadGroupSizeX; |
||||
|
int dispatchY = (levelHeight + threadGroupSizeY - 1) / threadGroupSizeY; |
||||
|
|
||||
|
_filterOpticalFlowPass.ScheduleDispatch(commandBuffer, dispatchDescription, frameIndex, level, dispatchX, dispatchY); |
||||
|
} |
||||
|
|
||||
|
if (level > 0) |
||||
|
{ |
||||
|
int nextLevelWidth = _opticalFlowTextureSizes[level - 1].x; |
||||
|
int nextLevelHeight = _opticalFlowTextureSizes[level - 1].y; |
||||
|
|
||||
|
const int threadGroupSizeX = opticalFlowBlockSize / 2; |
||||
|
const int threadGroupSizeY = opticalFlowBlockSize / 2; |
||||
|
//const int threadGroupSizeZ = 4;
|
||||
|
int dispatchX = (nextLevelWidth + threadGroupSizeX - 1) / threadGroupSizeX; |
||||
|
int dispatchY = (nextLevelHeight + threadGroupSizeY - 1) / threadGroupSizeY; |
||||
|
const int dispatchZ = 1; |
||||
|
|
||||
|
_scaleOpticalFlowPass.ScheduleDispatch(commandBuffer, dispatchDescription, frameIndex, level, dispatchX, dispatchY, dispatchZ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
commandBuffer.EndSample(_sampler); |
||||
|
|
||||
|
_resourceFrameIndex = (_resourceFrameIndex + 1) % MaxQueuedFrames; |
||||
|
} |
||||
|
|
||||
|
private void SetupSpdConstants(out Vector2Int dispatchThreadGroupCount) |
||||
|
{ |
||||
|
const int resolutionMultiplier = 1; |
||||
|
|
||||
|
ref OpticalFlow.SpdConstants spdConstants = ref _spdConstants.Value; |
||||
|
FfxSpd.SetupSpdConstants(_contextDescription.resolution * resolutionMultiplier, ref spdConstants.spd, out dispatchThreadGroupCount); |
||||
|
spdConstants.numWorkGroupsOpticalFlowInputPyramid = spdConstants.spd.numWorkGroups; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: baebcaebda3cbd344a546d7f3c47ae0d |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,200 @@ |
|||||
|
using System; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using UnityEngine; |
||||
|
using UnityEngine.Profiling; |
||||
|
using UnityEngine.Rendering; |
||||
|
|
||||
|
namespace FidelityFX.FrameGen |
||||
|
{ |
||||
|
internal abstract class OpticalFlowPass: FfxPassBase |
||||
|
{ |
||||
|
protected readonly OpticalFlowResources Resources; |
||||
|
protected readonly ComputeBuffer Constants; |
||||
|
|
||||
|
protected OpticalFlowPass(OpticalFlowResources resources, ComputeBuffer constants) |
||||
|
: base("Optical Flow") |
||||
|
{ |
||||
|
Resources = resources; |
||||
|
Constants = constants; |
||||
|
} |
||||
|
|
||||
|
public void ScheduleDispatch(CommandBuffer commandBuffer, in OpticalFlow.DispatchDescription dispatchParams, int bufferIndex, int level, int dispatchX, int dispatchY, int dispatchZ = 1) |
||||
|
{ |
||||
|
using (ProfilerSample(commandBuffer)) |
||||
|
{ |
||||
|
Dispatch(commandBuffer, dispatchParams, bufferIndex, level, dispatchX, dispatchY, dispatchZ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected abstract void Dispatch(CommandBuffer commandBuffer, in OpticalFlow.DispatchDescription dispatchParams, int bufferIndex, int level, int dispatchX, int dispatchY, int dispatchZ); |
||||
|
} |
||||
|
|
||||
|
internal sealed class OpticalFlowPrepareLumaPass : OpticalFlowPass |
||||
|
{ |
||||
|
public OpticalFlowPrepareLumaPass(in OpticalFlow.ContextDescription contextDescription, OpticalFlowResources resources, ComputeBuffer constants) |
||||
|
: base(resources, constants) |
||||
|
{ |
||||
|
InitComputeShader("Prepare Luma", contextDescription.shaders.prepareLuma); |
||||
|
} |
||||
|
|
||||
|
protected override void Dispatch(CommandBuffer commandBuffer, in OpticalFlow.DispatchDescription dispatchParams, int bufferIndex, int level, int dispatchX, int dispatchY, int dispatchZ) |
||||
|
{ |
||||
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.SrvInputColor, dispatchParams.color); |
||||
|
|
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowInput, Resources.OpticalFlowInputLevels[0][bufferIndex]); |
||||
|
|
||||
|
commandBuffer.SetComputeConstantBufferParam<OpticalFlow.OpticalFlowConstants>(ComputeShader, OpticalFlowShaderIDs.CbOpticalFlow, Constants); |
||||
|
|
||||
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
internal sealed class OpticalFlowGenerateInputPyramidPass : OpticalFlowPass |
||||
|
{ |
||||
|
private ComputeBuffer _spdConstants; |
||||
|
|
||||
|
public OpticalFlowGenerateInputPyramidPass(in OpticalFlow.ContextDescription contextDescription, OpticalFlowResources resources, ComputeBuffer constants, ComputeBuffer spdConstants) |
||||
|
: base(resources, constants) |
||||
|
{ |
||||
|
_spdConstants = spdConstants; |
||||
|
InitComputeShader("Generate Optical Flow Input Pyramid", contextDescription.shaders.generateOpticalFlowInputPyramid); |
||||
|
} |
||||
|
|
||||
|
protected override void Dispatch(CommandBuffer commandBuffer, in OpticalFlow.DispatchDescription dispatchParams, int bufferIndex, int level, int dispatchX, int dispatchY, int dispatchZ) |
||||
|
{ |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowInput, Resources.OpticalFlowInputLevels[0][bufferIndex]); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowInputLevel1, Resources.OpticalFlowInputLevels[1][bufferIndex]); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowInputLevel2, Resources.OpticalFlowInputLevels[2][bufferIndex]); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowInputLevel3, Resources.OpticalFlowInputLevels[3][bufferIndex]); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowInputLevel4, Resources.OpticalFlowInputLevels[4][bufferIndex]); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowInputLevel5, Resources.OpticalFlowInputLevels[5][bufferIndex]); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowInputLevel6, Resources.OpticalFlowInputLevels[6][bufferIndex]); |
||||
|
|
||||
|
commandBuffer.SetComputeConstantBufferParam<OpticalFlow.OpticalFlowConstants>(ComputeShader, OpticalFlowShaderIDs.CbOpticalFlow, Constants); |
||||
|
commandBuffer.SetComputeConstantBufferParam<OpticalFlow.SpdConstants>(ComputeShader, OpticalFlowShaderIDs.CbSpd, _spdConstants); |
||||
|
|
||||
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
internal sealed class OpticalFlowGenerateSCDHistogramPass : OpticalFlowPass |
||||
|
{ |
||||
|
public OpticalFlowGenerateSCDHistogramPass(in OpticalFlow.ContextDescription contextDescription, OpticalFlowResources resources, ComputeBuffer constants) |
||||
|
: base(resources, constants) |
||||
|
{ |
||||
|
InitComputeShader("Generate SCD Histogram", contextDescription.shaders.generateScdHistogram); |
||||
|
} |
||||
|
|
||||
|
protected override void Dispatch(CommandBuffer commandBuffer, in OpticalFlow.DispatchDescription dispatchParams, int bufferIndex, int level, int dispatchX, int dispatchY, int dispatchZ) |
||||
|
{ |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.SrvOpticalFlowInput, Resources.OpticalFlowInputLevels[0][bufferIndex]); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowScdHistogram, Resources.OpticalFlowSCDHistogram); |
||||
|
|
||||
|
commandBuffer.SetComputeConstantBufferParam<OpticalFlow.OpticalFlowConstants>(ComputeShader, OpticalFlowShaderIDs.CbOpticalFlow, Constants); |
||||
|
|
||||
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
internal sealed class OpticalFlowComputeSCDDivergencePass : OpticalFlowPass |
||||
|
{ |
||||
|
public OpticalFlowComputeSCDDivergencePass(in OpticalFlow.ContextDescription contextDescription, OpticalFlowResources resources, ComputeBuffer constants) |
||||
|
: base(resources, constants) |
||||
|
{ |
||||
|
InitComputeShader("Compute SCD Divergence", contextDescription.shaders.computeScdDivergence); |
||||
|
} |
||||
|
|
||||
|
protected override void Dispatch(CommandBuffer commandBuffer, in OpticalFlow.DispatchDescription dispatchParams, int bufferIndex, int level, int dispatchX, int dispatchY, int dispatchZ) |
||||
|
{ |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowScdHistogram, Resources.OpticalFlowSCDHistogram); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowScdPreviousHistogram, Resources.OpticalFlowSCDPreviousHistogram); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowScdTemp, Resources.OpticalFlowSCDTemp); |
||||
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowScdOutput, dispatchParams.opticalFlowSCD); |
||||
|
|
||||
|
commandBuffer.SetComputeConstantBufferParam<OpticalFlow.OpticalFlowConstants>(ComputeShader, OpticalFlowShaderIDs.CbOpticalFlow, Constants); |
||||
|
|
||||
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
internal sealed class OpticalFlowComputePass : OpticalFlowPass |
||||
|
{ |
||||
|
public OpticalFlowComputePass(in OpticalFlow.ContextDescription contextDescription, OpticalFlowResources resources, ComputeBuffer constants) |
||||
|
: base(resources, constants) |
||||
|
{ |
||||
|
InitComputeShader("Optical Flow Search", contextDescription.shaders.computeOpticalFlow); |
||||
|
} |
||||
|
|
||||
|
protected override void Dispatch(CommandBuffer commandBuffer, in OpticalFlow.DispatchDescription dispatchParams, int bufferIndex, int level, int dispatchX, int dispatchY, int dispatchZ) |
||||
|
{ |
||||
|
int levelIndex = bufferIndex ^ (level & 1); |
||||
|
|
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.SrvOpticalFlowInput, Resources.OpticalFlowInputLevels[level][bufferIndex]); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.SrvOpticalFlowPreviousInput, Resources.OpticalFlowInputLevels[level][bufferIndex ^ 1]); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlow, Resources.OpticalFlowLevels[level][levelIndex]); |
||||
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowScdOutput, dispatchParams.opticalFlowSCD); |
||||
|
|
||||
|
commandBuffer.SetComputeConstantBufferParam<OpticalFlow.OpticalFlowConstants>(ComputeShader, OpticalFlowShaderIDs.CbOpticalFlow, Constants); |
||||
|
|
||||
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
internal sealed class OpticalFlowFilterPass : OpticalFlowPass |
||||
|
{ |
||||
|
public OpticalFlowFilterPass(in OpticalFlow.ContextDescription contextDescription, OpticalFlowResources resources, ComputeBuffer constants) |
||||
|
: base(resources, constants) |
||||
|
{ |
||||
|
InitComputeShader("Optical Flow Filter", contextDescription.shaders.filterOpticalFlow); |
||||
|
} |
||||
|
|
||||
|
protected override void Dispatch(CommandBuffer commandBuffer, in OpticalFlow.DispatchDescription dispatchParams, int bufferIndex, int level, int dispatchX, int dispatchY, int dispatchZ) |
||||
|
{ |
||||
|
int levelIndex = bufferIndex ^ (level & 1); |
||||
|
|
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.SrvOpticalFlowPrevious, Resources.OpticalFlowLevels[level][levelIndex]); |
||||
|
|
||||
|
if (level == 0) |
||||
|
{ |
||||
|
// Final output (levels are counted in reverse)
|
||||
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlow, dispatchParams.opticalFlowVector); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlow, Resources.OpticalFlowLevels[level][levelIndex ^ 1]); |
||||
|
} |
||||
|
|
||||
|
commandBuffer.SetComputeConstantBufferParam<OpticalFlow.OpticalFlowConstants>(ComputeShader, OpticalFlowShaderIDs.CbOpticalFlow, Constants); |
||||
|
|
||||
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
internal sealed class OpticalFlowScalePass : OpticalFlowPass |
||||
|
{ |
||||
|
public OpticalFlowScalePass(in OpticalFlow.ContextDescription contextDescription, OpticalFlowResources resources, ComputeBuffer constants) |
||||
|
: base(resources, constants) |
||||
|
{ |
||||
|
InitComputeShader("Optical Flow Scale", contextDescription.shaders.scaleOpticalFlow); |
||||
|
} |
||||
|
|
||||
|
protected override void Dispatch(CommandBuffer commandBuffer, in OpticalFlow.DispatchDescription dispatchParams, int bufferIndex, int level, int dispatchX, int dispatchY, int dispatchZ) |
||||
|
{ |
||||
|
if (level <= 0) |
||||
|
return; |
||||
|
|
||||
|
int levelIndex = bufferIndex ^ (level & 1); |
||||
|
|
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.SrvOpticalFlowInput, Resources.OpticalFlowInputLevels[level][bufferIndex]); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.SrvOpticalFlowPreviousInput, Resources.OpticalFlowInputLevels[level][bufferIndex ^ 1]); |
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.SrvOpticalFlow, Resources.OpticalFlowLevels[level][levelIndex ^ 1]); |
||||
|
|
||||
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowNextLevel, Resources.OpticalFlowLevels[level - 1][levelIndex ^ 1]); |
||||
|
commandBuffer.SetComputeResourceParam(ComputeShader, KernelIndex, OpticalFlowShaderIDs.UavOpticalFlowScdOutput, dispatchParams.opticalFlowSCD); |
||||
|
|
||||
|
commandBuffer.SetComputeConstantBufferParam<OpticalFlow.OpticalFlowConstants>(ComputeShader, OpticalFlowShaderIDs.CbOpticalFlow, Constants); |
||||
|
|
||||
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, dispatchZ); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: a509b94b3bffef549b9d3316b44df221 |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,76 @@ |
|||||
|
using UnityEngine; |
||||
|
using UnityEngine.Experimental.Rendering; |
||||
|
|
||||
|
namespace FidelityFX.FrameGen |
||||
|
{ |
||||
|
internal class OpticalFlowResources: FfxResourcesBase |
||||
|
{ |
||||
|
public readonly RenderTexture[][] OpticalFlowInputLevels = |
||||
|
{ |
||||
|
new RenderTexture[2], |
||||
|
new RenderTexture[2], |
||||
|
new RenderTexture[2], |
||||
|
new RenderTexture[2], |
||||
|
new RenderTexture[2], |
||||
|
new RenderTexture[2], |
||||
|
new RenderTexture[2], |
||||
|
}; |
||||
|
|
||||
|
public readonly RenderTexture[][] OpticalFlowLevels = |
||||
|
{ |
||||
|
new RenderTexture[2], |
||||
|
new RenderTexture[2], |
||||
|
new RenderTexture[2], |
||||
|
new RenderTexture[2], |
||||
|
new RenderTexture[2], |
||||
|
new RenderTexture[2], |
||||
|
new RenderTexture[2], |
||||
|
}; |
||||
|
|
||||
|
public RenderTexture OpticalFlowSCDHistogram; |
||||
|
public RenderTexture OpticalFlowSCDPreviousHistogram; |
||||
|
public RenderTexture OpticalFlowSCDTemp; |
||||
|
|
||||
|
public void Create(in OpticalFlow.ContextDescription contextDescription) |
||||
|
{ |
||||
|
Vector2Int opticalFlowInputTextureSize = contextDescription.resolution; |
||||
|
Vector2Int opticalFlowTextureSize = OpticalFlow.GetOpticalFlowTextureSize(contextDescription.resolution, OpticalFlow.MinBlockSize); |
||||
|
|
||||
|
for (int level = 0; level < OpticalFlow.OpticalFlowMaxPyramidLevels; ++level) |
||||
|
{ |
||||
|
CreateDoubleBufferedResource(OpticalFlowInputLevels[level], $"OPTICALFLOW_OpticalFlowInputLevel{level}-", opticalFlowInputTextureSize, GraphicsFormat.R8_UInt); |
||||
|
CreateDoubleBufferedResource(OpticalFlowLevels[level], $"OPTICALFLOW_OpticalFlowLevel{level}-", opticalFlowTextureSize, GraphicsFormat.R16G16_SInt); |
||||
|
|
||||
|
opticalFlowTextureSize = NextLevelSize(opticalFlowTextureSize); |
||||
|
opticalFlowInputTextureSize = new Vector2Int(opticalFlowInputTextureSize.x >> 1, opticalFlowInputTextureSize.y >> 1); |
||||
|
} |
||||
|
|
||||
|
OpticalFlowSCDHistogram = CreateResource("OPTICALFLOW_OpticalFlowSCDHistogram", new Vector2Int(OpticalFlow.GetSCDHistogramTextureWidth(), 1), GraphicsFormat.R32_UInt); |
||||
|
OpticalFlowSCDPreviousHistogram = CreateResource("OPTICALFLOW_OpticalFlowSCDPreviousHistogram", new Vector2Int(OpticalFlow.GetSCDHistogramTextureWidth(), 1), GraphicsFormat.R32_SFloat); |
||||
|
OpticalFlowSCDTemp = CreateResource("OPTICALFLOW_OpticalFlowSCDTemp", new Vector2Int(3, 1), GraphicsFormat.R32_UInt); |
||||
|
} |
||||
|
|
||||
|
public void Destroy() |
||||
|
{ |
||||
|
DestroyResource(ref OpticalFlowSCDTemp); |
||||
|
DestroyResource(ref OpticalFlowSCDPreviousHistogram); |
||||
|
DestroyResource(ref OpticalFlowSCDHistogram); |
||||
|
|
||||
|
for (int level = 0; level < OpticalFlow.OpticalFlowMaxPyramidLevels; ++level) |
||||
|
{ |
||||
|
DestroyResource(OpticalFlowLevels[level]); |
||||
|
DestroyResource(OpticalFlowInputLevels[level]); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private static Vector2Int NextLevelSize(Vector2Int size) |
||||
|
{ |
||||
|
return new Vector2Int(AlignUp(size.x, 2) / 2, AlignUp(size.y, 2) / 2); |
||||
|
} |
||||
|
|
||||
|
private static int AlignUp(int x, int y) |
||||
|
{ |
||||
|
return (x + (y - 1)) & ~(y - 1); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 56e728c675f67404a966d919d71f9041 |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,33 @@ |
|||||
|
using UnityEngine; |
||||
|
|
||||
|
namespace FidelityFX.FrameGen |
||||
|
{ |
||||
|
public static class OpticalFlowShaderIDs |
||||
|
{ |
||||
|
// Shader resource views, i.e. read-only bindings
|
||||
|
public static readonly int SrvInputColor = Shader.PropertyToID("r_input_color"); |
||||
|
public static readonly int SrvOpticalFlowInput = Shader.PropertyToID("r_optical_flow_input"); |
||||
|
public static readonly int SrvOpticalFlowPreviousInput = Shader.PropertyToID("r_optical_flow_previous_input"); |
||||
|
public static readonly int SrvOpticalFlow = Shader.PropertyToID("r_optical_flow"); |
||||
|
public static readonly int SrvOpticalFlowPrevious = Shader.PropertyToID("r_optical_flow_previous"); |
||||
|
|
||||
|
// Unordered access views, i.e. random read/write bindings
|
||||
|
public static readonly int UavOpticalFlowInput = Shader.PropertyToID("rw_optical_flow_input"); |
||||
|
public static readonly int UavOpticalFlowInputLevel1 = Shader.PropertyToID("rw_optical_flow_input_level_1"); |
||||
|
public static readonly int UavOpticalFlowInputLevel2 = Shader.PropertyToID("rw_optical_flow_input_level_2"); |
||||
|
public static readonly int UavOpticalFlowInputLevel3 = Shader.PropertyToID("rw_optical_flow_input_level_3"); |
||||
|
public static readonly int UavOpticalFlowInputLevel4 = Shader.PropertyToID("rw_optical_flow_input_level_4"); |
||||
|
public static readonly int UavOpticalFlowInputLevel5 = Shader.PropertyToID("rw_optical_flow_input_level_5"); |
||||
|
public static readonly int UavOpticalFlowInputLevel6 = Shader.PropertyToID("rw_optical_flow_input_level_6"); |
||||
|
public static readonly int UavOpticalFlow = Shader.PropertyToID("rw_optical_flow"); |
||||
|
public static readonly int UavOpticalFlowNextLevel = Shader.PropertyToID("rw_optical_flow_next_level"); |
||||
|
public static readonly int UavOpticalFlowScdHistogram = Shader.PropertyToID("rw_optical_flow_scd_histogram"); // scene change detection histogram
|
||||
|
public static readonly int UavOpticalFlowScdPreviousHistogram = Shader.PropertyToID("rw_optical_flow_scd_previous_histogram"); |
||||
|
public static readonly int UavOpticalFlowScdTemp = Shader.PropertyToID("rw_optical_flow_scd_temp"); |
||||
|
public static readonly int UavOpticalFlowScdOutput = Shader.PropertyToID("rw_optical_flow_scd_output"); |
||||
|
|
||||
|
// Constant buffer bindings
|
||||
|
public static readonly int CbOpticalFlow = Shader.PropertyToID("cbOF"); |
||||
|
public static readonly int CbSpd = Shader.PropertyToID("cbOF_SPD"); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 12d00661151ef1b468cbe643922fc0cc |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,33 @@ |
|||||
|
// Copyright (c) 2024 Nico de Poel |
||||
|
// |
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
// of this software and associated documentation files (the "Software"), to deal |
||||
|
// in the Software without restriction, including without limitation the rights |
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
// copies of the Software, and to permit persons to whom the Software is |
||||
|
// furnished to do so, subject to the following conditions: |
||||
|
// |
||||
|
// The above copyright notice and this permission notice shall be included in all |
||||
|
// copies or substantial portions of the Software. |
||||
|
// |
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
// THE SOFTWARE. |
||||
|
|
||||
|
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch |
||||
|
|
||||
|
#pragma kernel CS |
||||
|
|
||||
|
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_LOW_RES_MOTION_VECTORS |
||||
|
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_INVERTED_DEPTH |
||||
|
|
||||
|
#pragma use_dxc |
||||
|
#pragma require WaveBasic |
||||
|
|
||||
|
#include "ffx_unity_common.cginc" |
||||
|
|
||||
|
#include "shaders/ffx_frameinterpolation_compute_game_vector_field_inpainting_pyramid_pass.hlsl" |
||||
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: e9b3faa41d2279344857aa1643c74c54 |
||||
|
ComputeShaderImporter: |
||||
|
externalObjects: {} |
||||
|
preprocessorOverride: 0 |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,33 @@ |
|||||
|
// Copyright (c) 2024 Nico de Poel |
||||
|
// |
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
// of this software and associated documentation files (the "Software"), to deal |
||||
|
// in the Software without restriction, including without limitation the rights |
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
// copies of the Software, and to permit persons to whom the Software is |
||||
|
// furnished to do so, subject to the following conditions: |
||||
|
// |
||||
|
// The above copyright notice and this permission notice shall be included in all |
||||
|
// copies or substantial portions of the Software. |
||||
|
// |
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
// THE SOFTWARE. |
||||
|
|
||||
|
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch |
||||
|
|
||||
|
#pragma kernel CS |
||||
|
|
||||
|
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_LOW_RES_MOTION_VECTORS |
||||
|
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_INVERTED_DEPTH |
||||
|
|
||||
|
#pragma use_dxc |
||||
|
#pragma require WaveBasic |
||||
|
|
||||
|
#include "ffx_unity_common.cginc" |
||||
|
|
||||
|
#include "shaders/ffx_frameinterpolation_compute_inpainting_pyramid_pass.hlsl" |
||||
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: b171a3b3146508a4ebe6ecf70d112568 |
||||
|
ComputeShaderImporter: |
||||
|
externalObjects: {} |
||||
|
preprocessorOverride: 0 |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,33 @@ |
|||||
|
// Copyright (c) 2024 Nico de Poel |
||||
|
// |
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
// of this software and associated documentation files (the "Software"), to deal |
||||
|
// in the Software without restriction, including without limitation the rights |
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
// copies of the Software, and to permit persons to whom the Software is |
||||
|
// furnished to do so, subject to the following conditions: |
||||
|
// |
||||
|
// The above copyright notice and this permission notice shall be included in all |
||||
|
// copies or substantial portions of the Software. |
||||
|
// |
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
// THE SOFTWARE. |
||||
|
|
||||
|
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch |
||||
|
|
||||
|
#pragma kernel CS |
||||
|
|
||||
|
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_LOW_RES_MOTION_VECTORS |
||||
|
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_INVERTED_DEPTH |
||||
|
|
||||
|
#pragma use_dxc |
||||
|
#pragma require WaveBasic |
||||
|
|
||||
|
#include "ffx_unity_common.cginc" |
||||
|
|
||||
|
#include "shaders/ffx_frameinterpolation_debug_view_pass.hlsl" |
||||
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 63512d6a875b7f749b69f1e1dab1db24 |
||||
|
ComputeShaderImporter: |
||||
|
externalObjects: {} |
||||
|
preprocessorOverride: 0 |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,33 @@ |
|||||
|
// Copyright (c) 2024 Nico de Poel |
||||
|
// |
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
// of this software and associated documentation files (the "Software"), to deal |
||||
|
// in the Software without restriction, including without limitation the rights |
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
// copies of the Software, and to permit persons to whom the Software is |
||||
|
// furnished to do so, subject to the following conditions: |
||||
|
// |
||||
|
// The above copyright notice and this permission notice shall be included in all |
||||
|
// copies or substantial portions of the Software. |
||||
|
// |
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
// THE SOFTWARE. |
||||
|
|
||||
|
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch |
||||
|
|
||||
|
#pragma kernel CS |
||||
|
|
||||
|
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_LOW_RES_MOTION_VECTORS |
||||
|
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_INVERTED_DEPTH |
||||
|
|
||||
|
#pragma use_dxc |
||||
|
#pragma require WaveBasic |
||||
|
|
||||
|
#include "ffx_unity_common.cginc" |
||||
|
|
||||
|
#include "shaders/ffx_frameinterpolation_disocclusion_mask_pass.hlsl" |
||||
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: eff2ebf6818194848a6bda41001d845a |
||||
|
ComputeShaderImporter: |
||||
|
externalObjects: {} |
||||
|
preprocessorOverride: 0 |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,33 @@ |
|||||
|
// Copyright (c) 2024 Nico de Poel |
||||
|
// |
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
// of this software and associated documentation files (the "Software"), to deal |
||||
|
// in the Software without restriction, including without limitation the rights |
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
// copies of the Software, and to permit persons to whom the Software is |
||||
|
// furnished to do so, subject to the following conditions: |
||||
|
// |
||||
|
// The above copyright notice and this permission notice shall be included in all |
||||
|
// copies or substantial portions of the Software. |
||||
|
// |
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
// THE SOFTWARE. |
||||
|
|
||||
|
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch |
||||
|
|
||||
|
#pragma kernel CS |
||||
|
|
||||
|
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_LOW_RES_MOTION_VECTORS |
||||
|
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_INVERTED_DEPTH |
||||
|
|
||||
|
#pragma use_dxc |
||||
|
#pragma require WaveBasic |
||||
|
|
||||
|
#include "ffx_unity_common.cginc" |
||||
|
|
||||
|
#include "shaders/ffx_frameinterpolation_game_motion_vector_field_pass.hlsl" |
||||
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 71e44c470ff3d6346b75aaa5edc608b5 |
||||
|
ComputeShaderImporter: |
||||
|
externalObjects: {} |
||||
|
preprocessorOverride: 0 |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,33 @@ |
|||||
|
// Copyright (c) 2024 Nico de Poel |
||||
|
// |
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
// of this software and associated documentation files (the "Software"), to deal |
||||
|
// in the Software without restriction, including without limitation the rights |
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
// copies of the Software, and to permit persons to whom the Software is |
||||
|
// furnished to do so, subject to the following conditions: |
||||
|
// |
||||
|
// The above copyright notice and this permission notice shall be included in all |
||||
|
// copies or substantial portions of the Software. |
||||
|
// |
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
// THE SOFTWARE. |
||||
|
|
||||
|
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch |
||||
|
|
||||
|
#pragma kernel CS |
||||
|
|
||||
|
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_LOW_RES_MOTION_VECTORS |
||||
|
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_INVERTED_DEPTH |
||||
|
|
||||
|
#pragma use_dxc |
||||
|
#pragma require WaveBasic |
||||
|
|
||||
|
#include "ffx_unity_common.cginc" |
||||
|
|
||||
|
#include "shaders/ffx_frameinterpolation_inpainting_pass.hlsl" |
||||
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: d9affbaf53b13854898a7fd84c66e487 |
||||
|
ComputeShaderImporter: |
||||
|
externalObjects: {} |
||||
|
preprocessorOverride: 0 |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,33 @@ |
|||||
|
// Copyright (c) 2024 Nico de Poel |
||||
|
// |
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
// of this software and associated documentation files (the "Software"), to deal |
||||
|
// in the Software without restriction, including without limitation the rights |
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
// copies of the Software, and to permit persons to whom the Software is |
||||
|
// furnished to do so, subject to the following conditions: |
||||
|
// |
||||
|
// The above copyright notice and this permission notice shall be included in all |
||||
|
// copies or substantial portions of the Software. |
||||
|
// |
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
// THE SOFTWARE. |
||||
|
|
||||
|
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch |
||||
|
|
||||
|
#pragma kernel CS |
||||
|
|
||||
|
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_LOW_RES_MOTION_VECTORS |
||||
|
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_INVERTED_DEPTH |
||||
|
|
||||
|
#pragma use_dxc |
||||
|
#pragma require WaveBasic |
||||
|
|
||||
|
#include "ffx_unity_common.cginc" |
||||
|
|
||||
|
#include "shaders/ffx_frameinterpolation_optical_flow_vector_field_pass.hlsl" |
||||
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: b89c0efd0c4ccad468e76ded24ac4bdf |
||||
|
ComputeShaderImporter: |
||||
|
externalObjects: {} |
||||
|
preprocessorOverride: 0 |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,33 @@ |
|||||
|
// Copyright (c) 2024 Nico de Poel |
||||
|
// |
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
// of this software and associated documentation files (the "Software"), to deal |
||||
|
// in the Software without restriction, including without limitation the rights |
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
// copies of the Software, and to permit persons to whom the Software is |
||||
|
// furnished to do so, subject to the following conditions: |
||||
|
// |
||||
|
// The above copyright notice and this permission notice shall be included in all |
||||
|
// copies or substantial portions of the Software. |
||||
|
// |
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
// THE SOFTWARE. |
||||
|
|
||||
|
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch |
||||
|
|
||||
|
#pragma kernel CS |
||||
|
|
||||
|
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_LOW_RES_MOTION_VECTORS |
||||
|
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_INVERTED_DEPTH |
||||
|
|
||||
|
#pragma use_dxc |
||||
|
#pragma require WaveBasic |
||||
|
|
||||
|
#include "ffx_unity_common.cginc" |
||||
|
|
||||
|
#include "shaders/ffx_frameinterpolation_pass.hlsl" |
||||
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 58d390c8d43f74c42832f68ef4597133 |
||||
|
ComputeShaderImporter: |
||||
|
externalObjects: {} |
||||
|
preprocessorOverride: 0 |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,34 @@ |
|||||
|
// Copyright (c) 2024 Nico de Poel |
||||
|
// |
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
// of this software and associated documentation files (the "Software"), to deal |
||||
|
// in the Software without restriction, including without limitation the rights |
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
// copies of the Software, and to permit persons to whom the Software is |
||||
|
// furnished to do so, subject to the following conditions: |
||||
|
// |
||||
|
// The above copyright notice and this permission notice shall be included in all |
||||
|
// copies or substantial portions of the Software. |
||||
|
// |
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
// THE SOFTWARE. |
||||
|
|
||||
|
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch |
||||
|
|
||||
|
#pragma kernel CS |
||||
|
|
||||
|
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_LOW_RES_MOTION_VECTORS |
||||
|
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_JITTERED_MOTION_VECTORS |
||||
|
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_INVERTED_DEPTH |
||||
|
|
||||
|
#pragma use_dxc |
||||
|
#pragma require WaveBasic |
||||
|
|
||||
|
#include "ffx_unity_common.cginc" |
||||
|
|
||||
|
#include "shaders/ffx_frameinterpolation_reconstruct_and_dilate_pass.hlsl" |
||||
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 8502d70e8836f5e4c818069fbc90a683 |
||||
|
ComputeShaderImporter: |
||||
|
externalObjects: {} |
||||
|
preprocessorOverride: 0 |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,33 @@ |
|||||
|
// Copyright (c) 2024 Nico de Poel |
||||
|
// |
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
// of this software and associated documentation files (the "Software"), to deal |
||||
|
// in the Software without restriction, including without limitation the rights |
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
// copies of the Software, and to permit persons to whom the Software is |
||||
|
// furnished to do so, subject to the following conditions: |
||||
|
// |
||||
|
// The above copyright notice and this permission notice shall be included in all |
||||
|
// copies or substantial portions of the Software. |
||||
|
// |
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
// THE SOFTWARE. |
||||
|
|
||||
|
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch |
||||
|
|
||||
|
#pragma kernel CS |
||||
|
|
||||
|
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_LOW_RES_MOTION_VECTORS |
||||
|
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_INVERTED_DEPTH |
||||
|
|
||||
|
#pragma use_dxc |
||||
|
#pragma require WaveBasic |
||||
|
|
||||
|
#include "ffx_unity_common.cginc" |
||||
|
|
||||
|
#include "shaders/ffx_frameinterpolation_reconstruct_previous_depth_pass.hlsl" |
||||
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: b665305f7d728ed478c661e3d0fa4d46 |
||||
|
ComputeShaderImporter: |
||||
|
externalObjects: {} |
||||
|
preprocessorOverride: 0 |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,33 @@ |
|||||
|
// Copyright (c) 2024 Nico de Poel |
||||
|
// |
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
// of this software and associated documentation files (the "Software"), to deal |
||||
|
// in the Software without restriction, including without limitation the rights |
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
// copies of the Software, and to permit persons to whom the Software is |
||||
|
// furnished to do so, subject to the following conditions: |
||||
|
// |
||||
|
// The above copyright notice and this permission notice shall be included in all |
||||
|
// copies or substantial portions of the Software. |
||||
|
// |
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
// THE SOFTWARE. |
||||
|
|
||||
|
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch |
||||
|
|
||||
|
#pragma kernel CS |
||||
|
|
||||
|
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_LOW_RES_MOTION_VECTORS |
||||
|
#pragma multi_compile_local __ FFX_FRAMEINTERPOLATION_OPTION_INVERTED_DEPTH |
||||
|
|
||||
|
#pragma use_dxc |
||||
|
#pragma require WaveBasic |
||||
|
|
||||
|
#include "ffx_unity_common.cginc" |
||||
|
|
||||
|
#include "shaders/ffx_frameinterpolation_setup_pass.hlsl" |
||||
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: b4821f6dac05a804e9ad78b957888248 |
||||
|
ComputeShaderImporter: |
||||
|
externalObjects: {} |
||||
|
preprocessorOverride: 0 |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,30 @@ |
|||||
|
// Copyright (c) 2024 Nico de Poel |
||||
|
// |
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
// of this software and associated documentation files (the "Software"), to deal |
||||
|
// in the Software without restriction, including without limitation the rights |
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
// copies of the Software, and to permit persons to whom the Software is |
||||
|
// furnished to do so, subject to the following conditions: |
||||
|
// |
||||
|
// The above copyright notice and this permission notice shall be included in all |
||||
|
// copies or substantial portions of the Software. |
||||
|
// |
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
// THE SOFTWARE. |
||||
|
|
||||
|
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch |
||||
|
|
||||
|
#pragma kernel CS |
||||
|
|
||||
|
#pragma use_dxc |
||||
|
#pragma require WaveBasic |
||||
|
|
||||
|
#include "ffx_unity_common.cginc" |
||||
|
|
||||
|
#include "shaders/ffx_opticalflow_compute_luminance_pyramid_pass.hlsl" |
||||
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: b4c831117e9d7db4f904bd81e05f9def |
||||
|
ComputeShaderImporter: |
||||
|
externalObjects: {} |
||||
|
preprocessorOverride: 0 |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,30 @@ |
|||||
|
// Copyright (c) 2024 Nico de Poel |
||||
|
// |
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
// of this software and associated documentation files (the "Software"), to deal |
||||
|
// in the Software without restriction, including without limitation the rights |
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
// copies of the Software, and to permit persons to whom the Software is |
||||
|
// furnished to do so, subject to the following conditions: |
||||
|
// |
||||
|
// The above copyright notice and this permission notice shall be included in all |
||||
|
// copies or substantial portions of the Software. |
||||
|
// |
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
// THE SOFTWARE. |
||||
|
|
||||
|
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch |
||||
|
|
||||
|
#pragma kernel CS |
||||
|
|
||||
|
#pragma use_dxc |
||||
|
#pragma require WaveBasic |
||||
|
|
||||
|
#include "ffx_unity_common.cginc" |
||||
|
|
||||
|
#include "shaders/ffx_opticalflow_compute_optical_flow_advanced_pass_v5.hlsl" |
||||
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: f480a6ee4cca98544a6f72d0a57caa36 |
||||
|
ComputeShaderImporter: |
||||
|
externalObjects: {} |
||||
|
preprocessorOverride: 0 |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,30 @@ |
|||||
|
// Copyright (c) 2024 Nico de Poel |
||||
|
// |
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
// of this software and associated documentation files (the "Software"), to deal |
||||
|
// in the Software without restriction, including without limitation the rights |
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
// copies of the Software, and to permit persons to whom the Software is |
||||
|
// furnished to do so, subject to the following conditions: |
||||
|
// |
||||
|
// The above copyright notice and this permission notice shall be included in all |
||||
|
// copies or substantial portions of the Software. |
||||
|
// |
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
// THE SOFTWARE. |
||||
|
|
||||
|
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch |
||||
|
|
||||
|
#pragma kernel CS |
||||
|
|
||||
|
#pragma use_dxc |
||||
|
#pragma require WaveBasic |
||||
|
|
||||
|
#include "ffx_unity_common.cginc" |
||||
|
|
||||
|
#include "shaders/ffx_opticalflow_compute_scd_divergence_pass.hlsl" |
||||
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 06c260b21c4db2c4c88629b23a249e32 |
||||
|
ComputeShaderImporter: |
||||
|
externalObjects: {} |
||||
|
preprocessorOverride: 0 |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,30 @@ |
|||||
|
// Copyright (c) 2024 Nico de Poel |
||||
|
// |
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
// of this software and associated documentation files (the "Software"), to deal |
||||
|
// in the Software without restriction, including without limitation the rights |
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
// copies of the Software, and to permit persons to whom the Software is |
||||
|
// furnished to do so, subject to the following conditions: |
||||
|
// |
||||
|
// The above copyright notice and this permission notice shall be included in all |
||||
|
// copies or substantial portions of the Software. |
||||
|
// |
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
// THE SOFTWARE. |
||||
|
|
||||
|
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch |
||||
|
|
||||
|
#pragma kernel CS |
||||
|
|
||||
|
#pragma use_dxc |
||||
|
#pragma require WaveBasic |
||||
|
|
||||
|
#include "ffx_unity_common.cginc" |
||||
|
|
||||
|
#include "shaders/ffx_opticalflow_filter_optical_flow_pass_v5.hlsl" |
||||
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 067af02200e7be2469c7f23a8711fe3c |
||||
|
ComputeShaderImporter: |
||||
|
externalObjects: {} |
||||
|
preprocessorOverride: 0 |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,30 @@ |
|||||
|
// Copyright (c) 2024 Nico de Poel |
||||
|
// |
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
// of this software and associated documentation files (the "Software"), to deal |
||||
|
// in the Software without restriction, including without limitation the rights |
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
// copies of the Software, and to permit persons to whom the Software is |
||||
|
// furnished to do so, subject to the following conditions: |
||||
|
// |
||||
|
// The above copyright notice and this permission notice shall be included in all |
||||
|
// copies or substantial portions of the Software. |
||||
|
// |
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
// THE SOFTWARE. |
||||
|
|
||||
|
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch |
||||
|
|
||||
|
#pragma kernel CS |
||||
|
|
||||
|
#pragma use_dxc |
||||
|
#pragma require WaveBasic |
||||
|
|
||||
|
#include "ffx_unity_common.cginc" |
||||
|
|
||||
|
#include "shaders/ffx_opticalflow_generate_scd_histogram_pass.hlsl" |
||||
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: f20d1907c158bfe4d85b2f18d497a09f |
||||
|
ComputeShaderImporter: |
||||
|
externalObjects: {} |
||||
|
preprocessorOverride: 0 |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,30 @@ |
|||||
|
// Copyright (c) 2024 Nico de Poel |
||||
|
// |
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
// of this software and associated documentation files (the "Software"), to deal |
||||
|
// in the Software without restriction, including without limitation the rights |
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
// copies of the Software, and to permit persons to whom the Software is |
||||
|
// furnished to do so, subject to the following conditions: |
||||
|
// |
||||
|
// The above copyright notice and this permission notice shall be included in all |
||||
|
// copies or substantial portions of the Software. |
||||
|
// |
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
// THE SOFTWARE. |
||||
|
|
||||
|
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch |
||||
|
|
||||
|
#pragma kernel CS |
||||
|
|
||||
|
#pragma use_dxc |
||||
|
#pragma require WaveBasic |
||||
|
|
||||
|
#include "ffx_unity_common.cginc" |
||||
|
|
||||
|
#include "shaders/ffx_opticalflow_prepare_luma_pass.hlsl" |
||||
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 3b70bda1db8d2f74396241d4811241ed |
||||
|
ComputeShaderImporter: |
||||
|
externalObjects: {} |
||||
|
preprocessorOverride: 0 |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
Some files were not shown because too many files changed in this diff
Write
Preview
Loading…
Cancel
Save
Reference in new issue