   Is it possible to directional lighting on a cube with indices
  Just curious if it is possible to do directional lighting on a cube with indices. And when I mean cube with indices, I mean a cube with 4 vertices, and 36 indexes. Right now I say no because you need to assign a surface normal for each vertex and if you only have 4 its almost impossible cause you have 6 sides.If it is possible, what would be the best way of implementing that. If no, then I assume programs like maya don't use indices for their cubes.Another question i would like to add is when is it best to use index buffers for objects and when is it best to just use a triangle list.[Edited by - numerical25 on May 27, 2010 10:44:01 PM]
Quote:And when I mean cube with indices, I mean a cube with 4 vertices, and 36 indexes.How do you make a cube with 4 vertices? Did you mean 8?Quote:Another question i would like to add is when is it best to use index buffers for objects and when is it best to just use a triangle list.Although I can't say this with certainty, I think that these days indexed geometry is the 'rule', more or less, and un-indexed geometry is the exception.As for when using un-indexed geometry would be a win, I imagine that would depend on a number of factors (mostly having to do with how much data has to be transfered across the bus).   ;  With only 8 vertices (and in turn only 8 vertex normals) then no, I don't think its possible to correctly light a cube. You'd need 4 vertices per side (24). You'd still only need 36 indices though. So its not so much the indices that are the issue, its the vertices.   ;Quote:Original post by NanohaWith only 8 vertices (and in turn only 8 vertex normals) then no, I don't think its possible to correctly light a cube. You'd need 4 vertices per side (24). You'd still only need 36 indices though. So its not so much the indices that are the issue, its the vertices.Ok, that makes sense. It kind of threw me off because I thought the point of indices is to reduce the amount of vertices you have to put on the screen. But this can't be the case with a cube because 3 sides share the same vertices. But on the other hand, this would have to be the same for any object. including a plane (surface). atleast 4 faces on a surface share the same vertices. Is this when surface averageing comes into play ?;Quote:Original post by numerical25But on the other hand, this would have to be the same for any object. including a plane (surface). atleast 4 faces on a surface share the same vertices. Is this when surface averageing comes into play ?Yes, for soft edges you just average the face normals (technically, add them together and normalise the result).Only for hard edges do you need separate vertex normals, and a cube is pretty much the worst possible case in this respect, as all edges are hard.   ;Quote:It kind of threw me off because I thought the point of indices is to reduce the amount of vertices you have to put on the screen.The point of indices is to reduce the transformation per-vertex. Most verts are connected to more than 1 triangle, so tranforming it once will give the same position for that vertex.What happens though is you have to think of vertices with different attributes as separate vertices. Since you want it flat shaded, each vertex can have up to 3 normals. After transforming the vertex, the GPU does not know what triangle you are drawing and which normal to use.   