My Questions

Nov 29, 2008 at 2:52 PM
Edited Nov 29, 2008 at 2:59 PM
Hello again!
Here is my epic code of terrain: http://rafb.net/p/Bj1frB43.html
I have error: Cannot use shader of type 'Xen.Ex.Material.vs1n' with Vertices<IslandWar.CustomVertex> object as it does not include element 'Tangent0'
On 91 line.
I understand that i should add new field, but i don't understand how Xen managing it.
Can you please give more info on how Xen auto-managing verts decls?
Coordinator
Nov 29, 2008 at 8:22 PM
Edited Nov 29, 2008 at 8:30 PM

Hi.

This couldn't be easier :-)

struct CustomVertex
{
  public Vector3 position;
  public Vector3 normal;
  public Vector2 tex;

  public Vector3 tangent;
  public Vector3 binormal;
}

Naturally, fill out the constructor too.

I'm going to assume you know how to properly calculate tangents / binormals, and understand how they relate to normals. They can be tricky things to get right.

The codethat generates the declarations will try it's best to guess what you intended the field would do. In this case, 'tangent' is pretty clear, and because it doesn't have a number, it will go into index 0. Calling it Tangent0 would have worked exactly the same. However calling it 'myVertexTangentValueInIndexZero' would not have worked :-) In such a case, it will throw an exception saying it cannot work out what you intended. There is an attribute (Xen.Graphics.VertexElementAttribute) that lets you manually specify the useage.

Good luck :-)