Loading High-Resolution Backgrounds Efficiently

For questions about using Classic.

Post » Tue Mar 23, 2010 5:22 pm

Hi folks, I'm wondering what the most time/memory efficient way of loading a big high-res image into Construct is. My game runs at 1280x720 resolution, so the backgrounds are that size per screen. However, loading giant 1280x720 textures into a backdrop object is clearly inneficient, and ends up slowing Construct down a fair bit.

I know that Construct prefers to work with power of two squared textures; would I be better off cutting up each backdrop into a sequence of power-of-two tiles, say 256x256, and importing them as seperate objects? Or, would I be better exporting the background image as one oversized power-of-two image (in this case, 1296x1296)?

Also, is any particular object best suited to loading backdrops like this? Backdrop, Tiled Backdrop, Sprite, do these add different strains on processing? Currently I've been using Tiled Backdrop for all my static backgrounds. Any help or ideas would be appreciated,

Cheers, Tom
B
2
S
1
G
5
Posts: 50
Reputation: 1,500

Post » Tue Mar 23, 2010 6:06 pm

[quote="chaosmaster":2kgdshmp]would I be better off cutting up each backdrop into a sequence of power-of-two tiles, say 256x256, and importing them as seperate objects? Or, would I be better exporting the background image as one oversized power-of-two image (in this case, 1296x1296)?[/quote:2kgdshmp]

first is preferable
besides there's no need in loading your picture slices singly. Just load them as frames of the first slice. that'll simplify your work in editor window.
PS. Don't forget to set animation speed to 0 though
B
23
S
2
G
4
Posts: 36
Reputation: 2,822

Post » Tue Mar 23, 2010 6:38 pm

Cutting up the texture would probably be best, like nowon said.

[quote="chaosmaster":36sh198p] Or, would I be better exporting the background image as one oversized power-of-two image (in this case, 1296x1296)?
[/quote:36sh198p]

I dont think 1296x1296 is a power of 2. The next up would be 2048. http://en.wikipedia.org/wiki/Power_of_t ... ers_of_two
B
77
S
49
G
25
Posts: 346
Reputation: 17,409

Post » Tue Mar 23, 2010 6:40 pm

All images take up as much VRAM as the smallest power of 2 size they fit in. Each of your 1280x720 images are acting like 2048x2048 with most of that being empty space. Bad idea.

Also, what are these Backdrop objects? There's only Sprite and Tiled Background. Tiled Background is mainly made to save some time while rendering pow2 tiled images.
B
2
S
2
G
2
Posts: 372
Reputation: 1,794

Post » Tue Mar 23, 2010 8:00 pm

The most efficient way is to avoid loading big images like that. Are you sure you can't just make the background out of smaller instanced objects?

[quote="chaosmaster":2hcnjcz4]Or, would I be better exporting the background image as one oversized power-of-two image (in this case, 1296x1296)?[/quote:2hcnjcz4]

No, don't do this; some (most?) newer graphics cards can handle textures that aren't square. Whenever possible, try to make square power of two textures, but if you absolutely need a big rectangular image, just keep the texture as small as possible, and try to keep height and width the smallest power of two possible. Don't add blank space just for the hell of it; You lose performance for both the old and newer graphics cards that way.

[quote="chaosmaster":2hcnjcz4]would I be better off cutting up each backdrop into a sequence of power-of-two tiles, say 256x256, and importing them as seperate objects?[/quote:2hcnjcz4]

You save some VRAM this way, especially if your texture is a really irregular shape.

But like I said, always try to use small objects to build the background, if possible.
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Tue Mar 23, 2010 8:34 pm

[quote="Mr Wolf":3g3s3ta7]All images take up as much VRAM as the smallest power of 2 size they fit in. Each of your 1280x720 images are acting like 2048x2048 with most of that being empty space. Bad idea.
[/quote:3g3s3ta7]

Wouldn't that be 2048x1024?
B
28
S
8
G
8
Posts: 530
Reputation: 7,154

Post » Tue Mar 23, 2010 9:42 pm

[quote="Guyon":2wnwl8d2][quote="Mr Wolf":2wnwl8d2]All images take up as much VRAM as the smallest power of 2 size they fit in. Each of your 1280x720 images are acting like 2048x2048 with most of that being empty space. Bad idea.
[/quote:2wnwl8d2]

Wouldn't that be 2048x1024?[/quote:2wnwl8d2]
That depends on the GPU, but for most computers these days, I'd say yes.
B
2
S
2
G
2
Posts: 372
Reputation: 1,794

Post » Wed Mar 24, 2010 1:11 pm

I think all graphics cards can support 1024x1024 textures, so for greater convenience you can cut textures in to chunks of that size. If you have edges to cover, you can cut them in to say 256x256 squares and they will use less VRAM than another 1024x1024 texture. Basically, the rule of thumb is to assume your texture is placed on the smallest square power-of-two size surface that can entirely fit your image (so 1024x50 size textures is probably a bad idea - it could use 1024x1024 size surface and waste VRAM - but some modern cards might be able to use rectangular power of two and place it on 1024x64).

But as Davioware said, you'll very quickly run out of VRAM this way. If you want low-end hardware to be able to play your game, you need to be thinking about 64mb cards, of which only 32mb may be available for your game to use (the rest used by OS, other apps etc). It's better to use tiling where you can, and add variations with scaled, rotated sprites for decoration. You can still get an interesting appearance that way, and with a much lower VRAM usage.

The tiled background object with a power-of-two size texture is a very efficient way to tile an image (it draws as fast as a single texture no matter how much you tile it). You lose that if it's not using a power-of-two size texture though.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,610

Post » Wed Mar 24, 2010 1:54 pm

[quote="Ashley":pg3j99pk]The tiled background object with a power-of-two size texture is a very efficient way to tile an image (it draws as fast as a single texture no matter how much you tile it). You lose that if it's not using a power-of-two size texture though.[/quote:pg3j99pk]
When using the Tiled Background's "Power-of-two Only" abilities, it counts 128x64 as pow2, but is it still getting the speed boost when doing rectangle pow2?
B
2
S
2
G
2
Posts: 372
Reputation: 1,794

Post » Wed Mar 24, 2010 1:58 pm

I think that's dependent on whether your graphics card supports rectangular power-of-two textures - it might not work on someone else's video card that doesn't support it.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,610

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests