| Topic: Order of Vertex Elements
|
|
 | Order of Vertex Elements | |  |
| Poster | : slewnau | | Posts | : 1 | | Country | : USA | | City | : East Lansing |
| | | | Posted by slewnau on 09/10/2009 at 09:51:02
| | When I created my VertexPositionNormalColored type I used position, normal, then color like this
public Vector3 position;
public Vector3 normal;
public Color color;
public static VertexElement[] VertexElements =
{
new VertexElement(0, 0, VertexElementFormat.Vector3, VertexElementMethod.Default, VertexElementUsage.Position, 0),
new VertexElement(0, sizeof(float)*4, VertexElementFormat.Vector3, VertexElementMethod.Default, VertexElementUsage.Normal, 0),
new VertexElement(0, sizeof(float)*3, VertexElementFormat.Color, VertexElementMethod.Default, VertexElementUsage.Color, 0),
};
instead of position, color, normal and when I set the normals, it created a crazy mess of colors where shadows should be. Why should it matter the order of the VertexElements when the vector3 and color types are defined in the same order? | |
|
| | | | | | Poster | : adt7 | | Posts | : 49 | | Country | : United Kingdom | | City | : Bristol |
| | | | Posted by adt7 on 10/10/2009 at 04:34:19
| | new VertexElement(0, sizeof(float)*4, VertexElementFormat.Vector3, VertexElementMethod.Default, VertexElementUsage.Normal, 0),
new VertexElement(0, sizeof(float)*3, VertexElementFormat.Color, VertexElementMethod.Default, VertexElementUsage.Color, 0), |
Should instead be:
new VertexElement(0, sizeof(float)*3, VertexElementFormat.Vector3, VertexElementMethod.Default, VertexElementUsage.Normal, 0),
new VertexElement(0, sizeof(float)*6, VertexElementFormat.Color, VertexElementMethod.Default, VertexElementUsage.Color, 0), |
You're offseting your normal data too far into the stream, and your colour data not far enough. | |
|
|
 | | |  |
|
|
|
If you appreciate the amount of time I spend creating and updating these pages, feel free to donate -- any amount is welcome !
|
- Website design & DirectX code : Riemer Grootjans - ©2006 Riemer Grootjans
|
|