PDA

View Full Version : Best technique to render the same model in different locations



jwilliams
05-07-2004, 07:11 AM
I was curious, what is the best way to render multiple instances of the same model?

specifically, I have my vertex data and indice data for a model in separate VBO's. But each instance of the model has a different transformation matrix. It would seem like I could bind the VBO's and then use MultiDrawElements, but I cannot do that because I have to call glLoadMatrix between each model...

Any suggestions? does this even make sense, I can try to rephrase my question if it doesnt

-NiCo-
05-07-2004, 07:29 AM
Like you said, MultiDrawElements does not allow you to change the modelviewmatrix for every instance.
Just use

load matrix 1
DrawRangeElements
load matrix 2
DrawRangeElements
load matrix 3
DrawRangeElements
...

N.

jwilliams
05-07-2004, 07:40 AM
Well I am trying to draw thousands of billboard trees... I am beginning to think i might be better off just building up one big buffer with the triangles in world space and rendering them in one batch... basically sacrificing memory for speed... but then that's what memory is for i guess

dorbie
05-07-2004, 07:49 AM
Depends on the complexity of the objects, in your case having groups of billboards in a single group of primitives would be better. Quads may be worth exploring because you can send a single primitive but your mileage will definitely vary. Whether you want to try linking them with degenerate triangles to try to draw groups of trees as a single mesh primitive is another issue but probably something very worth exploring.

harsman
05-07-2004, 11:00 AM
If you have some sort of spatial or bounding volume hierarchy that you use for your scene graph it migh be possible to store lower LODs in non-leaf nodes. That way, you get O(log n) complexity. It doesn't always work, matching edges tends to be a pain, but it works very well when it does (see Thatcher Ulrich's chunked LOD for a real world example).

simongreen
05-07-2004, 05:18 PM
Direct3D vertex shader 3.0 includes an instancing API which is intended to help with this problem. It basically involves creating additional vertex streams that encode object transformations, so that you can draw many objects with one draw call.

The per draw-call overhead in OpenGL isn't as bad as Direct3D, but we're considering an OpenGL extension to expose this functionality on the GeForce 6 series.

There are some details on page 22 of this presentation:
http://download.nvidia.com/developer/presentations/GDC_2004/Dx9Optimization_AshuRege.pdf

-S.


Originally posted by jwilliams:
I was curious, what is the best way to render multiple instances of the same model?

specifically, I have my vertex data and indice data for a model in separate VBO's. But each instance of the model has a different transformation matrix. It would seem like I could bind the VBO's and then use MultiDrawElements, but I cannot do that because I have to call glLoadMatrix between each model...

Any suggestions? does this even make sense, I can try to rephrase my question if it doesnt

Ozzy
05-08-2004, 09:27 AM
What about NV_primitive_restart extension?