1
votes

I have a bunch of parameters that are output from the vertex shader, and I want to pass them to the pixel shader.

The normal way to do this is to declare an output structure

struct vOut
{
    float4 param0 : TEXCOORD0 ;
    float4 param1 : TEXCOORD1 ;
} ;

So you have to write a separate variable and put each in a texture coordinate.

Is there a way to declare an array of 16 * float4's, and have them occupy TEXCOORD0 -> TEXCOORD15 without having to write out a vertex declaration like this?

1

1 Answers

1
votes

just declare it like so:

struct VertexOutput_Test
{
  float4 hPosition    : POSITION;
  float4 vArr[5]     : TEXCOORD0;
};

and address it normally within vertex and pixel shaders, e.g. this dummy code:

VertexOutput_Test VS_Test(VertexInput_1UV IN) 
{
  VertexOutput_Test OUT = (VertexOutput_Test)0;
  float4 Po = float4(IN.position.xyz,1.0);
  float3 No = IN.normal.xyz;
  OUT.hPosition = mul(Po,worldViewProj);
  OUT.vArr[0] = float4(1,0,0,0);
  OUT.vArr[1] = float4(1,1,0,0);
  OUT.vArr[2] = float4(1,0,1,0);
  OUT.vArr[3] = float4(1,0,0,1);
  OUT.vArr[4] = float4(1,1,1,1);
  return OUT;
}

if you look at the fxc output, you'll see that it lays them out nicely in order