Non-Power of 2 Texture
I'm in the process of creating a little app that mates USGS DEM (digital elevation) data to an image (a registered map of some kind). The DEM data gets turned into a mesh, the image is the texture for said mesh.
The problem here is that the image is rarely going to be in power of two dimensions, and I can't resize it (via stretching or shrinking) as it will distort the image too much.
The obvious, though to me somewhat inellegant way around this, is to add padding around the image to get it up to a power of 2.
Anybody have a better way to do this?
Quote:Original post by ff8
Use this extension GL_ARB_texture_non_power_of_two .
bye
Ah... forgot to mention. This has to be able to run on an old machine... or rather, old video card. I'm not counting on anything greater than OpenGL 1.2 functionality, so swanky extension won't do. Thanks, though.
Quote:Original post by glGuy3fWhile it sounds inellegant, I believe that it is the standard method, since the non-power-of-2 stuff is hardware dependent, and even now I think the majority of cards on the market don't support it. (I don't know how exactly this works with OGL, but that's how it is with D3D, so I suppose since it's a hardware limitation, it's the same on both.) I know that I use this method all the time, as it has been in all the sample code that I've looked at whenever it was needed.
The obvious, though to me somewhat inellegant way around this, is to add padding around the image to get it up to a power of 2.
hey,
Rounding up to the next power of 2 is what I would consider the 'standard' way of doing things. If you're concerned about memory wastage [on cards where it's available] you may want to look into putting in an alternate path for non power of 2 textures.
An alternative [with the next power of 2] is clipping the textures so that you don't get so much wastage... IE, bad diagram:
Texture [300x70]:
||||||
Gets turned into texture [256x128]:
|||
=
or some other such equivelent system. Of course, this really isn't so great if you're not sure of the dimensions before hand. In that case, I'd probably try to put two or more textures into the 'spare' space remaining on the texture.
CJM
Rounding up to the next power of 2 is what I would consider the 'standard' way of doing things. If you're concerned about memory wastage [on cards where it's available] you may want to look into putting in an alternate path for non power of 2 textures.
An alternative [with the next power of 2] is clipping the textures so that you don't get so much wastage... IE, bad diagram:
Texture [300x70]:
||||||
Gets turned into texture [256x128]:
|||
=
or some other such equivelent system. Of course, this really isn't so great if you're not sure of the dimensions before hand. In that case, I'd probably try to put two or more textures into the 'spare' space remaining on the texture.
CJM
another solution is to change your texture coordinates from UV to texel positions and use GL_ARB_texture_rectangle (GL_EXT_texture_rectangle on older cards, same Enum's though)
compatability is great on NVIDIA (GeForce2+) and looks great on ATI (Radeon 7000+) but ATI's implmentation of the EXT version was pretty dodge AFAIK, though that has definatly changed in the ARB version (im using it just fine on my R9500 Pro)
compatability list for EXT_texture_rectangle
compatability list for ARB_texture_rectangle
OpenGL registry specs for ARB_texture_rectangle (which should be identical to the EXT version save the prefixes.)
Cheers
-Danu
compatability is great on NVIDIA (GeForce2+) and looks great on ATI (Radeon 7000+) but ATI's implmentation of the EXT version was pretty dodge AFAIK, though that has definatly changed in the ARB version (im using it just fine on my R9500 Pro)
compatability list for EXT_texture_rectangle
compatability list for ARB_texture_rectangle
OpenGL registry specs for ARB_texture_rectangle (which should be identical to the EXT version save the prefixes.)
Cheers
-Danu
I'll look into those extensions, I might be able to use TEXTURE_RECTANGLE one, but we're talking about an old Matrox (G200, if I recall) card here. The initial texture is large, anyway: 5000x3000 give or take, so I'll have to be breaking it into tiles (256x256, most likely). Some of the tiles will still have to be padded though or, if it works, created via that extension.
Thanks for the help, much appreciated.
Thanks for the help, much appreciated.
Eh, you know, on my geforce6600 my max texture size is 4096x4096 you better be breaking it up :-p
cheers
-Dan
cheers
-Dan
IIRC you can use non power of 2 textures if you are using mipmaps, I think I read that in a nehe tutorial somewhere. Anyways hope that helps.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement