Question regarding memory/processor CPU and number of images vs size of images.

Hello,


I have a really basic question, hopefully someone can answer this for me. If i'm making a game and the map background image is going to be a 1000 x 1000 image (for the sake of the example). Which of the following would use the least processor CPU and memory? Which would use the most?


Option 1: One large 1000 x 1000 image loaded in the background.

Option 2: 10 instances 100 x 100 images loaded in the background (put together they create the 1000 x 1000 image)

Option 3: 100 instances of 10 x 10 images loaded in the background (put together they create the same 1000 x 1000 image).


I would assume breaking the image down into smaller segments would consume less memory and CPU than processing the entire 1000 x 1000 image at all times.


However at what point does breaking the image down start increasing the memory and processor usage? Say using 1000 1 x 1 images compared to using 100 10x10 ones.

I think the graphics hardware generally takes care of the work, and 1,000 x 1,000 isn't really that exterme for modern hardware. But it would generally handle breaking down the image into smaller chunks if necessary, or drawing only the part of the image that needs to be drawn.


The texture atlas feature of Xcode / SpriteKit actually combines smaller images together into larger image files, in order to improve drawing performance by the graphics hardware. The texture atlas uses images of up to 2048 x 2048 on iOS 7, and 4096 x 4096 on iOS 8, to give you a concrete example of the sizes the graphics hardware can generally handle efficiently.



You could still use smaller tiled versions of the large image in your code if you want, but the problem you run into if you subdivide the image yourself is that the amount of work and data your code would need to handle increases exponentially as you subdivide the image.


For example, if you split a 1000 by 1000 image into 500 x 500 chunks, you are dividing the sizes by 2 but it actually gives you four pieces (upper left, upper right, bottom left, and bottom right).


Dividing into 100x100 chunks means you are dealing with 100 pieces, or into 10x10 gives 10,000 pieces.



I would recommend starting with just using the full image to begin with, and worrying about subdividing it later if you have performance problems related to it.

So I just tried loading a plain green/grassy background image into my game. The background "map" was 1000 x 1000 but after testing it out I could actually use closer to 2000 x 2000 map size. The player in the game will need a lot of space to explore + at anytime there will be like 20 monsters chasing after him.


When I loaded the 1000 x 1000 background image it started to get choppy as the player ventured towards the middle of the map. When he went closer to the sides or off the map the FPS went back up. I didn't use any fancy coding to break the map down into parts or tell xcode to do any of that for me.


What do you suggest I do if I want to use a map around the size of 2000 x 2000... Please help and thank you for your time.

Assuming you are using Apple's SpriteKit framework, I'd recommend posting to the SpriteKit section:

https://forums.developer.apple.com/community/graphics-and-games/spritekit


You can probably get more help there.



You could also move this thread to that section, by going to the "Actions" buton/menu near the top on the right side, and choosing "Move". (Go to the bottom of the dialog which comes up, and choose spaces, then find "Graphics and Games" and click on where it says X subspaces, and then choose "SpriteKit".)

Question regarding memory/processor CPU and number of images vs size of images.
 
 
Q