weird things with my vertex declaration & vertex shader




Hi,

I have a vertex format class defined as:


Public X, Y, Z As Single ' POSITION0 : FLOAT3
Public NX, NY, NZ As Single ' NORMAL0 : FLOAT3
Public tU, tV As Single ' TEXCOORD0 : FLOAT2
Public blend1, blend2, blend3, blend4 As Single ' TEXCOORD1 :
FLOAT4
Public tU2, tV2 As Single ' TEXCOORD2 : FLOAT2
Public tU3, tV3 As Single ' TEXCOORD3 : FLOAT2
Public terrainFogging, terrainShadows As Single ' TEXCOORD4 :
FLOAT2


Public Const Format As Integer = VertexFormats.Position +
VertexFormats.Normal + _
VertexFormats.Texture0 +
VertexFormats.Texture1 + VertexFormats.Texture2 +
VertexFormats.Texture3 + VertexFormats.Texture4

and the declaration as:


Friend _elements() As VertexElement = { _
New VertexElement(0, 0, DeclarationType.Float3,
DeclarationMethod.Default, DeclarationUsage.Position, 0), _
New VertexElement(0, 12, DeclarationType.Float3,
DeclarationMethod.Default, DeclarationUsage.Normal, 0), _
New VertexElement(0, 24, DeclarationType.Float2,
DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0), _
New VertexElement(0, 32, DeclarationType.Float4,
DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 1), _
New VertexElement(0, 48, DeclarationType.Float2,
DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 2), _
New VertexElement(0, 56, DeclarationType.Float2,
DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 3), _
New VertexElement(0, 64, DeclarationType.Float2,
DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 4), _
VertexElement.VertexDeclarationEnd}

When I set the 'terrainShadows' property of the vertex (which is
TEXCOORD4) , why do I have to reference it within my vertex shader as
TEXCOORD5?

struct VS_INPUT
{
float4 Position : POSITION0;
float3 Normal : NORMAL0;
float2 Texcoord : TEXCOORD0;
float4 Texcoord1 : TEXCOORD1;
float2 Texcoord2 : TEXCOORD2;
float2 Texcoord3 : TEXCOORD3;
float2 Texcoord4 : TEXCOORD4;
float2 Texcoord5 : TEXCOORD5;
};

If I reference Texcoord4[1] within the shader it is zero, I have to
reference Texcoord5[1] to get the correct value. I have only defined
in my declarations and the vertexformat that I have a total of five
texture coordinates, which are 0 to 4, but TEXCOORD5 makes it a sixth?

I cannot see what it is that I am doing wrong...is it wrong to have a
texture coordinate as a float4 or something?

Thanks,

Richy

.