Textures and terrain rendering

Started by
17 comments, last by Mescalito 21 years, 5 months ago
exactly AJF - just as I do it. But make sure you use an indexed triangle list. Make a vertex buffer with four vertices per landscape square. Fill an indexed buffer to draw all triangles.
Its a lot more vertices than with 1 big texture, but it really doesnt make such a difference.

Eventually you will want to use a dynamic vertex buffer if you want to cull and update your landscape data frame-by-frame.

Putting all textures in one big texture is not always a good idea, especially if you want to use mip-mapping, since sub-textures can ''bleed'' into each other. The alternative is just to sort the terrain sqs by texture and draw in a few passes (1 for each texture).
A*
Advertisement
I think I''ve finally understood AJF/AndyM method to draw a map, and it can be implemented with only one DrawPrimitive (with TRIANGLE_STRIP).

So for 2 squads we won''t draw 4 tris but 6. And we won''t need 6 vertices but 8. I''ll try the two methods to determine which is the fastest.

And one more time thank you everbody !
quote:Original post by Mescalito
I think I''ve finally understood AJF/AndyM method to draw a map, and it can be implemented with only one DrawPrimitive (with TRIANGLE_STRIP).

So for 2 squads we won''t draw 4 tris but 6. And we won''t need 6 vertices but 8. I''ll try the two methods to determine which is the fastest.

And one more time thank you everbody !


No I think you are confused. Forget triangle strips, they only offer small speed improvements and only when used properly.

Lookup INDEXED triangle LISTs. Per quad you have 4 vertices, but six indices which specify two triangles made from the 4 vertices.
Put them all in one big vertex and index buffer (or feed them into dynamic vertex buffers).
Actually AJF that is exactly what I was trying to describe, I suppose I wasnt doing very well in my explanation. I came to same conclusion as everyone else here, except I will be using one large triangle strip to draw the mesh, and storing two textures into the vertex buffer then using the programmable vertex shader to access those points. For me specifically, on a 10x10 grid of height data, creating triangle strips increases my index buffer size by only 1.5 times (10x10x4 vertices per quad), while using triangle lists would be 2 times the number in index numbers (10x10x6). This is compared to the original drawing of one large triangle strip without texture coordinate mapping (10x10x2) of course these are all approximate only to my version of vertices. (I know the numbers dont add up correctly, it is based on my curent algorithms).

--------------------------Vantage: Greenlit on Steam / Independent Games Festival Submission http://www.crystaldragon.com

Yes I should be confused....
How do you do it with indexed triangles ?
I''ve read several tuts about index buffer and indexed primitives.
I know how it works.

So to do what i want I have to give 4 vertices by squad on my terrain (vertices containing UV texture coo.)
2 of 4 vertices are used once more for the next squad.

For a 10x10 grid terrain, I''ll use 400 vertices, and it will drawn with a DrawIndexedPrimitive(D3DPT_TRIANGLELIST) to give some 200 triangles.

Is that OK ???!
exactly... vertex counts are less relevant these days
OK ! ...
Now I''ve REALLY understood what to do I''ll work on the terrain engine.

Thanks for all !!!!
Hey all

I''ma newb in directX, been working with The nebula device for a while, but moving on to low-level DX now.

I''m busy building a terrain from a heightmap bmp and almost got it working, but for one thing. Currently I have a vertex buffer set up correctly, but the index buffer is giving me hasstles. I build up one tristrip for the whole terrain, but every second strip is missing. Apparently it''s something to do with the triangle wrapping ? But I know nothing of that.

Help please...

This topic is closed to new replies.

Advertisement