Browse Source

Additional safety checks when applying mipmap bias offset

stable
Nico de Poel 3 years ago
parent
commit
a9bd7a284f
  1. 8
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/SuperResolution.cs

8
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/SuperResolution.cs

@ -218,11 +218,15 @@ namespace UnityEngine.Rendering.PostProcessing
// Apply a mipmap bias so that textures retain their sharpness // Apply a mipmap bias so that textures retain their sharpness
float biasOffset = Fsr2.GetMipmapBiasOffset(_renderSize.x, _displaySize.x); float biasOffset = Fsr2.GetMipmapBiasOffset(_renderSize.x, _displaySize.x);
if (!float.IsNaN(biasOffset))
if (!float.IsNaN(biasOffset) && !float.IsInfinity(biasOffset))
{ {
_callbacks.ApplyMipmapBias(biasOffset); _callbacks.ApplyMipmapBias(biasOffset);
_appliedBiasOffset = biasOffset; _appliedBiasOffset = biasOffset;
} }
else
{
_appliedBiasOffset = 0f;
}
} }
private void DestroyFsrContext() private void DestroyFsrContext()
@ -233,7 +237,7 @@ namespace UnityEngine.Rendering.PostProcessing
_fsrContext = null; _fsrContext = null;
} }
if (!float.IsNaN(_appliedBiasOffset) && _appliedBiasOffset != 0f)
if (!float.IsNaN(_appliedBiasOffset) && !float.IsInfinity(_appliedBiasOffset) && _appliedBiasOffset != 0f)
{ {
_callbacks.ApplyMipmapBias(-_appliedBiasOffset); _callbacks.ApplyMipmapBias(-_appliedBiasOffset);
_appliedBiasOffset = 0f; _appliedBiasOffset = 0f;

Loading…
Cancel
Save