diff --git a/Assets/Resources/FSR3/Fsr3UpscalerShaders.asset b/Assets/Resources/FSR3/Fsr3UpscalerShaders.asset new file mode 100644 index 0000000..50daff0 --- /dev/null +++ b/Assets/Resources/FSR3/Fsr3UpscalerShaders.asset @@ -0,0 +1,22 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: db26e15a33db6ab42a38daab0ba2712f, type: 3} + m_Name: Fsr3UpscalerShaders + m_EditorClassIdentifier: + computeLuminancePyramidPass: {fileID: 7200000, guid: d253be05abcdc80428503d3e4cce3a36, type: 3} + reconstructPreviousDepthPass: {fileID: 7200000, guid: 4f59e5b9179d74844ae06a30ae1e0629, type: 3} + depthClipPass: {fileID: 7200000, guid: 20e44016ed34b0d4b8de499d1b566c69, type: 3} + lockPass: {fileID: 7200000, guid: a135306e6d1857e43a86ef20db2a47fe, type: 3} + accumulatePass: {fileID: 7200000, guid: c9b45f0ae7673694ba57a4aadfe212e9, type: 3} + sharpenPass: {fileID: 7200000, guid: 7aaf5cfff022de2499e9b0412f947f6c, type: 3} + autoGenReactivePass: {fileID: 7200000, guid: 5716b91fdaa4e9e439df6b96a796fe6e, type: 3} + tcrAutoGenPass: {fileID: 7200000, guid: 75cdc6ef23f08ed498d4da511923fcea, type: 3} diff --git a/Assets/Resources/FSR3/Fsr3UpscalerShaders.asset.meta b/Assets/Resources/FSR3/Fsr3UpscalerShaders.asset.meta new file mode 100644 index 0000000..1aa49b3 --- /dev/null +++ b/Assets/Resources/FSR3/Fsr3UpscalerShaders.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4151befafd86e8740ab09463b4f1bdbb +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index ad95b81..00d0521 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -337,15 +337,7 @@ MonoBehaviour: autoTcScale: 1 autoReactiveScale: 5 autoReactiveMax: 0.9 - shaders: - computeLuminancePyramidPass: {fileID: 7200000, guid: d253be05abcdc80428503d3e4cce3a36, type: 3} - reconstructPreviousDepthPass: {fileID: 7200000, guid: 4f59e5b9179d74844ae06a30ae1e0629, type: 3} - depthClipPass: {fileID: 7200000, guid: 20e44016ed34b0d4b8de499d1b566c69, type: 3} - lockPass: {fileID: 7200000, guid: a135306e6d1857e43a86ef20db2a47fe, type: 3} - accumulatePass: {fileID: 7200000, guid: c9b45f0ae7673694ba57a4aadfe212e9, type: 3} - sharpenPass: {fileID: 7200000, guid: 7aaf5cfff022de2499e9b0412f947f6c, type: 3} - autoGenReactivePass: {fileID: 7200000, guid: 5716b91fdaa4e9e439df6b96a796fe6e, type: 3} - tcrAutoGenPass: {fileID: 7200000, guid: 75cdc6ef23f08ed498d4da511923fcea, type: 3} + shaders: {fileID: 11400000, guid: 4151befafd86e8740ab09463b4f1bdbb, type: 2} --- !u!114 &963194230 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Core/Fsr3UpscalerShaders.cs b/Assets/Scripts/Core/Fsr3UpscalerShaders.cs index 9d9fa4d..154fbc4 100644 --- a/Assets/Scripts/Core/Fsr3UpscalerShaders.cs +++ b/Assets/Scripts/Core/Fsr3UpscalerShaders.cs @@ -7,7 +7,7 @@ namespace FidelityFX /// All the compute shaders used by the FidelityFX Super Resolution 3 (FSR3) Upscaler. /// [Serializable] - public class Fsr3UpscalerShaders + public class Fsr3UpscalerShaders: ScriptableObject { /// /// The compute shader used by the luminance pyramid computation pass. @@ -56,5 +56,29 @@ namespace FidelityFX { return (Fsr3UpscalerShaders)MemberwiseClone(); } + + #if UNITY_EDITOR + private void Reset() + { + computeLuminancePyramidPass = FindComputeShader("ffx_fsr3upscaler_compute_luminance_pyramid_pass"); + reconstructPreviousDepthPass = FindComputeShader("ffx_fsr3upscaler_reconstruct_previous_depth_pass"); + depthClipPass = FindComputeShader("ffx_fsr3upscaler_depth_clip_pass"); + lockPass = FindComputeShader("ffx_fsr3upscaler_lock_pass"); + accumulatePass = FindComputeShader("ffx_fsr3upscaler_accumulate_pass"); + sharpenPass = FindComputeShader("ffx_fsr3upscaler_rcas_pass"); + autoGenReactivePass = FindComputeShader("ffx_fsr3upscaler_autogen_reactive_pass"); + tcrAutoGenPass = FindComputeShader("ffx_fsr3upscaler_tcr_autogen_pass"); + } + + private static ComputeShader FindComputeShader(string name) + { + string[] assets = UnityEditor.AssetDatabase.FindAssets($"t:ComputeShader {name}"); + if (assets == null || assets.Length == 0) + return null; + + string assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(assets[0]); + return UnityEditor.AssetDatabase.LoadAssetAtPath(assetPath); + } + #endif } } diff --git a/Assets/Scripts/Fsr3UpscalerImageEffect.cs b/Assets/Scripts/Fsr3UpscalerImageEffect.cs index 1d50cab..5554dec 100644 --- a/Assets/Scripts/Fsr3UpscalerImageEffect.cs +++ b/Assets/Scripts/Fsr3UpscalerImageEffect.cs @@ -406,7 +406,7 @@ namespace FidelityFX // Output the upscaled image if (_originalRenderTarget != null) { - // Output to the camera target texture, passing through depth and motion vectors + // Output to the camera target texture, passing through depth as well _dispatchCommandBuffer.SetGlobalTexture("_DepthTex", BuiltinRenderTextureType.CameraTarget, RenderTextureSubElement.Depth); _dispatchCommandBuffer.Blit(Fsr3ShaderIDs.UavUpscaledOutput, _originalRenderTarget, _copyWithDepthMaterial); }