Browse Source

Turned shaders aggregate into a scriptable object, with a default asset instance that automatically resets to look up the correct shader references.

fsr3
Nico de Poel 2 years ago
parent
commit
bd98fdf00d
  1. 22
      Assets/Resources/FSR3/Fsr3UpscalerShaders.asset
  2. 8
      Assets/Resources/FSR3/Fsr3UpscalerShaders.asset.meta
  3. 10
      Assets/Scenes/SampleScene.unity
  4. 26
      Assets/Scripts/Core/Fsr3UpscalerShaders.cs
  5. 2
      Assets/Scripts/Fsr3UpscalerImageEffect.cs

22
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}

8
Assets/Resources/FSR3/Fsr3UpscalerShaders.asset.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4151befafd86e8740ab09463b4f1bdbb
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

10
Assets/Scenes/SampleScene.unity

@ -337,15 +337,7 @@ MonoBehaviour:
autoTcScale: 1 autoTcScale: 1
autoReactiveScale: 5 autoReactiveScale: 5
autoReactiveMax: 0.9 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 --- !u!114 &963194230
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

26
Assets/Scripts/Core/Fsr3UpscalerShaders.cs

@ -7,7 +7,7 @@ namespace FidelityFX
/// All the compute shaders used by the FidelityFX Super Resolution 3 (FSR3) Upscaler. /// All the compute shaders used by the FidelityFX Super Resolution 3 (FSR3) Upscaler.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class Fsr3UpscalerShaders
public class Fsr3UpscalerShaders: ScriptableObject
{ {
/// <summary> /// <summary>
/// The compute shader used by the luminance pyramid computation pass. /// The compute shader used by the luminance pyramid computation pass.
@ -56,5 +56,29 @@ namespace FidelityFX
{ {
return (Fsr3UpscalerShaders)MemberwiseClone(); 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<ComputeShader>(assetPath);
}
#endif
} }
} }

2
Assets/Scripts/Fsr3UpscalerImageEffect.cs

@ -406,7 +406,7 @@ namespace FidelityFX
// Output the upscaled image // Output the upscaled image
if (_originalRenderTarget != null) 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.SetGlobalTexture("_DepthTex", BuiltinRenderTextureType.CameraTarget, RenderTextureSubElement.Depth);
_dispatchCommandBuffer.Blit(Fsr3ShaderIDs.UavUpscaledOutput, _originalRenderTarget, _copyWithDepthMaterial); _dispatchCommandBuffer.Blit(Fsr3ShaderIDs.UavUpscaledOutput, _originalRenderTarget, _copyWithDepthMaterial);
} }

Loading…
Cancel
Save