   Vertexbuffer, Indexbuffer and Lights?
  Hi, I have a vertexbuffer where I store 8 vertices with the position and color.Then I have an indexbuffer where I store my 36 indices to create a cube of my 8 vertices.The problem is now, that when I render the cube all cubesides have the same color. When I turn on the lights, the cube color becomes black. I think I need the normals for every cube side to get the right color value. How can I set the normals for all 6 cube sides? I'm able to set a normal for every vertex value in the vertexbuffer, but when I create the cube with my indexbuffer every vertex is part of three cube sides. So I think, I can't set a normal value in the vertexbuffer.Does anyone know, how I can solve this?Pikebu   
  First of all what is your vertex format?  How do you want your vertex color computed, because you can set diffuse color source as vertex color and specular color source as material color. So.. :)Second of all when you have light the color is determined by light color and material color (I asume that the color sources are set to material diffuse, ambient and specular in this case).If you want totally different colors for each side of cube, you need to duplicate vertices, same thing if you want different texture to each side of cube.Use these functions to control the color sources : D3DMCS_COLOR1 = Vertex diffuse colorD3DMCS_COLOR2 = Vertex specular colorD3DMCS_MATERIAL = Material colorD3DDevice->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL);D3DDevice->SetRenderState(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL);D3DDevice->SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL);Might be a little messy message, written in hurry, but I hope it helps. :)   ;Quote:Original post by pikebuHi, I have a vertexbuffer where I store 8 vertices with the position and color.Then I have an indexbuffer where I store my 36 indices to create a cube of my 8 vertices.The problem is now, that when I render the cube all cubesides have the same color. When I turn on the lights, the cube color becomes black. I think I need the normals for every cube side to get the right color value. How can I set the normals for all 6 cube sides? I'm able to set a normal for every vertex value in the vertexbuffer, but when I create the cube with my indexbuffer every vertex is part of three cube sides. So I think, I can't set a normal value in the vertexbuffer.PikebuThe cube is the classic example where sharing vertexes and using an index buffer is a bad idea. When rendering a shape you would compute a normal that is the average of the normals of the triangles sharing that vertex. This makes the shape look smoothed. A cube should just be rendered as 12 triangles and 36 vertexes. Something like a ball or cylinder should use an index buffer to share vertexes, but something with sharp edges, like cubes, houses, etc shouldn't.By the way you are right, you need normals if you turn on lighting or everything renders as black.   