Kinect pixel shader

Hi guys.
I try to use a kinect depth to filter the hand on the table, I can’t use the hand node because I don’t see de the user, I only see the hand’s.

I can filter the image with using a simple pixelshader

float RED = 1;
float GREEN = 1;
float BLUE = 1;
float Tolerancia = 0;
float4 PS(vs2ps In): COLOR
{
float4 col = tex2D(Samp, In.TexCd);

if ( 
( col.r >= (RED-Tolerancia) ) && ( col.r <= (RED+Tolerancia) ) &&
( col.g >= (GREEN-Tolerancia) ) && ( col.g <= (GREEN+Tolerancia) )&&
( col.b >= (BLUE-Tolerancia) ) && ( col.b <= (BLUE+Tolerancia) )
)
{
	if(
	( col.r == RED ) &&	( col.g == GREEN )  && ( col.b == BLUE )
	)
	{
		return float4 (1,0,0,1);
	}else{
		return col;
	}
	
}else
{
	return float4(0,0,0,1);		
}	

}

I compare de each pixel with the expecific input color and apply a tolerance level to create a specific width zone.

The problem is:
When I put the hand in the escene, the range level change in the kinect depth image.
I adjunt the pacht.

test kinect.rar (5.6 kB)

Hi Jordi,
Using Kinect (Microsoft) your shader is working. (with some artifacts produced by the ir “shadow”) These filter may help https://discourse.vvvv.org/ when they’ll come…

I’m not sure what you want to achive, so I just clean the patch a bit.
I remember there was already a shader to do this…

PS: The depth gives you a L16 bit luminance texture…
Why consider RGB for filtering?
Sorry noob question.

Bye

test kinect 2.zip (9.1 kB)