Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

nagromo

many textures bad?

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

Is it a bad idea to usemany textures? I planned on using one 512*512 texture for the map and several 256*256 textures for different characters. Is this very restrictive with changing textures? Is it OK if I have many textures loaded but only use different ones at different times?

Share this post


Link to post
Share on other sites
Advertisement
Too many textures means alot of server-state changes per frame, which gets expensive as it requires data transfer across the AGP bus. As long as you try and sort your objects by texture, this shouldn''t be -too- much of a problem, unless you have many objects each with their own, different texture. Usually it only gets this severe with something like fonts or animated sprites.

Share this post


Link to post
Share on other sites
how much problem is it for OGL to switch textures if all the data is in video mem? I would think it wouldn''t be much more than a pointer change, but i have no clue.

Share this post


Link to post
Share on other sites
According to my experience, changing textures (as long as you have a decent video card) is NOT a problem. They get cached pretty well, and changing the textures has a far less penalty than other things, up to the point that it isn''t even noticeable, unless you do that an insanely amount of time/frame.

Share this post


Link to post
Share on other sites
Texture changes are reasonably cheap IF all textures you use during a frame fit on the on-board VRAM, after frame buffers (z, rgb, screen, etc) are subtracted (with padding).

If they''re not, then you will start thrashing, which is bad. If you sort your textures, it''s still bad, because you''ll kick out the first texture to fit the last, and then start over -- LRU leads to worst possible performance as soon as you''re over the limit of available texture memory.

The real thing to do here is to allow the user to choose texture resolution levels, i e "more detail" and "less detail" to adjust quality vs performance. You can easily do this by including the highest resolution textures, but ignoring the top one or two mip map levels if the settings is lower.

If you still are thrashing, sorting in alternating orders, so that the textures used last on one frame are used first the next frame, will make degradation more smooth than typical LRU with static sort order.

However, a 512x512 is only 128 kB when DXT1 compressed, or 1 MB when uncompressed in RGB(A)32 format. Most modern cards have 32 MB or more of framebuffer and texture memory; figure 12 MB is used for frame buffers, so you get 20 MB for textures. You can fit a lot in that :-) (I really, REALLY recommend using DXT1 and DXT5 compression)

Share this post


Link to post
Share on other sites
please talk me up on compression. I''m not at a point yet where i would waste my 64MB of memory even with no compression, but i sure plan to :-)

Right now i''m just loading images via SDL_Surfaces, like so. Where would i use the compression and how is it done? very interested.


/* Create storage space for the texture */
SDL_Surface* img = IMG_Load(file);

if ( img ) {

// convert the surface to a common BGRA format

// this avoids problems with loading different image types

SDL_Surface* newimg = SDL_DisplayFormatAlpha( img );

// free original image

SDL_FreeSurface( img );

GLuint texture = 0;

/* Create The Texture */
glGenTextures( 1, &texture );

/* Typical Texture Generation Using Data From The Bitmap */
glBindTexture( GL_TEXTURE_2D, texture );

/* Generate The Texture */
glTexImage2D(
GL_TEXTURE_2D,
0,
4,
newimg->w,
newimg->h,
0,
GL_BGRA,
GL_UNSIGNED_BYTE,
newimg->pixels
);
}

Share this post


Link to post
Share on other sites
I am using the textures for animated sprites. The way I have it set up now, all frames of animation for one character will be stored on one texture and different texture coordinates will be used each frame for animation. While some characters may use the same sprite, there will likely be a variety of characters shown at once with different textures.

I am also using a font, but I don''t see why that should take more than one 256*256 texture. Would you have a different texture for each string? The way I had envisioned it is to have ascii 0-255 on one texture and draw one quad for each character. Is there a better way?

Also, does DXT1 or DXT5 preserve alpha, and are they very widespread on older cards?

Share this post


Link to post
Share on other sites
Don''t do your animations like that, if posible.
Instead, create a texture with all the frames (assuming the frames are not very big, and have the same size). Try to minimize updating textures ifpossible, that''s relatively slow.
As for teht ext, yes, a 256x256 file is enough, unless you want to have more fonts, and/or things such as italics, bold, etc.

Share this post


Link to post
Share on other sites
quote:
Original post by Raduprv
Don''t do your animations like that, if posible.
Instead, create a texture with all the frames (assuming the frames are not very big, and have the same size).

Isn''t that what he said he was doing?

quote:
Original post by nagromo
Also, does DXT1 or DXT5 preserve alpha, and are they very widespread on older cards?

DXT1 stores only a 1 bit alpha and seems to store colour data as 16 bit on NVidia cards (not sure about GeforceFXs or the Geforce 6, though). If you''re not concerned about the colour, though, it''s a decent format for storing textures with an alpha mask. DXT5 preserves the alpha channel -much- better and looks very good in general. Both are supported on most video cards.

Share this post


Link to post
Share on other sites
quote:
Original post by Ostsol

quote:
Original post by nagromo
Is it a bad idea to usemany textures? I planned on using one 512*512 texture for the map and several 256*256 textures for different characters. Is this very restrictive with changing textures? Is it OK if I have many textures loaded but only use different ones at different times?


quote:
Original post by Raduprv
Don''t do your animations like that, if posible.
Instead, create a texture with all the frames (assuming the frames are not very big, and have the same size).

Isn''t that what he said he was doing?



No

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!