Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

My test FBX mesh is a cube. From what I surmise, it seems that the cube is on the extreme end of this issue, but I believe that the same issue would be able to occur in any mesh:

Each vertex has 3 normals, each pointing a different direction. Of course loading in any type of mesh, potentially ones having thousands of vertices, I need to use indices and not duplicate shared verts. Currently, I'm just writing the normals to the vertex at the index that the FBX data tells me they go to, which has the effect of overwriting any previous normal data. But for lighting calculations I need more info, something that's equivalent to a normal per face, but I have no idea how this should be done. Do I average the 3 different verts' normals together or what?

share|improve this question
1  
    
Thanks for pointing me to that. I'm not sure if I'm wrong in replying here, being this is a duplicate... Just to be clear, are you saying that - for mesh data - using indices can not possibly allow for accurate rendering, such as would be needed for lighting? What do you mean by "A great many model formats will use multiple indices; you will need to fixup this vertex data before you can render with it." What exactly does this "fixup" entail? –  Ramon Johannessen Sep 24 '12 at 2:06
1  
First, this has nothing to do with "accuracy"; it's about working. You must provide the data as OpenGL wants it. This means that if the same position is used by two different normals, you must use two positions (that happen to be the same). As for "fixup", it means exactly what the post said: "So if you have a cube, where each face has its own normal, you will need to replicate the position and normal data a lot. You will need 24 positions and 24 normals, even though the cube will only have 8 unique positions and 6 unique normals." –  Nicol Bolas Sep 24 '12 at 2:42
    
@Nicol Should be an answer. –  Anko Mar 11 '13 at 21:40
    
At the time I was working on this, my understanding of the concepts involved was still being solidified, which is probably why your answer didn't seem to answer my question. Reading it now it makes perfect sense, and I've since got it working. Thanks for the help. –  Ramon Johannessen Apr 16 '13 at 15:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.