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

Started by
2 comments, last by White Rabbit 21 years, 11 months ago
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."
"Follow the white rabbit."
Advertisement
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.
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=new RENDERCLUSTER )==NULL ) <br> return false;<br> }<br> /////////////////////////////////////////////////////////<br> // clear surface flag<br> for ( i=0; i<Surfaces;i++ ) Surface<i>.Visited=false;<br> /////////////////////////////////////////////////////////<br><br> int indices,cluster;<br> bool found;<br> cluster=0;<br> <br> for ( j=0; j<Surfaces; j++ )<br> {<br> found=false; <br> if ( Surface[j].Visited==false )<br> {<br> Surface[j].Visited=true;<br> Surface[j].RenderQueue=RenderCluster[cluster];<br> indices=1;<br> found=true;<br> for ( i=0; i<Surfaces; i++ )<br> if ( Surface.Visited==false)<br> if ( strcmp(Surface.TextureName,Surface[j].TextureName)==0 )<br> {<br> Surface.RenderQueue=Surface[j].RenderQueue;<br> Surface.Visited=Surface[j].Visited;<br> indices++;<br> } <br> <br> if ( (RenderCluster[ cluster ]- >SurfaceIndex=new int [indices ])==NULL ) return false;<br> RenderCluster[ cluster ]->items=indices;<br> }<br><br> Bar.StepIt();<br><br> if ( found==true ) cluster++;<br> }<br><br><br> Bar.DestroyWindow();<br><br> ///////////////////////////////////////////////////////<br> return true;<br>}<br><br><br><br>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<br>is in the string name fiels inside the surfaces struct, i <br>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 </i> <br><br>
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


This topic is closed to new replies.

Advertisement