Get the lights working (as such).

They work nicely now when the normal map and texture are bypassed (don't
know what texture is getting used currently).
This commit is contained in:
Bill Currie 2012-05-14 20:29:36 +09:00
parent 8c5e278bf8
commit a032aa5adf
2 changed files with 8 additions and 4 deletions

View file

@ -35,9 +35,12 @@ calc_light (vec3 n, int ind)
{
vec3 d;
light l = lights[ind];
float mag;
d = l.position.xyz - position;
return l.color.rgb * (l.position.w * dot (d, n) / dot (d, d));
d = position - l.position.xyz;
mag = dot (d, n);
mag = max (0.0, mag);
return l.color.rgb * (l.position.w * mag / dot (d, d));
}
void

View file

@ -67,9 +67,10 @@ main (void)
// but probably good enough)
t = qmult (q0, vtangent.xyz);
#else
mat3 nm = mat3 (m[0].xyz, m[1].xyz, m[2].xyz);
v = (m * vec4 (vposition, 1.0)).xyz;
n = (m * vec4 (vnormal, 1.0)).xyz;
t = (m * vec4 (vtangent.xyz, 1.0)).xyz;
n = nm * vnormal;
t = nm * vtangent.xyz;
#endif
position = v * 8.0;
normal = norm_mat * n;