Created
November 16, 2017 20:00
-
-
Save st4rdog/f840326e5cc3e7e5ac047ca2e4a1b08c to your computer and use it in GitHub Desktop.
Sharpen blurry mipmaps in Unity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class MipMapBiasAdjusterS : MonoBehaviour { | |
[Header("Settings")] | |
[Tooltip("A positive bias makes a texture appear extra blurry, while a negative bias sharpens the texture. Note that using large negative bias can reduce performance, so it's not recommended to use more than -0.5 negative bias.)")] | |
public float _target = -2f; | |
[Tooltip("Adjust all textures found in scene?")] | |
public bool _allTexturesOnStart; | |
[Header("References")] | |
public Texture[] _texturesToAdjust; | |
void Start() | |
{ | |
if (_allTexturesOnStart) | |
{ | |
foreach (Texture tex in (Texture[])Resources.FindObjectsOfTypeAll(typeof(Texture))) | |
{ | |
tex.mipMapBias = _target; | |
} | |
} | |
} | |
[ContextMenu("Adjust")] | |
public void Adjust() | |
{ | |
foreach (Texture tex in _texturesToAdjust) | |
{ | |
tex.mipMapBias = _target; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment