Search code examples
c#xnavertex

Difference between using VertexPositionNormalTexture and VertexPositionTexture


What are the differences between using VertexPositionNormalTexture and VertexPositionTexture in XNA? Does the GPU apply culling if the normal points away from the camera, or does it do that automatically? Is it just more data to send to GPU?

What are the advantages and disadvantages, and in what situations would each one be applicable?


Solution

  • The advantage is that you can pass a calculated vertex normal to your shader and the shader can use that information in the render, for example you can implement smoother lighting that more closely approximates curved surfaces by interpolating the normal across each triangle and using this interpolated normal for lighting rather than the normal of the triangle.

    I suppose you could use this information for culling, but it's not generally what it's used for. You don't need vertex normals to cull because generally it's easily done just by calculating the direction of the normal of the triangle, rather than each vertex.

    When you say 'does the GPU apply culling...' remember that the days of fixed pipeline processing are gone, the GPU does what you tell it to do in your shader code. At the end of the day you can put whatever information you want in to your vertex stream, and use that information however you want in your shader, the possibilities are endless.