Game Development Community

Scroller troubles...

by Nicolai Dutka · in Torque Game Builder · 06/01/2008 (1:48 pm) · 9 replies

I have made 3 scrollers. The first 2 work, but I made them like 2 months ago. Now, I am trying to make the 3rd and having major issues...

I add an image map, then go down to my scrollers and can see it there. Drag and drop it in. No problem. Tell it to scroll -5 on Y and suddenly, I am seeing HUGE chunks of white space. I am 100% certain I made my image tiling. The white space seems to be the exact same size as the image itself.

How can I get rid of this white space so it tiles properly?

#1
06/01/2008 (2:11 pm)
AHHH!! I see.... the image HAS to be SQUARE! Oh well, add some of my OWN whitespace on the edges and I am in business! :P
#2
06/01/2008 (2:11 pm)
This can happen if your image is not a power of 2
#3
06/01/2008 (5:17 pm)
Actually, the "power of 2" does not matter because the torque engine can handle ANY square image. The key is that is must be a perfect square.

I've used dozens of images that were not power of 2 with no problems at all.
#4
06/01/2008 (5:18 pm)
The image doesnt really need to be square... it just need its dimentions (in pixels) be power of two (128...256 or stuff like that), so that when scrollin, they "tile" seamlessly.
#5
06/02/2008 (4:41 am)
Sorry, but you are wrong on that one. It DOES have to be square and DOES NOT have to be powers of 2. Try it. I tried a 1024x2048 and got white space. Tried 1000x1000 and worked perfect. It MUST be SQUARE and powers of 2 does NOT matter.
#6
06/02/2008 (5:56 am)
For scrollers you must use a power-of-two image and it must be a single-framed image-map e.g. FULL mode.

I don't see how a 1000x1000 image could possibly work.

Melv.
#7
06/02/2008 (7:11 am)
512x2048 is a power of 2 and it sorta works, but you get the white space!

Have you ever tried anything less than powers of 2? It certainly DOES work. The engine automatically translates the image to the nearest power of 2, so if you give it a 1000x1000, it DOES work and the engine treats it as a 1024x1024.

I JUST FINISHED TESTING and can tell you with 100% certainty that the image DOES NOT need to be a power of 2, it only need be SQUARE! (Non-square images work too, but they generate white space when scrolling the image).

YOU CAN USE NON-POWER OF 2 IMAGES!! I JUST FINISHED using a 1000x1000. I also tried some other sizes to see what would happen and EVERY SINGLE ONE OF THESE works PERFECTLY:

121x345
250x250
640x127

You can give the engine ANY image size you want!!
#8
06/02/2008 (11:36 am)
Thats interesting. Less caps would be great.
#9
06/03/2008 (12:43 am)
Nicolai,

You could take what I say on faith but being as I wrote T2D I'd hope that counts for something. ;)

I don't doubt what you're seeing is real, it's just that it doesn't make sense knowing what I know.

The image-maps will relocate non-power-of-two frames into a compatible power-of-two image-map automatically but they won't rescale them. This confirms your statement that "you can give the engine ANY image size you want!!".

Detailed information on this process can be found in a document that I wrote here.

This means that for all T2D objects you can use any sized images you like (up to the maximum hardware texture size) but T2D will not rescale them, it only recreates textures that are compatible. To see the resultant textures you can go into your preferences and set "$pref::T2D::imageMapDumpTextures = 1;". This will create a folder called "imageMapDump" and dump all the calculated textures that result from the image-map options. This process can take a long time dependent upon how fast your disk is so be patient when starting-up.

The t2dScroller though is slightly different as it uses hardware wrapping of the textures to perform the "repeat" command. In other words the scroller uses the whole texture and not just a single frame within it. This makes it incompatible with anything other than an image-map set to "FULL".

This accounts for why you see whitespace. The texture(s) created by the image-map are cleared to white and the source frame(s) are populated within it. If you have a single frame that's not POT then the target image will be POT and the source frame will sit within it. When the scroller comes along and uses the whole texture you'll see whitespace to the right/below it.

Using a texture of 512x2048 (assuming your maximum hardware texture size is 2048 or above) is a POT and won't result in any target texture size change so the source frame will sit perfectly in it and will be completely compatible with the scroller.

Padding is something to watch out for. When you use the filter padding option (see document above) T2D will ignore it when you are using a FULL mode image if it is already a POT so that shouldn't affect a 512x2048 image set to FULL mode. If the image is something like 513x2048 then it would affect it.

Could you show the image / image-map for the 512x2048 image that apparently doesn't work? Also, one of the 250x250 that apparently does (including image-map)?

melv (*dot*) may (+at+) gmail (-dot-) com.

Melv.