1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
// Rendering variables
//
// V - unit vector in direction of viewer
// L - unit vector in direction of light source
// H - unit vector that bisects V and L
// N - unit vector in normal direction
//
// theta - angle between H and V or H and L
// alpha - angle betwee N and H
// don't reference TEXCOORD0, it's and alias for POSITION
void fragment_program( in float4 pos : POSITION,
in float4 normal : TEXCOORD1,
in float4 col : COLOR0,
out float4 color : COLOR,
uniform float4x4 testFloat4x4,
uniform float4x4 testDouble4x4,
uniform float3 lightFocalPoint,
uniform float3 lightPosition,
uniform float3 cameraFocalPoint,
uniform float3 cameraPosition
)
{
float3 lightVec = lightFocalPoint - lightPosition;
float3 eyeVec = cameraFocalPoint - cameraPosition;
float ne = dot( normal.xyz, normalize(eyeVec) );
// Halfway Vector varies once per object
float3 H = normalize( lightVec + eyeVec );
float diffuse = max(0.0, dot(normalize(normal.xyz),normalize(lightVec)));
// check Vector inputs, object is red upon error conditions
if( 0
|| testFloat4x4[0][0]!=99.43669 || testFloat4x4[0][1]!=53.27563
|| testFloat4x4[0][2]!=31.72327 || testFloat4x4[0][3]!=46.41460
|| testFloat4x4[1][0]!= 3.92156 || testFloat4x4[1][1]!=36.45097
|| testFloat4x4[1][2]!=32.70953 || testFloat4x4[1][3]!=62.55845
|| testFloat4x4[2][0]!= 8.42773 || testFloat4x4[2][1]!=55.26141
|| testFloat4x4[2][2]!=14.26995 || testFloat4x4[2][3]!=27.33909
|| testFloat4x4[3][0]!=45.95263 || testFloat4x4[3][1]!=72.71652
|| testFloat4x4[3][2]!=74.05554 || testFloat4x4[3][3]!=83.90914
|| testDouble4x4[0][0]!=17.68202 || testDouble4x4[0][1]!=20.61210
|| testDouble4x4[0][2]!=90.67103 || testDouble4x4[0][3]!=0.10092
|| testDouble4x4[1][0]!=30.20822 || testDouble4x4[1][1]!=45.71106
|| testDouble4x4[1][2]!=59.58049 || testDouble4x4[1][3]!=48.07516
|| testDouble4x4[2][0]!=92.06191 || testDouble4x4[2][1]!=92.43174
|| testDouble4x4[2][2]!=90.71167 || testDouble4x4[2][3]!=39.48975
|| testDouble4x4[3][0]!=77.99728 || testDouble4x4[3][1]!=51.03002
|| testDouble4x4[3][2]!=12.48477 || testDouble4x4[3][3]!=48.91196
)
{
color = float4( 1.0, 0.0, 0.0, 1.0 );
}
else
{
// Lambertian Shading
//color.rgb = MyAmbient * col;
// Phong Shading
color = (0.5 + diffuse) * col;
color.a = 1.0;
}
}
|