0

How to declare an array of TEXCOORDs? In different struct I have :

float2 foo : TEXCOORD0 
float3 bar : TEXCOORD1

And now I need

float4 Positions[NUMBER_OF_FLOATS]
float3 OtherPositions[NUMBER_OF_FLOATS_2]

I want these arrays to consist of TEXCOORDs (if I omit the TEXCOORD semantic, I get an error because of it). But no matter how I write it, I get a duplicate error, that I use TEXCOORD0 and TEXCOORD1 multiple times.

Any help is appreciated.

Wanderer
  • 147
  • 1
  • 8

1 Answers1

0

The problem is that the predefined semantics like TEXCOORD have a specific type (seen in doc). So the compiler expects you TEXCOORD to be float vector and not an array of float vectors. Maybe it works with custom semantics, but didn't found any references and never tested it by myself.

I also stumbled over this problematic and solved it (quite ugly) with the preprocessor. In your case it would look like

#if NUMBER_OF_FLOATS > 0
  float4 Position_1 : TEXCOORD0;
#endif
#if NUMBER_OF_FLOATS > 1
  float4 Position_2 : TEXCOORD1;
#endif
#if NUMBER_OF_FLOATS > 2
  float4 Position_3 : TEXCOORD2;
#endif
...

Of course this would need a recompling of the shader if the number changes and your vertex layout must have to fit, but despite it is not the best solution it works for me :)

Gnietschow
  • 3,070
  • 1
  • 18
  • 28