Based upon Looki's "Keep Color" shader I wrote a shader that takes 3 colors and replaces them with 3 new ones. (Or how many you put in the code)
It works fine for almost all colors except for darker shades of gray? I noticed this happened with Looki's shader, too.
For example, it will replace RGB (188,188,188), but it won't replace (119,119,119) or black (0,0,0)
Here's the code for the shader:
Code:sampler2D source; float4 replaceThis1, replaceWith1,replaceThis2, replaceWith2,replaceThis3, replaceWith3; float4 ps_main(in float2 In : TEXCOORD0) : COLOR0 { float4 color = tex2D(source,In); if(color.r == replaceThis1.r && color.g == replaceThis1.g && color.b == replaceThis1.b) color.rgb = replaceWith1.rgb; if(color.r == replaceThis2.r && color.g == replaceThis2.g && color.b == replaceThis2.b) color.rgb = replaceWith2.rgb; if(color.r == replaceThis3.r && color.g == replaceThis3.g && color.b == replaceThis3.b) color.rgb = replaceWith3.rgb; return color; } technique tech_main { pass P0 { PixelShader = compile ps_2_0 ps_main(); } }






Reply With Quote




Thanks a lot.











