Archived

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

Riskbreaker

Intelligent Vertex Buffer use and Indexing

Recommended Posts

Riskbreaker    122
I''m coding Brian Turner''s implementation of the ROAM algorithm for terrain using DirectX, if you''re familiar with it... anyway, here''s my question. I want to load all the vertex information from the height field in a vertex buffer and use indices to tell D3D how to link up the needed triangles. The ROAM algorithm only creates a certain number of triangles depending on the eye point, and I was planning on loading in ALL the vertex information from the height map into the vertex buffer... this means if my height map is 1024x1024 resolution, it''ll load in around 1048576 vertices into the buffer and navigate among those to link the triangle it needs. I guess my question pertains to how D3D handles vertex buffers. Is this inefficient, or once the vertices are loaded, does it not need to load them again? I hope that makes sense. Thanks to any D3D gurus who know! Riskbreaker

Share this post


Link to post
Share on other sites
Yes, it is inefficient. You don't want to transform every single vertex every single frame, which is exactly what will happen regardless of what indices you give it. I would just use dynamic buffers and refresh the entire buffer each time some part of the geometry changes, loading the currently visible vertices into the buffer.

I use a more complicated but faster method by only refreshing the data that wasn't already in the buffer, and taking advantage of both dynamic and static buffers, but I'm not writing a heightmap engine - my data is more structured and a little more static. So you should go with the above method.

~CGameProgrammer( );

EDIT: Even if you use static buffers for your method, it will still be slow. For optimization, Direct3D transforms everything in the vertex buffers in one loop, it doesn't go through the slow process of reading the index buffer, determing whether that vertex was transformed already or not, and then transforming it.

[edited by - CGameProgrammer on October 19, 2002 12:51:32 AM]

Share this post


Link to post
Share on other sites
BrianH    145
DirectX transforms only the vertices that you tell it too in the call to DrawIndexedPrimitive... thats what the ''MinIndex'' and ''NumVertices'' parameters are for. It will not just transform the entire buffer unless you tell it too with those parameters (i.e set MinIndex = 0 and NumVertices = number of vertices in the entire buffer).

-BH

Share this post


Link to post
Share on other sites
Well yeah, but that''s useless to me since the vertices are not ordered with undrawn ones first and drawn ones next, or anything like that. Those parameters only allow you to specify which range of the vertex array to transform, but it''s not selective... it doesn''t read the index buffer.

~CGameProgrammer( );

Share this post


Link to post
Share on other sites