hello all,
I would like to finally write my own shaders.
Little exercise for me:
I want to associate different textures to kinect users.
my plan is to tell vvvv: if the color = color user 1 then associate this color to texture 1, etc…
first step for me, must be so simple, but i can’t ;)
how to tell vvvv looks up at the texture and replace all x color pixels with white if they match color pin and the others with black if they don’t match.
here’s my code:
//replace pixels to white or black according to texture’s color
float4x4 tW: WORLD;
float4x4 tV: VIEW;
float4x4 tP: PROJECTION;
float4x4 tWVP: WORLDVIEWPROJECTION;
texture Tex <string uiname=“Texture”;>;
sampler Samp = sampler_state //sampler for doing the texture-lookup
{
Texture = (Tex); //apply a texture to the sampler
MipFilter = LINEAR; //sampler states
MinFilter = LINEAR;
MagFilter = LINEAR;
};
float4x4 tTex: TEXTUREMATRIX <string uiname=“Texture Transform”;>;
float4 usercolor : COLOR <string uiname=“user color”;> = { 0.0, 0.0, 0.0, 1.00000 };
struct vs2ps
{
float4 Pos : POSITION;
float4 TexCd : TEXCOORD0;
};
vs2ps VS(
float4 Pos : POSITION,
float4 TexCd : TEXCOORD0)
{
vs2ps Out = (vs2ps)0;
Out.Pos = mul(Pos, tWVP);
Out.TexCd = mul(TexCd, tTex);
return Out;
}
float4 user_color(vs2ps In): COLOR
//must be the heart of my silly process :)
{
float4 col = tex2D(Samp, In.TexCd);
if (col.r == usercolor.r && col.g ==usercolor.g && col.b == usercolor.b)
{
col = (1,1,1,1);
}
return col;
}
technique kinect
{
pass P0
{
VertexShader = compile vs_1_1 VS();
PixelShader = compile ps_2_0 user_color();
}
}
thanks a lot in advance !
kinect-texture.v4p (11.3 kB)
equal1.fx (1.4 kB)