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?

  • 1
    \$\begingroup\$ Duplicate of this Stack Overflow question \$\endgroup\$ – Nicol Bolas Sep 24 '12 at 1:37
  • \$\begingroup\$ 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? \$\endgroup\$ – Ramon Johannessen Sep 24 '12 at 2:06
  • 1
    \$\begingroup\$ 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." \$\endgroup\$ – Nicol Bolas Sep 24 '12 at 2:42
  • \$\begingroup\$ @Nicol Should be an answer. \$\endgroup\$ – Anko Mar 11 '13 at 21:40
  • \$\begingroup\$ 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. \$\endgroup\$ – Ramon Johannessen Apr 16 '13 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.