Indexed vertex arrays and landscapes.

Started by
9 comments, last by Arch@on 20 years, 10 months ago
Cheers. I was wondering what is the idea of using vertice arrays in landscapes? Wouldn''t they be more suitable for models? For 5*5 array(heights[25]) I would have to store each one of the values I''d get from x and y loops with triangle strips, meaning that my memory cost would have extremely significant increase. By using triangle strips I could also avoid creating same vertice twice. Can someone please elaborate. Storing indices and vertices for 1024x1024 heightmap seems just too much. I''m using the method explained in opengl super bible.
Advertisement
1024x1024x12 (3 floats, 4 bytes each) = 12mb. That doesn''t seem that far out for a nice size terrain, and if you''re using much larger terrains than that, nobody says you must load it all in memory at once, you could stream it in also, but that''s a whole nother topic.
quote:Original post by Ready4Dis
1024x1024x12 (3 floats, 4 bytes each) = 12mb. That doesn't seem that far out for a nice size terrain, and if you're using much larger terrains than that, nobody says you must load it all in memory at once, you could stream it in also, but that's a whole nother topic.


But you are not including indices are you?

How should I get around this? Do i just create 1024x1024 array from 0 to numVertices and then pass that to glDrawElements?

Does not seem to be very optimal to first store 1024x1024x3(triangles)x3(vertices)

and then store indices from 1024x1024?

that way you'd call

glVertexPointer(3, GL_SHORT, 0, map->getVertices());
glDrawElements(GL_TRIANGLES, 3*numvertices, GL_UNSIGNED_INT, indices);

for triangles and quite a lot, but little less for triangle strips


[edited by - Captain Goatse on June 5, 2003 7:58:57 AM]
quote:Original post by Captain Goatse

Does not seem to be very optimal to first store 1024x1024x3(triangles)x3(vertices)

and then store indices from 1024x1024?



In that case it wouldn''t be, but if you''re just rendering a patch of terrain you would only need the indices for that part of the array.

I had a go at explaining how to do it in this thread.

Cheers




______________________________

DGDev - The Delphi Games Development Community
______________________________DGDev - The Delphi Games Development Community
I can figure out how the thing is done, however I have problem coming up with good way to set the indices.

doing 110248576 indices manually kind of sucks.

The obvious is evading me, in two loops i constantly get array out of bounds. Now it is only a matter of time

I just need to figure out equation for this

indices[0] = 0;
indices[1] = 1;
indices[2] = 1024;

indices[3] = 1024;
indices[4] = 1;
indices[5] = 1025;

indices[6] = 1;
indices[7] = 2;
indices[8] = 1025;
why would you even have so many indices? if your terrain is divided into patches you have ONE index array for a patch (16x16 or 32x32, whatever size you prefer). so even without strips that shouldnt be more than 6000 indices. everything else is easier done by just changing the offset into the array.
f@dzhttp://festini.device-zero.de
quote:Original post by Trienco
why would you even have so many indices? if your terrain is divided into patches you have ONE index array for a patch (16x16 or 32x32, whatever size you prefer). so even without strips that shouldnt be more than 6000 indices. everything else is easier done by just changing the offset into the array.



Ok I''m have missed the concept. Let''s say I want to render the whole heightmap without any quadtree/whatever function, then I do need the indices[mapSize*mapSize]?
www.gametutorials.com has a good tutorial.
quote:Original post by Captain Goatse
Let''s say I want to render the whole heightmap without any quadtree/whatever function, then I do need the indices[mapSize*mapSize]?


if you want to render the whole 1024x1024 without any kind of subdivision and culling going on i really wouldnt care about the memory usage for your indices, because rendering the 2 million triangles will be a bigger problem.

the other thread that bluecat linked has a good explanation on how to use just one index buffer and changing the pointer instead. about trees: test it with and without, i need to really optimize my tree to get the same speed i have with just culling every patch/chunk/part of the heightmap (for about 4000 of them.. a tree using a list would be slower and one using recursion would be hell).

f@dzhttp://festini.device-zero.de
Well... I''m just moving to vertex arrays from regular triangle strips that used semi-recursive list to cull the polygons. Somehow it seems to be that the vertex arrays make this list more efficient memory wise. I can draw the picture "setting the indices by hand"(make adjoining vertices), so I think I understand the concept. However the indices part is lacking an actualy algorithm for now, however I don'' think that will be a problem.

This topic is closed to new replies.

Advertisement