Game Development Community

TGEA 1.7.1 - DDS images that are non-pow2 render incorrectly.

by Stefan Lundmark · in Torque Game Engine Advanced · 06/23/2008 (12:21 am) · 8 replies

Edit: Just noticed I mistyped the subject-line. "Non-pow2" should be "Non-Square". Ie, 512x512 works but 800x600 does not.

If you save scriptsAndAssets/client/ui/unified_background.jpg as a DDS file, you'll notice that the bottom part of the image gets screwed when you load it ingame. This is also the case in 1.0.3, so it is not recently introduced.

#1
06/23/2008 (11:46 am)
Well... 512x512 is square and pow2. 800x600 is non-square and non-pow2. Try 512x256 for non-square pow2 and 800x800 for square non-pow2. Then we can say if it's non-square, non-pow2, or non-square and non-pow2 that's the issue.
#2
06/23/2008 (12:20 pm)
800x600 isn't pow2?
#3
06/23/2008 (12:29 pm)
No it's not. Pow2 numbers can be expressed in the form 2^x where x is an integer. e.g. 2^1 = 2, 2^2 = 4, 2^3 = 8, etc.
#4
06/23/2008 (12:45 pm)
Got you. And here's what I'm seeing:

512x256 - Bad.
800x800 - Good.
512x512 - Good.
#5
06/23/2008 (2:36 pm)
This is how it looks like:
img46.imageshack.us/img46/6622/tgeaqs1.jpg
Notice how the image is not cropped, it is just shrinked in its height. I have been trying to find where it is doing this for a while now but all I am seeing is the same stuff as a identical PNG.
#6
07/15/2009 (4:18 pm)
Sigh. I'm sure it was reported to be fixed before but since it wasn't, here goes:

GFXTextureManager.cpp @ 476
_validateTexParams( dds->getHeight(), dds->getWidth(), profile, numMips, fmt );

Should be:
_validateTexParams( dds->getWidth(), dds->getHeight(), profile, numMips, fmt );

GFXTextureManager.cpp @ 497
ret->mBitmapSize.set( dds->mHeight, dds->mWidth, 0 );

Should be:
ret->mBitmapSize.set( dds->mWidth, dds->mHeight, 0 );
#7
07/16/2009 (1:34 am)
Thank you, Stefan. Checked into repo and hopefully gone for good now.

In the process, I found two more instances where height and width got swapped.

In DDSFile, the getSurfaceSize method that takes only a miplevel has the problem (within DDSFile, height always comes first).
In the GFXTextureManager::_createTexture method you have changed above, the _createTexture calls do this as well (in TGEA, there's only one).

//Edit: Hmm, found that the swapping is necessary to get the correct pitch on texture surfaces with non-square DDSs. Too tired now to find out why.
#8
07/16/2009 (4:31 am)
Thanks. So the getSurface method is correct? Cool!