I would like to understand how to optimize the 3D objects drawing using also normals.
For example I have a cube: it has 8 vertices, and 6 faces that could be rapresented as 12 triangles.
(I've used the cube in order to simplify the question, but in general if you have triangles that represent plane surfaces the question is still valid)
If so, I have a VertexBuffer with 8 vertices, and an IndexBuffer of 36 items (12t*3v each).
If I use the OpenGL function DrawElements in my code. This works!
The next step is introducing the normals, because I want the lights effects.
In this example I thought to use a NormalsBuffer with a normal for each triangle.
In order to get the right normal, I thought to use VertexShader and retrive the value just dividing the gl_VertexID by 3.
int triangleIndex = (gl_VertexID/3)
the triangleIndex is the Normals index to use to retrive normal in NormalsBuffer.
I didn't find any example or document that explains how to optimize the normal's vectors usage.
Is it my idea valid?
And if Yes how can I get the normal vector from Vertex Shader?
I have found this Post inspiring "Rendering meshes with multiple indices", but not useful because it miss usable code.