Jump to content
  • Advertisement
Sign in to follow this  
glGuy3f

Non-Power of 2 Texture

This topic is 4819 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Quote:
Original post by glGuy3f
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.
While 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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Eh, you know, on my geforce6600 my max texture size is 4096x4096 you better be breaking it up :-p

cheers
-Dan

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Quote:
Original post by Ademan555
Eh, you know, on my geforce6600 my max texture size is 4096x4096 you better be breaking it up :-p

cheers
-Dan


Heh, no doubt. I remember, not so fondly, of the day when the good ol' Voodoo3 could handle 256x256, max. Sadly, I'm revisiting those days...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!