diff --git a/Assets/Scripts/Fsr2ImageEffect.cs b/Assets/Scripts/Fsr2ImageEffect.cs index 760007d..88ebadb 100644 --- a/Assets/Scripts/Fsr2ImageEffect.cs +++ b/Assets/Scripts/Fsr2ImageEffect.cs @@ -121,14 +121,24 @@ namespace FidelityFX // Apply a mipmap bias so that textures retain their sharpness float biasOffset = Fsr2.GetMipmapBiasOffset(_renderSize.x, _displaySize.x); - Callbacks.ApplyMipmapBias(biasOffset); - + if (!float.IsNaN(biasOffset)) + { + Callbacks.ApplyMipmapBias(biasOffset); + } + if (!SystemInfo.supportsComputeShaders) { Debug.LogError("FSR2 requires compute shader support!"); enabled = false; return; } + + if (_renderSize.x == 0 || _renderSize.y == 0) + { + Debug.LogError($"FSR2 render size is invalid: {_renderSize.x}x{_renderSize.y}. Please check your screen resolution and camera viewport parameters."); + enabled = false; + return; + } _helper = GetComponent(); @@ -163,8 +173,11 @@ namespace FidelityFX { // Undo the current mipmap bias offset float biasOffset = Fsr2.GetMipmapBiasOffset(_renderSize.x, _prevDisplaySize.x); - Callbacks.ApplyMipmapBias(-biasOffset); - + if (!float.IsNaN(biasOffset)) + { + Callbacks.ApplyMipmapBias(-biasOffset); + } + // Restore the camera's original state _renderCamera.depthTextureMode = _originalDepthTextureMode; _renderCamera.targetTexture = _originalRenderTarget;