Hi all.
What I'm doing is creating a selected object display. This is when a user selects a game object and a window has its detail and a image,
That may show its health status.
I'm working on the image part.
Each object has a .DDS icon image with alpha channel and its a image of the object rendered as a wire frame
the inner parts are coloured black, This is the colour I would Like to over ride.
I tryed three ways the last one works the best but it adds a line at the top and bottom.
I'm thinking its from the top and bottom of the image.
here is my HLSL pixel shader snippit of code
//any other ways I should try.
float4 texColor = gTex.Sample( TexS, input.tex0 );
float4 diffuse = Mdiffuse * texColor;
// Kill transparent pixels.
clip(diffuse.a - 0.15f);
// Interpolated normals can become unnormal--so normalize.
input.normalW = normalize(input.normalW);
input.toEyeW = normalize(input.toEyeW);
// Light vector is opposite the direction of the light.
float3 lightVecW = gLight.dir;
//shadow stuff
float shadowFactor = 0.0;
float3 removethiscolour = float3(0.0, .0, 0.0);//this will be user set later
//if the colour is black then we want to change that colour
//to our new colour
//try 1
//float val = diffuse.r + diffuse.g + diffuse.b;
//if(val <= 0.55)
//diffuse = float4(0.0, 1.0, 0.0, 1.0);
//try 2
//find the colour to over write
//if(diffuse.r == removethiscolour.r && diffuse.g == removethiscolour.g && diffuse.b == removethiscolour.b )
// diffuse = float4(0.25, 0.25, 0.105, 1.0);
//this one I like more
//this here has a nice look to it
float v1 = diffuse.r - removethiscolour.r;
float v2 = diffuse.g - removethiscolour.g;
float v3 = diffuse.b - removethiscolour.b;
float delta = 0.5;
if(v1 <= delta && v2 <= delta & v3 <= delta)
diffuse = float4(1.0, 0.0, 0.0, 1.0);
float4 spec = Mspec;
// Compute the lit color for this pixel.
SurfaceInfo v = {input.posW, input.normalW, diffuse, spec};
float3 litColor = ParallelLight(v, gLight, gEyePosW, shadowFactor);
return float4(litColor * gSelectedColour, gAlpha);