struct IN
{
float3 normal : TEXCOORD0;
};
struct OUT
{
float4 color : COLOR;
}
OUT main(IN i)
{
OUT o;
float4 viewer = float4(0,0,1,0);
float4 red = float4(1,0,0,1);
float4 blue = float4(0,0,1,1);
float def = 1.0;
float epsilon = 0.0005;//can be zero for
//exact match
float4 v1,v4;
float dotP;
v1.xyz = i.normal*2;
v1 = v1-1.0;
v4 = v1*viewer;
dotP = v4.x+v4.y+v4.z;
o.color = ( abs(def-dotP) < epsilon ) ? red : blue;
return 0;
}
I also tested by passing just the dotP, and it seems like there is a lack of precision. Ie areas with different dotPs are shaded exactly the same.
I did that by doing
o.color = float4( dotP, dotP, dotP, 1);