[Bf-blender-cvs] [bafccb0] master: OpenGL: fix cycles texture draw mode not respecting double sided lighting.
Brecht Van Lommel
noreply at git.blender.org
Fri Nov 27 21:57:04 CET 2015
Commit: bafccb00dec6d882c580102aa4d0b0889c898154
Author: Brecht Van Lommel
Date: Fri Nov 27 02:29:57 2015 +0100
Branches: master
https://developer.blender.org/rBbafccb00dec6d882c580102aa4d0b0889c898154
OpenGL: fix cycles texture draw mode not respecting double sided lighting.
===================================================================
M source/blender/editors/space_view3d/drawmesh.c
===================================================================
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index 93e9910..728890a 100644
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@ -1138,6 +1138,8 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d,
if (ob->transflag & OB_NEG_SCALE) glFrontFace(GL_CW);
else glFrontFace(GL_CCW);
+ Mesh *me = ob->data;
+
if ((v3d->flag2 & V3D_SHADELESS_TEX) &&
((v3d->drawtype == OB_TEXTURE) || (ob->mode & OB_MODE_TEXTURE_PAINT)))
{
@@ -1145,52 +1147,51 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d,
}
else {
glEnable(GL_LIGHTING);
+ glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, (me->flag & ME_TWOSIDED) ? GL_TRUE : GL_FALSE);
}
- {
- Mesh *me = ob->data;
- TexMatCallback data = {scene, ob, me, dm};
- bool (*set_face_cb)(void *, int);
- bool picking = (G.f & G_PICKSEL) != 0;
-
- /* face hiding callback depending on mode */
- if (ob == scene->obedit)
- set_face_cb = tex_mat_set_face_editmesh_cb;
- else if (draw_flags & DRAW_FACE_SELECT)
- set_face_cb = tex_mat_set_face_mesh_cb;
- else
- set_face_cb = NULL;
-
- /* test if we can use glsl */
- bool glsl = (v3d->drawtype == OB_MATERIAL) && !picking;
+ TexMatCallback data = {scene, ob, me, dm};
+ bool (*set_face_cb)(void *, int);
+ bool picking = (G.f & G_PICKSEL) != 0;
+
+ /* face hiding callback depending on mode */
+ if (ob == scene->obedit)
+ set_face_cb = tex_mat_set_face_editmesh_cb;
+ else if (draw_flags & DRAW_FACE_SELECT)
+ set_face_cb = tex_mat_set_face_mesh_cb;
+ else
+ set_face_cb = NULL;
- GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL);
+ /* test if we can use glsl */
+ bool glsl = (v3d->drawtype == OB_MATERIAL) && !picking;
- if (glsl || picking) {
- /* draw glsl or solid */
- dm->drawMappedFacesMat(dm,
- tex_mat_set_material_cb,
- set_face_cb, &data);
- }
- else {
- float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL);
- /* draw textured */
- glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, zero);
- glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, zero);
- glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 0);
+ if (glsl || picking) {
+ /* draw glsl or solid */
+ dm->drawMappedFacesMat(dm,
+ tex_mat_set_material_cb,
+ set_face_cb, &data);
+ }
+ else {
+ float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- dm->drawMappedFacesMat(dm,
- tex_mat_set_texture_cb,
- set_face_cb, &data);
- }
+ /* draw textured */
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, zero);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, zero);
+ glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 0);
- GPU_end_object_materials();
+ dm->drawMappedFacesMat(dm,
+ tex_mat_set_texture_cb,
+ set_face_cb, &data);
}
+ GPU_end_object_materials();
+
/* reset opengl state */
glDisable(GL_COLOR_MATERIAL);
glDisable(GL_TEXTURE_2D);
+ glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
glDisable(GL_LIGHTING);
glBindTexture(GL_TEXTURE_2D, 0);
glFrontFace(GL_CCW);
More information about the Bf-blender-cvs
mailing list