0
votes

How can I output something from the vertex shader to the pixel shader multiple times. Eg I need to output the vertex color as a float 4 to the pixel shader 4 times after performing some different math operations on the vertex color in the vert shader?

can I do this? I tried creating an empty float4 color2, reading the In.vertcolor from In.color and outputing that... I dont get any errors but my texture is white. Its just reading any empty float 4...

here is my code for this section. Thanks!

//////////////////////////////////////////////////////////////
// Structs section 
// input from application
struct a2v {
float4 position  : POSITION;
float4 normal    : NORMAL;
float2 texCoord : TEXCOORD0;
float2 secondUV : TEXCOORD1;
float4 color: COLOR;
float4 color2;

};

// output to fragment program
struct v2f {
    float4 position        : POSITION;
    float2 texCoord : TEXCOORD0;

    float2 secondUV : TEXCOORD1;
    float3 worldNormal     : TEXCOORD2;
    float4 color: COLOR;
    float4 color2;

};



//////////////////////////////////////////////////////////////
// Vertex Shader 

v2f vShader(a2v In)
{
v2f Out;
Out.texCoord = In.texCoord;
Out.secondUV = In.secondUV;

float4 Mask1 = floor ((fmod((In.color  * 100f ), 10f))) *.111f;
float4 Mask2 = floor ((fmod((In.color2  * 100f ), 10f))) *.111f;
Out.color = Mask1;
Out.color2 = Mask2;


Out.position = mul(WorldViewProjection, In.position);
Out.worldNormal = mul(WorldInverseTranspose, In.normal).xyz;

return Out;
}
1

1 Answers

0
votes

There is a COLOR1 binding attribute which you can assign to the 'color2' field in a2v and v2f structures.

Be sure to allocate the secondary color (COLOR1) as an attribute stream in you application.