Browse Source

Try our best to ensure a shaders asset is assigned to the image effect component.

fsr3
Nico de Poel 2 years ago
parent
commit
fdcc85355c
  1. 6
      Assets/Scripts/Core/Fsr3UpscalerShaders.cs
  2. 22
      Assets/Scripts/Fsr3UpscalerImageEffect.cs

6
Assets/Scripts/Core/Fsr3UpscalerShaders.cs

@ -72,11 +72,11 @@ namespace FidelityFX
private static ComputeShader FindComputeShader(string name)
{
string[] assets = UnityEditor.AssetDatabase.FindAssets($"t:ComputeShader {name}");
if (assets == null || assets.Length == 0)
string[] assetGuids = UnityEditor.AssetDatabase.FindAssets($"t:ComputeShader {name}");
if (assetGuids == null || assetGuids.Length == 0)
return null;
string assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(assets[0]);
string assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(assetGuids[0]);
return UnityEditor.AssetDatabase.LoadAssetAtPath<ComputeShader>(assetPath);
}
#endif

22
Assets/Scripts/Fsr3UpscalerImageEffect.cs

@ -146,6 +146,13 @@ namespace FidelityFX
enabled = false;
return;
}
if (shaders == null)
{
Debug.LogError($"FSR3 Upscaler shaders are not assigned! Please ensure an {nameof(Fsr3UpscalerShaders)} asset is assigned to the Shaders property of this component.");
enabled = false;
return;
}
if (_maxRenderSize.x == 0 || _maxRenderSize.y == 0)
{
@ -459,5 +466,20 @@ namespace FidelityFX
return _maxRenderSize;
}
#if UNITY_EDITOR
private void Reset()
{
if (shaders != null)
return;
string[] assetGuids = UnityEditor.AssetDatabase.FindAssets($"t:{nameof(Fsr3UpscalerShaders)}");
if (assetGuids == null || assetGuids.Length == 0)
return;
string assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(assetGuids[0]);
shaders = UnityEditor.AssetDatabase.LoadAssetAtPath<Fsr3UpscalerShaders>(assetPath);
}
#endif
}
}
Loading…
Cancel
Save