I'm using viewports to handle different screen resolutions to support multiple platforms (desktop, android, etc.) in my libgdx powered game. I made all image assets for Full HD resolution and thought it will be easy to scale down them for lower screen resolutions. The thing is when I resize them (scale up or down) they are pixelated very badly. I tried to use TextureFilter.Linear and TextureFilter.MipMapLinearLinear (enabled mipmaps). The result is still not satisfying. Then I came across this post made by an administrator on libgdx forums:

http://badlogicgames.com/forum/viewtopic.php?p=107267#p107267

He says it scales the texture 60 times a second.

1-) Does it really gets scaled 60 times a second? If so why isn't it scaled only one time at program start? How can i do this?

2-) Since all games which support multiple platforms somehow need to achieve the rescaling, what is the best way to do it? My image editor program can resize it without pixelating so I think there should be a way.

This answer explicitly refers to libgdx, but likely applies to other frameworks/engines.

1) It depends on what you consider “scaling” to entail. Can the mip-map level change each frame? Yes. However, the different mip-map levels are generated when the texture is created and uploaded to the GPU internally. Libgdx is not running a reconstruction algorithm each frame.

2) Some games ship with multiple sized source textures. However, many others rely on dynamically resizing content. For those methods, there are better mip-mapping filters than Linear. For example, the Mitchell-Netravali Cubic Filter or Catmull-Rom Cubic Spline Filter - two of the “top tier” filters among many others. You can find implementation details on all of the major reconstruction algorithms here.

For example, this graphic was downsampled from 2380x3360 to 260x400; a massive 1:11 ratio*.

Downsmapled Example

*After downsampling the graphic was upsampled again with a linear filter to more easily compare the effects.

  • Isn't there a libgdx way of doing this other than implementing myself? Everyone using libgdx implements those algorithms? – Tom Milberg Jan 22 at 16:56
  • Not everyone goes down this route. You can see other solutions to supporting a range of dynamic resolutions here. Unless you can find an open source project, then yes; perhaps you can share your solution if you choose to go down that route. – Landon Jan 23 at 19:20

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.