For one of my games I need to have a toon shader that works in both black and white and color. This is what I created for the black and white one:
here's the script:
Code:
material mat_bw
{
effect = "
sampler2D g_samSrcColor;
float4 MyShader( float2 Tex : TEXCOORD0 ) : COLOR0
{
float4 Color;
int Color_all;
Color = tex2D( g_samSrcColor, Tex.xy);
Color.rgb = (Color.r + Color.g + Color.b)/3;
Color_all = (Color.r/.167);
Color.rgb = Color_all * .167;
return Color;
}
technique PostProcess
{
pass p1
{
VertexShader = null;
PixelShader = compile ps_2_0 MyShader();
}
}
";
}
Now, the problem comes when I try to use the same kind of thing with color. I can't find a formula that would force the saturation to be a certain level. Any suggestions?