Wait! I finally got the right equation! I was trying to change only the red green or blue value based on how much of each was present, but I needed to multiply them all by one universal fraction! Here's my results (by the way I wasn't really looking for an outline):
And the code:
Code:
material mat_rgb
{
effect = "
sampler2D g_samSrcColor;
float4 MyShader( float2 Tex : TEXCOORD0 ) : COLOR0
{
float4 Color;
int Color_all;
float multiplyer;
Color = tex2D( g_samSrcColor, Tex.xy);
Color_all = ((Color.r + Color.g + Color.b)/3)/.167;
multiplyer = (Color_all * .167)/((Color.r + Color.g + Color.b)/3);
Color.r = (Color.r * multiplyer);
Color.g = (Color.g * multiplyer);
Color.b = (Color.b * multiplyer);
return Color;
}
technique PostProcess
{
pass p1
{
VertexShader = null;
PixelShader = compile ps_2_0 MyShader();
}
}
";
}