Archived

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

White Rabbit

Texture Mapping: The easy, the hard, and the fast way?

Recommended Posts

Hi there, i''ve been doing some coding, and i came to the conclusion that, if we want our engine to render fast scenes, we can keep continuasly bindding new textures. What i want: I want my render funtion to make the smallest amout of texture binds possible, for that the optimal situation would be for me to have a vertex array, and a single texture, that texture would have somehow all the textures that would be used in that map, and i would just have to give the right coordenates to use them. Problem: How do i reduce the amount of texture bind calls? How do i combine the textures all into a smaller number of textures? Is there a "by the book" way of doing this(programs, filters, plugin''s)? Or is this the ultime job for the artists? Give me some input on this please, i''ve talked to some friends, and the "artist" word allways comes arround, isn''t there a fairly easy and fast way of doing this without resorting to them? "Follow the white rabbit."

Share this post


Link to post
Share on other sites
nope, you have to sort by texture. combining textures means they likly wont scale correctly due to bilinear filtering. turn that filtering off, and you will have your game looking like back when 3d hardware was a luxury. the asy way is ussually not the best way (and in this case for a 3d game, its the worst way). texture switching is not too expensive, assuming you are drawing a decent amount of polys per call and they all fit in vram.

in fact its more common to have a texture split into smaller textures because its too big.

Share this post


Link to post
Share on other sites
bool CRender::BuildTextureQueue(void)
{
CProgressBar Bar("building rendering clusters",25,Surfaces,FALSE,0);
Bar.SetStep(1);

register int i,j;
////////////////////////////////////////////////////////
// builds rendering queue
if ( (RenderCluster=new RENDERCLUSTER *[ Surfaces ])==NULL )
return false;
for ( i=0; i {
if ( (RenderCluster[ i ]=new RENDERCLUSTER )==NULL )
return false;
}
/////////////////////////////////////////////////////////
// clear surface flag
for ( i=0; i.Visited=false;
/////////////////////////////////////////////////////////

int indices,cluster;
bool found;
cluster=0;

for ( j=0; j {
found=false;
if ( Surface[j].Visited==false )
{
Surface[j].Visited=true;
Surface[j].RenderQueue=RenderCluster[cluster];
indices=1;
found=true;
for ( i=0; i if ( Surface[i].Visited==false)
if ( strcmp(Surface[i].TextureName,Surface[j].TextureName)==0 )
{
Surface[i].RenderQueue=Surface[j].RenderQueue;
Surface[i].Visited=Surface[j].Visited;
indices++;
}

if ( (RenderCluster[ cluster ]- >SurfaceIndex=new int [indices ])==NULL ) return false;
RenderCluster[ cluster ]->items=indices;
}

Bar.StepIt();

if ( found==true ) cluster++;
}


Bar.DestroyWindow();

///////////////////////////////////////////////////////
return true;
}



maybe the post is messy , but correct if you mean how can i do to draw different textures avoind a lof of texture bind state change , then the code job is that, in my engine i have a lot ,lot of surfaces each with a texture whose ( <--??? ) name
is in the string name fiels inside the surfaces struct, i
cycle through all the surfaces , i read the name and i punt in a render queue , i svae the index in the surface structure , so i have a sequential range in the renderquee array which holds the index f the surfaces having the same texture, when its time to render i just read the index for the surface ( triangle ) and i render each render queue and i get only a new binding when i have to draw all the triangles sharing the same texture, i hope its clear because my english is getting rusty as i get older and older , byez

Share this post


Link to post
Share on other sites
There are some things i don''t understand in this site

1) why when i put the code, it is cut in pieces and not complete

2) my password and username disappears


Share this post


Link to post
Share on other sites