Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-02-06 22:21:24 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-02-06 22:21:24 +0300
commite40803a5b3ac860f895c2180fe90f0040f3583d5 (patch)
tree992d30305f2b27bd0f607c3dbb274a7fb4d1d388 /source/blender/gpu
parent09099111e39a7363fa186c4200b60b3b2bd93f9e (diff)
Fix for bug #18228: OpenGL specular did not get the correct view
vector in perspective mode. This is default OpenGL behavior, but by now this optimization is really insignificant. Works in both the 3d view and game engine.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/GPU_draw.h2
-rw-r--r--source/blender/gpu/intern/gpu_draw.c11
2 files changed, 8 insertions, 5 deletions
diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h
index 2399e7b6a8c..a5a2e2dd13e 100644
--- a/source/blender/gpu/GPU_draw.h
+++ b/source/blender/gpu/GPU_draw.h
@@ -82,7 +82,7 @@ int GPU_set_tpage(struct MTFace *tface);
int GPU_default_lights(void);
int GPU_scene_object_lights(struct Scene *scene, struct Object *ob,
- int lay, float viewmat[][4]);
+ int lay, float viewmat[][4], int ortho);
/* Text render
* - based on moving uv coordinates */
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 4025a12a867..84bed5ccdbd 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -993,6 +993,8 @@ int GPU_default_lights(void)
U.light[2].spec[3]= 1.0;
}
+ glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE);
+
glLightfv(GL_LIGHT0, GL_POSITION, U.light[0].vec);
glLightfv(GL_LIGHT0, GL_DIFFUSE, U.light[0].col);
glLightfv(GL_LIGHT0, GL_SPECULAR, U.light[0].spec);
@@ -1030,7 +1032,7 @@ int GPU_default_lights(void)
return count;
}
-int GPU_scene_object_lights(Scene *scene, Object *ob, int lay, float viewmat[][4])
+int GPU_scene_object_lights(Scene *scene, Object *ob, int lay, float viewmat[][4], int ortho)
{
Base *base;
Lamp *la;
@@ -1041,6 +1043,10 @@ int GPU_scene_object_lights(Scene *scene, Object *ob, int lay, float viewmat[][4
for(count=0; count<8; count++)
glDisable(GL_LIGHT0+count);
+ /* view direction for specular is not compute correct by default in
+ * opengl, so we set the settings ourselfs */
+ glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, (ortho)? GL_FALSE: GL_TRUE);
+
count= 0;
for(base=scene->base.first; base; base=base->next) {
@@ -1127,9 +1133,6 @@ void GPU_state_init(void)
GPU_default_lights();
- /* no local viewer, looks ugly in ortho mode */
- /* glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, &one); */
-
glDepthFunc(GL_LEQUAL);
/* scaling matrices */
glEnable(GL_NORMALIZE);