Archived

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

Estauns

Texture Splatting : Stuck On Step -1

Recommended Posts

I''m workin on a terrain render with heightmaps, and I got the heightmaps workin'' nice in wireframe but now I''m stuck on texturing. I want to do something like splatting, where you can paint each quad a different texture (not neccessarily unique) and then blend ''em together. I''m stuck on like step -1 though, before I can even begind. I don''t know how to make it so that I draw all the quads with different textures. I''ve got a VB with all the vertices and an Index Buffer that makes ''em using a triangle list, and I can put one texture into every quad, but I don''t know how to change it? like.. 1111 1221 1221 1111 Where 1 is 1 texture and 2 is a different one. How do I batch these or whatever, using my one vertex buffer and one index buffer? What do you I have to do?

Share this post


Link to post
Share on other sites
Just to clarify here, I know how to draw them with different textures if I go through and draw one triangle at a time.

Its how to draw ALL of the ones that share a texture at once, that I don''t understand how to do without using a dynamic VB or IB. In the article about splatting by Charles Bloom, it says you don''t have to use a dyanmic VB, but I don''t know how to do it without it.

Share this post


Link to post
Share on other sites
Well there are (atleast) two good ways to accomplish this.

My personal choice is to simply sort your VB by texture and store the beginning index of each texture, as well as the number of triangles using that texture. Then, you can just call DrawIndexPrimitive once for each texture, and give it the proper number of triangles and position in the Buffer.

Another possibility would be to store all of your different textures in one file and then just change the texture coodinates of the vertices you need to texture differently to match the new texture (or change the secondary coords if you''re going to blend).

Take your pick, keeping in mind both will be difficult using Triangle Strips (think about using triangle lists, since today''s hardware can hardly tell a difference anyway), since you can then manipulate the data better. Also note that both of my methods would require a dynamic buffer. The second is probably the easier of the two, as well as the faster. Why I lean towards the first, I''m really not sure. But whatever floats your boat I suppose.

ms

Share this post


Link to post
Share on other sites