Hello there!
I'm still very much a novice concerning 3D rendering, so I apologize in advance for my naivety. I have a question regarding the basic 3D rendering techniques for a cube. So, if I have a cube with 8 vertices (position and normal) and an index buffer defining 12 triangles with those 8 vertices, and i render the cube as a triangle strip, what happens is that the normal of every vertex is interpolated in between all the faces that use that vertex. Now, I want to do some advanced light shading in the pixel shader of this cube, but all i have are the interpolated normals which won't give me the correct results, because they are being averaged between all the different triangles that use the vertex.
I see a couple of different solutions here:
- Use a triangle list instead of the triangle strip, but this increases the vertex count from 8 to 24,
- Define a geometry shader in between the vertex and pixel shader of the cube and calculate the normal of a triangle and pass that normal to the pixel shader (if that's even possible),
- Give the vertices texture coordinates and use a normal map for the cube.
Considering this being a rather simple example with 8 vertices, i guess it wouldn't really make a difference choosing any of these methods. But if I want to utilize the GPU's instancing capabilities and have multiple thousand instances of this cube, what would be the correct choice?
I feel like there is a very easy solution to the the problem I can't see yet and I am totally overthinking it.
Thanks in advance,
Paul