Jump to content
  • Advertisement
Sign in to follow this  
scottrick49

Drawing many of the same model

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

I have a scene with a simple 3d model that is drawn hundreds of times, in different positions, orientations, and colors each time. What would be the best way to do this quickly? Right now I just have a for loop with:
glPushMatrix();
glTranslate();
glMultMatrix();
glColor();
glDrawArrays();
glPopMatrix();
And it isn't all that fast. Any thoughts / suggestions?

Share this post


Link to post
Share on other sites
Advertisement
First idea: put the model in a VBO, loop (up to 30k instances)
Second: instancing. Needs shaders. (140,000 instances @ 60fps ^^)

Share this post


Link to post
Share on other sites
Yeah I could use a VBO for the vertices, but I would still have to push, translate, mult, color and pop for every object though, wouldn't I?

Share this post


Link to post
Share on other sites
Those are not really bottlenecks. If they were, you'd have long gone into pure GL3.2 with custom maths, buffers, instancing, modern shaders, etc.

Share this post


Link to post
Share on other sites
Well, I'm working on an android device, so that really isn't an option.

Our scene renders quite nicely until we start drawing these extra objects. Just trying to get some ideas on ways to improve performance.

Share this post


Link to post
Share on other sites
Should have mentioned "android device" first >_<. Just try to put them in VBOs, if the target devices support it. Or pre-bake all these objects into one larger object.

Share this post


Link to post
Share on other sites
Quote:
Original post by idinev
Should have mentioned "android device" first >_<. Just try to put them in VBOs, if the target devices support it. Or pre-bake all these objects into one larger object.


Wikipedia says Android supports GL ES 1.0 so there is no VBO which doesn't matter anyway. He can just use regular vertex arrays.

Maybe his Android device doesn't have a good GPU or maybe no GPU at all, just a optimized software rasterizer.
http://en.wikipedia.org/wiki/Android_(operating_system)

Share this post


Link to post
Share on other sites
You can use Geometry Instance... search for "GL_ARB_draw_instanced" into google.

Maybe you can find some information.

If you want multiples instance... with different transformation... the simpler is to use glMultMatrix...

each instance (reference) must have a WorldMatrix that will replace the original one. (Like this you avoid to update/create the world matrix at each render pass).
Use glLoadMatrix to load this initial matrix and for sub-elements... use glMultMatrix...

If you find a better solution... please share it ;-)

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.

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

Sign me up!