Color as input element in a dx11 shader

Hello Everybody,

Can anybody help me with programming a simple flat shader that takes color as input element. I am pretty new to v4 an computer graphics and have no background in programming.

Would it be something like adding this in the template shader?:

struct VS_IN
{
float4 AmbColor: COLOR;
};

struct vs2ps
{
float4 AmbColor: COLOR;
};

vs2ps VS(VS_IN input)
{
vs2ps output;
output.AmbColor = input.AmbColor
return output;
}

float4 PS(vs2ps In): SV_Target
{
???
}

Would appreciate the help,
Sven

If you want to use vertex colors then you need them in your mesh data and the shader below will work. It will let you know in the layout msg output pin if everything is right there. If you are just after having a user controlled color then check the dx11 constant shader, it already has this.

//@author: Everyoneishappy
//@help: Simple Vertex Color
//@tags: color
//@credits: 

Texture2D texture2d <string uiname="Texture";>;

SamplerState g_samLinear : IMMUTABLE
{
    Filter = MIN_MAG_MIP_LINEAR;
    AddressU = Clamp;
    AddressV = Clamp;
};

 
cbuffer cbPerDraw : register( b0 )
{
	float4x4 tVP : VIEWPROJECTION;
};


cbuffer cbPerObj : register( b1 )
{
	float4x4 tW : WORLD;
	float4x4 tColor <string uiname="Color Transform";>;
};

struct VS_IN
{
	float4 PosO : POSITION;
	float4 Vcol : COLOR0;

};

struct vs2ps
{
    float4 PosWVP: SV_POSITION;
	float4 Vcol : COLOR0;
};

vs2ps VS(VS_IN input)
{
    vs2ps Out = (vs2ps)0;
    Out.PosWVP  = mul(input.PosO,mul(tW,tVP));
	Out.Vcol = input.Vcol;
    return Out;
}




float4 PS(vs2ps In): SV_Target
{
    float4 col = In.Vcol;
	//col =1;
    return col;
}





technique10 Constant
{
	pass P0
	{
		SetVertexShader( CompileShader( vs_4_0, VS() ) );
		SetPixelShader( CompileShader( ps_4_0, PS() ) );
	}
}

Thanks!

Just tested it…
Works like a charm.https://vvvv.org/sites/default/files/imagecache/large/images/Schermopname%20(1).png