I need to draw a large set of cubes, all with (possibly) unique textures on each side. Some of the textures also have transparency parts. Cubes that are behind transparent textures should show through the transparent texture. However, it seems that the order in which I draw the cubes decides whether transparency works or not, which I want to avoid. Look here:
cubeEffect.CurrentTechnique = cubeEffect.Techniques["Textured"]; Block[] cubes = new Block[4]; cubes[0] = new Block(BlockType.leaves, new Vector3(0, 0, 3)); cubes[1] = new Block(BlockType.dirt, new Vector3(0, 1, 3)); cubes[2] = new Block(BlockType.log, new Vector3(0, 0, 4)); cubes[3] = new Block(BlockType.gold, new Vector3(0, 1, 4)); foreach(Block b in cubes) { b.shape.RenderShape(GraphicsDevice, cubeEffect); }
This is the code in the Draw method. This gives the following result: 
As you can see, the textures behind the sheet cube are not visible from the other side. When I reverse the index 3 and 0 in the array, I get this: 
It is clear that the drawing order affects the cubes. I suspect this may be due to the blend mode, but I have no idea where to start.
Bevin
source share