2
\$\begingroup\$

I am beginning game development and using texture atlases. I've created textures based on the resolution 1920x1080, so I created a 1024x1024 size Texture Atlas for storing multiple graphics.

If the game is played on a 800x480 size device, the atlas will be very big to load in memory. An atlas of 512x512 would be enough and on devices with 480x320 resolution the game might not even work due to the different texture size.

How can I resize the atlas to save memory? Can I use different texture atlases for different screen sizes?

I just want to know how other game devs do it?

\$\endgroup\$
4
  • \$\begingroup\$ Are you using a specific library? If so it might actually have some tooling for having multiple texture sizes and applies them appropriately. Or are you working from scratch? \$\endgroup\$
    – Sidar
    Feb 20, 2014 at 13:33
  • \$\begingroup\$ Make sure you're actually facing a performance problem too. Check the game with a profiler to see what you're actually using and see if you really even need to worry about this. \$\endgroup\$
    – House
    Feb 20, 2014 at 15:49
  • \$\begingroup\$ @Sider i am using libGdx for making games and it takes input like this Texture tex=new Texture(Gdx.files.internal("file path"); and TextureAtlas atlas=new TextureAtlas(Gdx.files.internal("atlas path")); \$\endgroup\$
    – Diljeet
    Feb 23, 2014 at 17:29
  • \$\begingroup\$ @Byte58 i am actually developing my first game so i don't really have any performance issues now, but for help could you please tell me more about profiler and how to actually use it \$\endgroup\$
    – Diljeet
    Feb 23, 2014 at 17:31

2 Answers 2

1
\$\begingroup\$

Yes, you can use different texture atlases for different screens. From technical standpoint you need to have a lookup structure to access textures knowing just their ID. Each ID should be linked with texture coordinates and size in relative space (0.0..1.0) or with regard to atlas size.

Basically there are several approaches which differ in quality and effort required:

  • Simplest, ship single atlas image with your application and resize it when initializing your application. Downsides are longer loading times on low-end devices (resizing takes some time) and lower image quality (blurry/jaggy depending on resize algorithm used)
  • Medium, resize the resulting atlas before packaging it into the application in Photoshop or alike. Then you can better control image quality. Downsides are that you will have to ship several atlases with your application, so that takes a bit more space. Images will still loose in quality.
  • Hard, resize (or even redraw) each texture individually for major screen sizes you are going to use and and pack them into different atlases for different resolutions. You should be able to generate atlases at any size with atlas generation tools, just supply list of textures to pack and atlas dimensions.
\$\endgroup\$
5
  • \$\begingroup\$ This isn't really answering the question. What's stopping OP from doing so is they're not sure how to resize. I know you're suggesting they supply multiple sizes in their shipped product, but you should make that more clear. If you're not sure exactly what someone is asking (since your answer has two follow up questions), you should ask the questions in the comments and wait to answer until you're sure what's being asked. \$\endgroup\$
    – House
    Feb 20, 2014 at 15:06
  • \$\begingroup\$ Rewrote with that in mind \$\endgroup\$
    – Kromster
    Feb 21, 2014 at 4:58
  • \$\begingroup\$ @KromStern Hello sir i am using libGdx for game development, i don't want to use "Simplest" solution, i can use Medium and Hard approach but i am still confused how to retrieve them for different devices, and also is the this the common approach used in games? i just want to know how other game devs do it? \$\endgroup\$
    – Diljeet
    Feb 23, 2014 at 17:40
  • \$\begingroup\$ Original question says: "How do I create differently sized texture atlases for different screen sizes?". I suggest you to post a new question focused on: "How to store and access different atlases for different devices using libgdx, (how other game devs do it) ?" \$\endgroup\$
    – Kromster
    Feb 23, 2014 at 18:08
  • \$\begingroup\$ @KromStern thanks for the suggestion i will try your question after a few days, if i will be unsuccessful in using these solutuins \$\endgroup\$
    – Diljeet
    Feb 23, 2014 at 18:35
0
\$\begingroup\$

Resize the image using standard java(?) functionality (BufferedImage) with the desired algorithm before you load it into a OpenGL texture. Otherwise, you'll just do scaling on the fly while rendering, and not saving any real memory usage.

Further things to think about once the resized texture atlas is resized:

How do you reference each texture in the atlas? By relative or absolute position? (Relative: 0.0 -> 0.1 on x and y coordinates). If it's relative, you can simply resize the atlas and it will still work. If not, you'll have to scale each texture position with the same ratio that you scaled the atlas with.

\$\endgroup\$
4
  • \$\begingroup\$ He's asking how to resize, and you're just confirming that resizing is a good idea. \$\endgroup\$
    – House
    Feb 20, 2014 at 15:04
  • \$\begingroup\$ I'm assuming he's just not asking how to resize an image, - I doubt that's a question suited here? \$\endgroup\$
    – Terje
    Feb 20, 2014 at 15:06
  • \$\begingroup\$ I believe he's asking how to resize it on the fly, in game. \$\endgroup\$
    – House
    Feb 20, 2014 at 15:11
  • \$\begingroup\$ @Terje : yes i am asking how to resize images, i mean how they are resized in common games, what method is actually used. I use libGdx. \$\endgroup\$
    – Diljeet
    Feb 23, 2014 at 17:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .