I am attempting to make a map editor for my game, just so I can visualize how the end result would be.
To my world I can add cubes (2 triangles) or corners (1 triangle), which are then added to a list of the vertices to draw, and the indices are added to a list of indices. Everything draws fine here, and I can set different colours for each vertex.
I would like to implement texturing, so that when you add a primitive to the scene it will let you choose a texture (that, I can handle), but then also blend with other primitive's of different textures if they are touching (everything is on a grid).
I would guess that I would have to store the texture name for each primitive, and somehow set that texture when drawing it. But I fail to see how you can set the effects texture when you are using one
DrawUserIndexedPrimitives<> to draw the entire scene.
If anyone has a work around for this, or ideas on other ways of doing this, you help would be greatly appreciated.
I have incorporated the technique from this website here - http://toyfactorygame.com/wp.php/2010/05/06/simple-fast-gpu-driven-multi-textured-terrain/ (similar to Blau's answer below), and have the current working result...
Which maps to this...
Using each color channel as a texture..
Output = tex2D(TextureSampler0, input.TexCoords) * input.Color.r; Output += tex2D(TextureSampler1, input.TexCoords) * input.Color.g; Output += tex2D(TextureSampler2, input.TexCoords) * input.Color.b; Output += tex2D(TextureSampler3, input.TexCoords) * input.Color.a;
But doing it this way means I can only be setting 4 textures to blend together each DrawPrimitives call.
Is there another way I can achieve multi texturing with more than 4 (preferably unlimited) textures? I know this is possible, as games like C&C generals allow you to set textures anywhere you want on the map.