summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndroid Code Review <code-review@android.com>2009-08-25 14:37:12 -0700
committerAndroid Code Review <code-review@android.com>2009-08-25 14:37:12 -0700
commit595e1ec4a394ce589eb70d70a86efc4ac298cfe7 (patch)
treeb6e71ab63f9af4d3bbfd0a9b5cfc740513f70042
parent0b3546e653fbe339b8a206f40e5efa12b4295126 (diff)
parent79ad0e6623998ca2006aa0c17f902340132c3e1c (diff)
downloadframeworks_base-595e1ec4a394ce589eb70d70a86efc4ac298cfe7.zip
frameworks_base-595e1ec4a394ce589eb70d70a86efc4ac298cfe7.tar.gz
frameworks_base-595e1ec4a394ce589eb70d70a86efc4ac298cfe7.tar.bz2
Merge change 11106
* changes: Calculate specular lighting correctly
-rw-r--r--include/private/opengles/gl_context.h1
-rw-r--r--opengl/libagl/light.cpp11
2 files changed, 9 insertions, 3 deletions
diff --git a/include/private/opengles/gl_context.h b/include/private/opengles/gl_context.h
index a85f275..e32e332 100644
--- a/include/private/opengles/gl_context.h
+++ b/include/private/opengles/gl_context.h
@@ -285,6 +285,7 @@ struct light_t {
vec4_t normalizedObjPosition;
vec4_t spotDir;
vec4_t normalizedSpotDir;
+ vec4_t objViewer;
GLfixed spotExp;
GLfixed spotCutoff;
GLfixed spotCutoffCosine;
diff --git a/opengl/libagl/light.cpp b/opengl/libagl/light.cpp
index 8ae32cc0f..f211bca 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;