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
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')
-rw-r--r--source/blender/gpu/GPU_draw.h2
-rw-r--r--source/blender/gpu/intern/gpu_draw.c11
-rw-r--r--source/blender/include/BSE_view.h1
-rw-r--r--source/blender/src/drawmesh.c6
-rw-r--r--source/blender/src/view.c22
5 files changed, 35 insertions, 7 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);
diff --git a/source/blender/include/BSE_view.h b/source/blender/include/BSE_view.h
index 55363bcf1f4..2a0485e229b 100644
--- a/source/blender/include/BSE_view.h
+++ b/source/blender/include/BSE_view.h
@@ -82,6 +82,7 @@ void viewmoveNDOF(int mode);
void view_zoom_mouseloc(float dfac, short *mouseloc);
int view_mouse_depth( float mouse_worldloc[3], short mval[2], int dist);
+int get_view3d_ortho(struct View3D *v3d);
int get_view3d_viewplane(int winxi, int winyi, rctf *viewplane, float *clipsta, float *clipend, float *pixsize);
void setwinmatrixview3d(int winx, int winy, struct rctf *rect);
diff --git a/source/blender/src/drawmesh.c b/source/blender/src/drawmesh.c
index ba266fa8c29..860bd8cee8f 100644
--- a/source/blender/src/drawmesh.c
+++ b/source/blender/src/drawmesh.c
@@ -75,6 +75,7 @@
#include "BDR_drawmesh.h"
#include "BSE_drawview.h"
+#include "BSE_view.h"
#include "GPU_extensions.h"
#include "GPU_draw.h"
@@ -351,9 +352,10 @@ static void draw_textured_begin(Object *ob)
solidtex= 1;
Gtexdraw.islit= -1;
}
- else
+ else {
/* draw with lights in the scene otherwise */
- Gtexdraw.islit= GPU_scene_object_lights(G.scene, ob, G.vd->lay, G.vd->viewmat);
+ Gtexdraw.islit= GPU_scene_object_lights(G.scene, ob, G.vd->lay, G.vd->viewmat, get_view3d_ortho(G.vd));
+ }
obcol[0]= CLAMPIS(ob->col[0]*255, 0, 255);
obcol[1]= CLAMPIS(ob->col[1]*255, 0, 255);
diff --git a/source/blender/src/view.c b/source/blender/src/view.c
index 8c16cfe705d..302bdf00e99 100644
--- a/source/blender/src/view.c
+++ b/source/blender/src/view.c
@@ -1579,6 +1579,28 @@ void object_view_settings(Object *ob, float *lens, float *clipsta, float *clipen
}
}
+int get_view3d_ortho(View3D *v3d)
+{
+ Camera *cam;
+
+ if(v3d->persp==V3D_CAMOB) {
+ if(v3d->camera && v3d->camera->type==OB_CAMERA) {
+ cam= v3d->camera->data;
+
+ if(cam && cam->type==CAM_ORTHO)
+ return 1;
+ else
+ return 0;
+ }
+ else
+ return 0;
+ }
+
+ if(v3d->persp==V3D_ORTHO)
+ return 1;
+
+ return 0;
+}
int get_view3d_viewplane(int winxi, int winyi, rctf *viewplane, float *clipsta, float *clipend, float *pixsize)
{