libagl: Transform the vertex if using eye space lighting with point lights

This fixes lighting when using point lights, when eye space
lighting is used (which is the default).

Change-Id: I0cd0d2329893d6b5f8af3b1e595274c2076fc322
This commit is contained in:
Martin Storsjo 2012-04-24 00:50:56 +03:00
parent db1597a989
commit d5b1cda91e

View File

@ -381,7 +381,14 @@ void lightVertex(ogles_context_t* c, vertex_t* v)
// compute vertex-to-light vector // compute vertex-to-light vector
if (ggl_unlikely(l.position.w)) { if (ggl_unlikely(l.position.w)) {
// lightPos/1.0 - vertex/vertex.w == lightPos*vertex.w - vertex // lightPos/1.0 - vertex/vertex.w == lightPos*vertex.w - vertex
#if !OBJECT_SPACE_LIGHTING
vec4_t o;
const transform_t& mv = c->transforms.modelview.transform;
mv.point4(&mv, &o, &v->obj);
vss3(d.v, l.objPosition.v, o.w, o.v);
#else
vss3(d.v, l.objPosition.v, v->obj.w, v->obj.v); vss3(d.v, l.objPosition.v, v->obj.w, v->obj.v);
#endif
sqDist = dot3(d.v, d.v); sqDist = dot3(d.v, d.v);
vscale3(d.v, d.v, gglSqrtRecipx(sqDist)); vscale3(d.v, d.v, gglSqrtRecipx(sqDist));
} else { } else {