Sign in to follow this  

Texturing Optimization

This topic is 4244 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

Would it be possible to optimize texturing by combining all textures in to one(or more) textures and updating the texture transform state instead changing the texture itself? If so, how would one go about combining textures.

Share this post


Link to post
Share on other sites

Heya,

There's a few constraints regarding this AFAIK.

Modern graphics cards have a max. texture size of 4096x4096. So your texture could not be bigger than this. And if you are targeting older cards...the limit is even lower I think.

Basically, your'e going to create one big texture in direct3d. Lock it and obtain a pointer to its memory. Now you start copying your texture data. How you copy it depends on how you want your smaller textures to be placed in the big one, their color depth and so on. Afterwards unlock it and use it like a normal texture.

To be honest, because of the texture size limit...your'e bound to end up changing textures at some point even if your'e using this technique unless you can fit your entire game ( or levels, whatever textures your'e going to to use ) into one texture.

Rather focus on rendering your stuff batched by texture.

- Pure


Share this post


Link to post
Share on other sites
It's often a good idea to pack textures; because of less texture changes, and because video mem can often be used more efficiently.

I use this technique:
http://www.blackpawn.com/texts/lightmaps/default.html

Share this post


Link to post
Share on other sites
The technique is called "Texture Atlas". Google it up or try nVidia (or was it ATI`s?) utility.

Also, you could sort-of bypass the problem if all your textures don`t fit into one huge texture. Provided you don`t need more than 1 or 2 texture stages (for example outdoor objects usually don`t need additional lightmap texture), you would just bind the huge textures untill all available texture units are filled. Then you would just use SetTextureStage commands so that it doesn`t blend with previous / next stages, and just switch Vertex shader which would output the specific object`s text.stage tex coords. This requires sorting by texture anyway, so it`s easy to just switch to different shader (or use branching if you can).

4 textures of 4096x4096 dimension give you the equivalent of huge 8192x8192 - that`s a pretty massive amount of texture data. However, that`s also a pretty massive amount of video memory - 128 MB at 16-bit quality and no mipmaps, so DXT compression is necessary (but it`s artifacts are invisible for most purposes, so you`ll use it anyway). With DXT, it shouldn`t take more than ~26 MB internally (+mipmaps), so that could be acceptable these days when new games refuse to run an anything with less than 64 MB of VRAM.

EDIT: I forgot to add the most obvious thing: Always test whether the object REALLY needs the current dimension of its texture because it might not get bigger on screen than, say, 300x300 pixels and so it definitely doesn`t need texture bigger than this (or 1024x1024 "just to add more detail" which is invisible anyway).

Share this post


Link to post
Share on other sites

This topic is 4244 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this