Texture is sharper WITHOUT MipMapping?

Hello!

I noticed a strange effect in my game. I have an object with one texture (material Mobile/Diffuse). When I activate MipMapping on the texture the texture looks kinda blurry (especially visible on the runes on the texture). When I deactivate MipMapping the runes look a bit sharper.
Here is a screenshot with and without MipMapping on the texture:

I hope you can see the effect that the right side is slightly sharper.

I have an orthographic camera with a fixed position.

  1. Can anyone explain how the texture is sharper WITHOUT MipMapping?
  2. When I deactivate MipMapping: Will the sharpening effect work for all resolutions? Or is it only sharper for some device resolutions?

Hopefully someone else will chime in with a proper answer, because I don’t know the details. But I can tell you that there’s a very important property called mipMapBias that affects the quality of the sprite. I believe someone here told me about that years ago.

I think Unity always defaults to the mip level that is one step smaller than the current resolution, which is odd. I want it to default to one step larger, so the sprite never has to upscale.

I ended up using this solution and setting my sprites to -0.5: mipmapBias in the Texture Importer - Questions & Answers - Unity Discussions

Not 100% sure if that will solve your problem, but it’s one possible explanation for why enabling mipmaps might somehow lead to lower image resolution.

You can also control mipmap bias in Shader Graphs using the Sample Texture 2D LOD node.

Sure. Mipmapping isn’t intended to keep textures sharp, it’s not part of the intent behind mipmapping at all. Mipmapping is only intended to reduce aliasing. i.e. prevent textures from having jagged edges or “having a sparkle” when displayed with fewer pixels than the texture itself has.

For example, here’s what a thin grid texture looks like with no mip maps:
7425959--909044--quad_nomips.gif

And here’s what it looks like using trilinear filtering:
7425959--909047--quad_trilinear.gif

As you can see, it’s a lot blurrier. Especially the ground plane, though the scaling quad doesn’t look as bad. It is still blurry. But it no longer aliases, and that’s all mipmapping is designed to prevent.

For comparison, this is probably closer to what you want:
7425959--909050--quad_rgss.gif

Those are all gifs from this article that goes deep into all of this:
https://bgolus.medium.com/sharper-mipmapping-using-shader-based-supersampling-ed7aadb47bec

And someone posted Sprite and UI shaders with the technique shown above implemented here:
https://discussions.unity.com/t/737314/8

Unity doesn’t do anything. What you’re seeing is all the default mipmapping behavior for literally all GPUs. And it’s not that it’s one step smaller, it’s that GPUs transition to the next mip before the previous one starts to alias. Displaying any texture at smaller than 1.5 texels : 1 pixel will start to alias, so it swaps or fades to the next mipmap before that.

Biasing can help sharpness as it delays the mip change, but will increase aliasing artifacts. Though some people prefer a sharp appearance with aliasing over the blur.

One important thing to be aware of, if you’re planning on releasing on iOS platforms. The mipMapBias does not work on any Apple device. You must bias the mip level in the shader, which is what the Sample Texture 2D LOD node does. The above shader also does the biasing in the shader so it’s more easily configurable.

8 Likes

Thanks a lot for the detailed information bgolus!

Since I am indeed targeting iOS I am not sure what to do now. I am using the very simple mobile/Diffuse shader and to be honest I would rather not touch any shader.

@bgolus The texture looks sharper when I deactivate MipMap on the texture on my iPhone7. Do you think it will also look sharper on other devices (with higher resolution?) Neither the object nor the camera moves.

If your texture is going to be displayed scaled larger than the original artwork’s resolution, then mipmapping won’t be used at all. Mipmapping is only an issue when the artwork is scaled down to smaller than its original resolution.

When scaled up the artwork may appear blurry as well, but for an entirely different reason. Disabling mipmapping won’t have any effect here because, again mipmapping isn’t being used. Just like taking artwork and scaling it up in Photoshop or GIMP results in a blurry image, there’s no additional detail to “scale up” to. There are again shader based approaches to try and minimize the blur, like using bicubic scaling or contrast filters, both of which are used for a lot of games with dynamic resolution or by some of Photoshop’s scaling algorithms. But really in this case the only real solution is to have with higher resolution artwork. Though using higher resolution art might cause aliasing issues when rendering at lower resolution … which is the whole reason mipmapping exists.

But really the answer is try it and see. It may or may not look bad to you on a higher resolution device. But it for sure won’t look any sharper with or without mipmapping enabled. And the shaders I linked to won’t help with that either.