Jump to content
  • Advertisement
Sign in to follow this  
cozzie

Rendering order for my objects

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

Hi. At this moment the object rendering part of my GLscene::Render() function looks like this: for(c=0;c<nr_objects;c++) { .... select material(with texture) for this model; draw the vertexarray; ... } Would it save me a lot if I sort out the objectnumbers with the same material/texture, so I only need to select al materials/textures one time? [Edited by - cozzie on October 14, 2004 7:39:59 AM]

Share this post


Link to post
Share on other sites
Advertisement
Related question: What's the most expensive, texture change or loading a new model view matrix?

Share this post


Link to post
Share on other sites
Quote:
Original post by _the_phantom_
yes, texture state changes are expensive, you want to minimise the changes during any perticular scene as much as you can


phantom .. does this include glEnable(GL_TEXTURE_2D) and glDisable? I can see how changing textures is expensive but I've heard that just doing these state changes has its own penality.

Share this post


Link to post
Share on other sites
Sort by pixel shader, then by texture.

If you are fillrate limited, you might also want to consider rendering from front to back, or laying down a quick ambient pass first if you're using some expensive shaders. Modern cards do an extra early z-test near the beginning of the pipeline that can help eliminate hidden pixels.

Share this post


Link to post
Share on other sites
I don't think I have to choose if I want to alter the model or projection matrix OR select the correct texture more times.

The only thing I will do is change the object rendering loop in my GLscene::Render() function.

Now it's:

for(c=0;c<nr_objects;c++)
{
...
select material that belongs to objects[c];
draw objects[c];
...
}

And this is something like what it will be:

for(c=0;c<nr_materials;c++)
{
select materials[c];
for(c2=0;c2<nr_objects;c2++)
{
if(objects[c2].material) == c)
{
...
draw object
...
}
}
}

I wonder if this will save me a lot, because I have to go through all objects to check what the material is, and that for every material in the scene..

I wonder if there's a quicker way

Share this post


Link to post
Share on other sites
Make something called a material group. When you render your objects, you basically just add them to the relevant material group. Then you render your material group.

eg.



for(c=0;c<nr_objects;c++)
{
AddToMaterialGroup(object, object.materialID)
}

for (c=0;c< nr_materialgrps;c++
{
if (materialgroup[c].numobjects > 0)
{
SetupMaterialGroup();
for (j = 0; j < materialgroup[c].numobjects; j++)
{
// draw object
}
}
}




The idea is that your material group keeps track of a list of pointers to objects. This list is cleared at the beginning of every frame. Then when 'rendering' your object, you're actually just adding it to the correct material group.

Then to render batched by material, you simply render the material group.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!