milann

Hi,

I've got a simple question concerning the normal vector of a polygon. I'm currently implementing lighting and I've browsed through several sources like The Ramblings of a Hazy Mind and several books, but there is one question that I cannot find an answer to. Most of the lighting effects rely on normal vectors:

VS_OUTPUT VertexShader(float3 position : POSITION0, float3 normal : NORMAL0)...

I wonder whether this mormal vector is always available because all of the examples I've seen just take it as a given What if I've defined the vertices as VertexPositionColor only - without normal data Are the normals automatically computed by the hardware just before the execution of the shaders

Tnx in advance Smile



Re: XNA Framework Vertex shaders and normals

Shawn Hargreaves - MSFT

Normals aren't magically computed for you: you need to have this data in your vertex declaration to be able to use it in a shader.

If you use the XNA Content Pipeline, that will generate normals for you during the build process, though, so models built through it will always include this data.