- Home /
Sprite resolution in function of camera zoom
Hello,
My game units are gameObjects with a sprite renderer attached. For each unit I have the same sprite but in 3 different compression levels (256, 64 and 32). Then I vary the used sprite in function of my camera zoom level. But is this the right approach?
If zoomed out to its maximum - the unit will be represented using the max 32 sprite, if zoomed in tight it will use the 256 compressed sprite (I will change this to 128 I believe). You can see some details in the attached: But I'm still not very happy on how "clean" the sprites look and I'm also I'm not sure how this will turn out in various resolution and if it is the correct/best way to do this? Any thoughts or advice?
Thanks a lot,
Answer by Namey5 · Aug 02, 2020 at 02:18 AM
Is there a reason you can't just use mipmapping? This is kinda the purpose it was created for.
I will explore this and see if it works for my situation. Thanks!
Hi, effectively mipmap seems to do the trick - not sure why I didn't find this out earlier when doing my research... shameful of me and thanks for your help. In the below, you can see the mip map version to the left and the change sprite compressed sprite version I was using to the right... very comparable - sometimes the mipmap seems a bit more fussy, sometime the compressed version to jagged... Do you have any thoughts on the performance of which? I call the check texture function I have only when the zoom is changed - not sure how this would compare to mipmap. Thanks a lot!!!
$$anonymous$$ipmapping is done automatically in the shader (whether or not your texture has mipmaps enabled, it will probably be sampled as though it does because the hardware is built to always use mipmaps) and will always choose the best resolution for the size on screen. This means that you won't get aliasing from sampling a texture at a higher res that the screen (like is probably happening in your other example) and it's actually better for performance as you only sample as high a resolution as you need without needing to do additional work.
Great - I will shift to this method. Thanks a lot. If you want to add mipmaps as an answer I will be happy to validate it. Cheers,