summaryrefslogtreecommitdiff
path: root/opengl/libagl/light.cpp
diff options
context:
space:
mode:
author Android (Google) Code Review <android-gerrit@google.com> 2009-08-25 18:36:47 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2009-08-25 18:36:47 -0700
commite4066eabe1d9dfbfc36040f98c8372f79913845f (patch)
treeb38dd00e41613f1a80e22d6e403d21b7d6fec136 /opengl/libagl/light.cpp
parent6cc34a19620c8fe0009f9577a6d8124217fc31c0 (diff)
parente03eaa1551a644e9a13c327d16cc09bfd7649d78 (diff)
Merge change 22710 into eclair
* changes: Calculate specular lighting correctly
Diffstat (limited to 'opengl/libagl/light.cpp')
-rw-r--r--opengl/libagl/light.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/opengl/libagl/light.cpp b/opengl/libagl/light.cpp
index 8ae32cc0f0..f211bcab32 100644
--- a/opengl/libagl/light.cpp
+++ b/opengl/libagl/light.cpp
@@ -216,6 +216,8 @@ static inline void light_picker(ogles_context_t* c)
static inline void validate_light_mvi(ogles_context_t* c)
{
uint32_t en = c->lighting.enabledLights;
+ // Vector from object to viewer, in eye coordinates
+ const vec4_t eyeViewer = { 0, 0, 0x1000, 0 };
while (en) {
const int i = 31 - gglClz(en);
en &= ~(1<<i);
@@ -223,6 +225,9 @@ static inline void validate_light_mvi(ogles_context_t* c)
c->transforms.mvui.point4(&c->transforms.mvui,
&l.objPosition, &l.position);
vnorm3(l.normalizedObjPosition.v, l.objPosition.v);
+ c->transforms.mvui.point4(&c->transforms.mvui,
+ &l.objViewer, &eyeViewer);
+ vnorm3(l.objViewer.v, l.objViewer.v);
}
}
@@ -379,9 +384,9 @@ void lightVertex(ogles_context_t* c, vertex_t* v)
// specular
if (ggl_unlikely(s && l.implicitSpecular.v[3])) {
vec4_t h;
- h.x = d.x;
- h.y = d.y;
- h.z = d.z + 0x10000;
+ h.x = d.x + l.objViewer.x;
+ h.y = d.y + l.objViewer.y;
+ h.z = d.z + l.objViewer.z;
vnorm3(h.v, h.v);
s = dot3(n.v, h.v);
s = (s<0) ? (twoSide?(-s):0) : s;