Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Atlas Map Sizes - 2048...4096...8192?

Author
Message
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 3rd Nov 2017 18:34
Hi All,

In my game I'm currently using atlas maps measuring 2048 x 2048 pixels for tiles and monster sprite sheets. I'm targeting PC and Mac only (not mobile) for my game. Is it safe to use 4096 x 4096 atlas images (or even 8192 x 8192 if I ever need that size)? It would be a bit more efficient for me and I've heard that using fewer images is better for performance but before I convert my 2048 images into fewer larger ones I thought I'd check on people's experiences. For example is there a limit for subimage.txt file length? For example a 4096 x 4096 atlas image for 64px tiles would yield a subimage text file 4096 lines long (and an 8192 image would give 16384 lines)!

Would these sized subimage text files and/or the size of the images themselves give problems on some modern-ish PCs? Or am I sounding like Ali G when he asked the computer expert if there would ever be a computer that could add 999,999,999,999 to 999,999,999,999?
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 3rd Nov 2017 21:05 Edited at: 3rd Nov 2017 21:29
Quote: "Images

Optimizing images is mostly about saving memory as raw image data can take up a lot of space. A single 1024x1024 image uses 4MB (1024*1024*4), whilst a 2048x2048 image uses 16MB (2048*2048*4) and with mobile devices usually sharing video memory with RAM a device can quickly run out and close your app without warning. This is different from the image format used to save an image like PNG or JPG since the GPU loads it into an uncompressed format that takes up more space.
Use the smallest image resolution necessary

Since AppGameKit version 2.0.20 images no longer need to be a power of 2 in size, this means you are no longer limtied to sizes such as 1024x512, so if your image only needs 900x460 pixels then use an image size of 900x460 as that will help save memory. There are two exceptions to this, if you want to use UV offset or scaling to repeat the image multiple times, or if you want to use mipmapping, then the image must be a power of two in size. If you can get away with the quality reduction, you can also use a low quality image like 500x250 and display it using a sprite at a larger size using SetSpriteSize(SpriteID, 960, 460) as this improves loading times and reduces memory usage.
Keep as few images loaded as necessary

You should try to load images only when necessary, and delete them when you no longer need them. This is because images are one of the biggest consumers of memory (along with 3D objects), so keeping as few in memory as possible will prevent your app from crashing because the device ran out of memory. A rough guide is to have no more than about 250MB of image data loaded at any one time, but this will vary depending on the devices you are targetting. Higher end devices will be able to keep more in memory without crashing. To calculate how much memory an image will use when loaded into memory, multiply its width by its height and multiply by 4, for example a 500x500 image would consume 500*500*4 = 1,000,000 bytes, or 1MB
Use atlas textures

An atlas texture is an image that contains multiple textures on it which means a single image can be shared with multiple sprites to improve performance. Sprites that share the same atlas texture can be drawn at the same time which is faster than drawing sprites one at a time. One disadvantage to using atlas textures is that you cannot do UV scrolling with the textures it contains as modifying the UV will reveal the other textures sharing the image space. To load images from an atlas texture use LoadImage to load the atlas texture and then LoadSubImage to load images from it. You may use these sub images just like you would any other image. It is generally a good idea to leave 1 or 2 pixels of space between each image on an atlas texture to avoid them bleeding into each other during sampling. If you are using atlas textures with mipmapping turned on then you may need to increase this spacing further depending on how the image is used.
Do not use images greater than 2048 in size

Whilst some devices do support images greater than 2048, for maximum compatibility it is highly recommended that you do not exceed 2048x2048 for a single image. If you do end up using larger images and the device trying to load them does not support that size then AppGameKit will scale the image down to the maximum supported size and continue loading as normal, however this may increase loading times.
"


I'd say 2048 max

Atlas for images shared

Unique sizes for unshared


Quote: "or am I sounding like Ali G when he asked the computer expert if there would ever be a computer that could add 999,999,999,999 to 999,999,999,999? "

Da West Staines Massif

I ran into problems when displaying large prime numbers because more than X digits (depending on the math processor) got displayed with that 'E' crap.

So, I wrote a little program in DB Classic that enabled me to work with Mersenne primes where I could display numbers in the tens of thousands of digits long. (or longer if I wanted)

I was checking outputs so I need the whole number as it would look on paper, not that E crap, but I had to pause each page of numbers as they were displayed so I could read it.

That of course was dealing with multiplication, but that can be done with addition, so it was possible and easy enough to do. (learnt dat at da Matthew Arnold Skool)

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 4th Nov 2017 09:18
Ok, thanks. I thought the size restrictions may only apply to mobile devices but it sounds like 2048 is about as large as you want to go.
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)

Login to post a reply

Server time is: 2024-09-30 09:21:15
Your offset time is: 2024-09-30 09:21:15