Browse Source

Made undoing of mipmap bias a distinct separate callback, so that it can be overridden by client apps. Skip textures that don't have mipmaps and thus don't have any use for a mipmap bias.

fsr2
Nico de Poel 3 years ago
parent
commit
f35b63f292
  1. 4
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/SuperResolution.cs
  2. 15
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/FSR2/Fsr2Callbacks.cs

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

@ -240,9 +240,9 @@ namespace UnityEngine.Rendering.PostProcessing
} }
// Undo the current mipmap bias offset // Undo the current mipmap bias offset
if (!float.IsNaN(_appliedBiasOffset) && !float.IsInfinity(_appliedBiasOffset) && _appliedBiasOffset != 0f)
if (_appliedBiasOffset != 0f && !float.IsNaN(_appliedBiasOffset) && !float.IsInfinity(_appliedBiasOffset))
{ {
_callbacks.ApplyMipmapBias(-_appliedBiasOffset);
_callbacks.UndoMipmapBias(_appliedBiasOffset);
_appliedBiasOffset = 0f; _appliedBiasOffset = 0f;
} }
} }

15
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/FSR2/Fsr2Callbacks.cs

@ -42,6 +42,8 @@ namespace FidelityFX
/// You may also want to store the bias offset value and apply it to any assets that are loaded in on demand. /// You may also want to store the bias offset value and apply it to any assets that are loaded in on demand.
/// </summary> /// </summary>
void ApplyMipmapBias(float biasOffset); void ApplyMipmapBias(float biasOffset);
void UndoMipmapBias(float biasOffset);
} }
/// <summary> /// <summary>
@ -76,10 +78,23 @@ namespace FidelityFX
{ {
CurrentBiasOffset += biasOffset; CurrentBiasOffset += biasOffset;
if (Mathf.Approximately(CurrentBiasOffset, 0f))
{
CurrentBiasOffset = 0f;
}
foreach (var texture in Resources.FindObjectsOfTypeAll<Texture2D>()) foreach (var texture in Resources.FindObjectsOfTypeAll<Texture2D>())
{ {
if (texture.mipmapCount <= 1)
continue;
texture.mipMapBias += biasOffset; texture.mipMapBias += biasOffset;
} }
} }
public virtual void UndoMipmapBias(float biasOffset)
{
ApplyMipmapBias(-biasOffset);
}
} }
} }
Loading…
Cancel
Save