• 12
• 9
• 10
• 13
• 10

# vertex and face normal troubles

This topic is 3586 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm trying to have a specific color for each face of a model, and at first I figured it'd be simple... When I create the vertex buffer each vertex has the face normal with it. So in the VS I figured I could do it based on the normal, but come VS time (using PIX to analyse), the Normal attribute is now the vertex normal... How did it become that? lol I can only assume DX10 somewhere along the way "optimized" it and assumed I wanted it as the vertex normal. At NO point in my code do I change the Normal attribute except when I first allocate the array (at which point it is the face normal). What gives? My Vertex Buffer:
struct Vertex
{
D3DXVECTOR3 Position;
D3DXVECTOR2 Texture;
D3DXVECTOR4 Color;
D3DXVECTOR3 Normal;
};
Each vertex has Normal set as the face normal (i.e. for a cube, the first 6 vertices all have Normal set as (0, 0, -1); the front face). But in the VS, each vertex has Normal as its vertex normal (the top right point for example has become (-1, 1, -1) or whatever its normal is). Also, while the above problem is annoying me, is there a "better" way to do what I want? In most cases, every face will be the same color, and I want to be able to specify a specific color for a number of faces (determined in-game). The other way I was thinking was to add a FaceId into the Vertex array and do it based on that, but this seems cumbersome (in the sense that the VB shouldn't have things like that in it). Any thoughts?

##### Share on other sites
Well, I found out how to fix it; I added D3D10_APPEND_ALIGNED_ELEMENT in my layout description to all my elements...
I assumed that because it said it was optional, it'd figure it out for itself... Guess not...
Anyways, now that that is solved, are there any other better ways of doing what I want?

Oh, and the reason it looked like it was the vertex's normal was because it was a perfect cube with the centre at (0, 0, 0), so of course each vertex in this instance is actually the same as its normal. Bleh. Guess that's another reason you shouldn't use a cube when testing things.