   Changing specific pixels with the Pixel Shader
  I want my pixel shader to change every pixel with the rgb value 195,159,153 to 0,0,0. I don't know what is wrong with my code.float4 PixelShader(float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0{float4 tex = tex2D(TextureSampler, texCoord);if(tex.r *255 == 195 && tex.g *255 == 159 && tex.b *255 == 153){tex.r = 0.0f;tex.g = 0.0f;tex.b = 0.0f;}    return tex;}If I remove the " && tex.b *255 == 153 " from the if-statement it works (although it only checks the red and green values). I have already checked that I do draw textures that contains (195,159,153) pixels. Why wont it work when it checks the blue value? Is the value truncated without me knowing it?   
  Have you tried just blue to make sure you really do have the colours you think you have?   ;  I have tried with blue only and it didnt work either. I'm displaying a texture that GIMP tells me has the rgb values 195,159 and 153. I've tried with several different textures, red/green checking works, but blue doesnt.   ;  What file format is your texture in? Jpegs for example may get decoded slightly differently depending on the software used. Also what texture format are you using? DXT ones can change colours somewhat too.However I suspect the issue is a precision one - pixel shaders work in floats. Try testing with something like this:float4 PixelShader(float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0{float3 tex = tex2D(TextureSampler, texCoord);float3 test = float3(195.0f/255.0f, 159.0f/255.0f, 153.0f/255.0f);// Result is squared distance, so the tolerance means// about 1/316 (0.8 in 0-255 terms). Adjust as necessary.if (dot(tex-test, tex-test) < 0.00001f){tex.r = 0.0f;tex.g = 0.0f;tex.b = 0.0f;}return tex;}Also note that while you can do this testing in the pixel shader, if the value to be tested against is a constant you should probably modify the texture at load or export time instead...   ;  It is a png file. Im not sure what texture format Im using. Im loading stuff through the content manager as 2dTextures. Im drawing them by calling spriteBatch.Draw(map.Texture, destinationRectangle,    sourceRectangle, Color.White);I've tried your program. I changed tex to float4 or else it wouldnt let me compile it. (float4 tex = tex2D(TextureSampler, texCoord);)And it worked! thank you.Would you mind explaining to me what "dot(tex-test, tex-test) < 0.00001f" means?;  The reason I wanted the colour to be a float3 was to avoid testing the alpha channel. However you can just use .rgb when reading from it instead.dot(tex-test, tex-test) is shorthand for:float3 d = tex.rgb-test.rgb;float dSquared = (d.x * d.x) + (d.y * d.y) + (d.z * d.z);That is it computes the standard squared distance between the colours, as if they were positions. That works because you can treat colours as positions within an RGB colour cube.I then picked a tolerance for that squared distance, which is about (0.8/255)*(0.8/255). You can play with that to have it affect more or less colours. However note that different hardware may behave slightly differently in precision of colours so don't make it too small.   ;  dot(tex-test, tex-test) < 0.00001fyour finding the distance between the rgb values and testing there orthogonality(right-angled'ness) to each other. So think of it like a clock, you have two vectors say one pointing at the 12 on the clock dial and another pointing at the 3, what the dot test will look for is, anything in the middle, and it will apply your new pixel colors too. (In your case your range is that tolerance of 1/316th he quotes in the code).   