Archived

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

edotorpedo

Multiple vertex arrays

Recommended Posts

Hi, I''m working on a terrain-engine (GeoMM + quadtree), and I was wondering how to use vertex arrays with this. I traverse a quad-tree, and at each leaf I render the vertices. Would I need one big vertex arrays with an index array for each leaf, or is it possible to create multiple vertex arrays for each leaf. How would I do this? Thanks, Edo

Share this post


Link to post
Share on other sites
The possible ways of doing it:

a) One VB and IB for each node in your tree.
Simple to Implement, but not optimal.

b) One VB + n IB''s: as many IB''s as you can depending on what the hardware can achieve, e.g. until the vertex buffer is full ( some cards can do 32 bit index buffer, others only do 16 bit. )

Not as simple to implement as (a), but making optimal use of VB''s and IBs

I have not verified what the performance impact is between (a) and (b), so I''m not sure if the extra effort is worth it to implement (b).

Hope this helps.

Share this post


Link to post
Share on other sites
Unique VB for each terrain tile, and one IB for all of them (if they are regular of course). If the number of vertices in the VB is large enough then there is really no impact in switching VBs (especially if they have same FVF).

Share this post


Link to post
Share on other sites

OK, I think I will go for one VB at each leaf and n IB''s at each leaf (because I need to render leaves at different LOD).

But something still isn''t clear. How can you switch between two (or n) VB''s? You all load them using glVertexPointer, and this doesn''t return a pointer to this particular array, which you can use in glDrawElements().

How would one go about implementing this: do I need to call glVertexPointer for each leaf for each frame?

Thanks,

Edo

Share this post


Link to post
Share on other sites
If you have a regular grid for you terrain, you only need one IB for each level of detail, not n IB for each leaf. If you think about it, all of the leaves would end up with the same set of n IBs.

Karg

Share this post


Link to post
Share on other sites

But I don''t have a regular grid. I''m using GeoMipMapping, so I need an IB for each LOD-level of my leaf. I also need an Vertex Array for each leaf. But I still can''t figure how I can create more than one vertex array, without switching VA each frame. I just don''t get it, the only way of setting another VA is glVertexPointer, isn''t it ?? But I don''t feel like calling this 256 times each frame.

How can I do this.

Thanks,

Edo

Share this post


Link to post
Share on other sites
GeoMM is typically performed using a VB for each leaf but only n IBs for each LOD. The IBs are regular and don''t take account for the specific geometry in each leaf (that''s done using the rough error metric).

You could use an IB for each leaf but you''d probably still need regular edge meshing so you don''t get any cracks. Or you could use some alternative solution like edge skirts.

Share this post


Link to post
Share on other sites


You''re right Doz, I only need n IB''s for each LOD, not for each leaf. This will need some serious pointer work, because I need to access these IB''s at a leaf of my QuadTree. However, this will not be too much of a problem.

Does anyone accidently know the answer to my second problem (creating multiple vertex arrays), or maybe point me to an implementation?

Thanks for the replies so far,

Edo

Share this post


Link to post
Share on other sites
quote:
Original post by edotorpedo

You''re right Doz, I only need n IB''s for each LOD, not for each leaf. This will need some serious pointer work, because I need to access these IB''s at a leaf of my QuadTree. However, this will not be too much of a problem.

Does anyone accidently know the answer to my second problem (creating multiple vertex arrays), or maybe point me to an implementation?

Thanks for the replies so far,

Edo


If you have single VB per patch, you can live with only one IB.
And besides geomorphing, just unite four patches when they change LOD to greater into single one with same number of vertices.

Share this post


Link to post
Share on other sites

This won''t be possible in my implementation, because I calculate the LOD for each patch individually, so it may be possible that all my four neighbours all have different LOD.

But somehow I''m missing something. Either it''s incredibly simple but I''m just plain stupid, or nobody knows the answer:

Do I need to call glVertexPointer() for each leaf every frame ??? There''s nothing like activeVertexArray(int array) is there? So how do I load say 100 different vertex arrays into memory without resetting them each frame.

If I know this, I don''t think I will be having any more problems implementing this.

Thanks,

Edo

Share this post


Link to post
Share on other sites

Or in other words: how fast is glVertexPointer(). If I call this for each leaf, will it still be fast, or is there a way around this?

Thanks,

Edo

Share this post


Link to post
Share on other sites