Purpose of mipmaps for 2D sprites?
Asked Answered
L

1

8

In current Unity,

For use in Unity.UI as conventional UI ..

for any "Sprite (2D and UI)", in fact it always defaults to having "Generate Mip Maps" turned ON. Every time you drop an image in, you have to turn that "off" and apply.

As noted in the comments, these days you can actually use world space UI canvasses, and indeed advanced users may indeed have (say) "buttons that float over the head of Zelda and they are in the far distance". However if you're a everyday Unity user adding a button, just turn it off :)

enter image description here

Leontineleontyne answered 17/2, 2016 at 15:40 Comment(5)
Sprites (particularly in 3D) could be far away from the camera. There's no need in that case to use the full-size sprite.Meddlesome
Hmm, but that would be a texture on a far away object? (it would have lighting and what have you). You never shrink a UI element, nor a "Sprite"Leontineleontyne
In an ortographic view game where the player can zoom in/out, mipmaps are kinda mandatory otherwise detailed objects would render awfully viewed from far away. Especially dark transparent sprites in front of light objects (like sky bakcground dark tree leaves)Size
cheers @Menyus - for sure, but this discussion is more about using the Unity UI systemLeontineleontyne
@Leontineleontyne Oh, my bad man!Size
P
10

In Unity, "sprites" can still be positioned in 3D space. For example, on a world space canvas. Furthermore, mipmaps are used when the sprite is scaled. This is because the mipmap sampling is determined by the texel size rather than the distance.

If a sprite is flat and perfectly scaled then there is no reason to use mipmaps. This would likely apply to your icon example.

I suspect that it is enabled by default for 2D games where sprites will often not be perfectly scaled. To clarify, a sprite does not need to be on a canvas. Sprites can exist as their own GameObject with a Sprite Renderer (not on a canvas.) When this is the case, scaling the camera view will change the sprite's size on the screen resulting in mipmapping due to the texel size changing. This results in making the sprite always perfectly scaled challenging without a canvas.

Psi answered 17/2, 2016 at 16:49 Comment(3)
The main point is that the "sprites" are used in more places than the UI. I believe the default behavior of dragging a sprite in the scene is to create a sprite gameobject.. not add it to the UI (I may be mistaken.) Sprite gameobjects (not on a canvas) will be used for gameplay which will often include scaling the camera view to simulate zooming in or zooming out. I agree with you that it will be an exception to need mipmaps in a standard UI. However, they will be needed in a worldspace UI since a camera may render the UI at a steep angle.Psi
I suppose you're right. It does seem very obscure. Anyway - perhaps more of a discussion point that a question. Cheers!Leontineleontyne
"Scaled" also includes different screen resolutions. If you support both high dpi and lower resolution screens (eg 4k vs1080p or various Android phones), mipmaps will make your high dpi sprites look AND perform better on on lower res screens.Vendee

© 2022 - 2024 — McMap. All rights reserved.