Selaa lähdekoodia

Add gl-separate-specular-color, enabled by default

rdb 12 vuotta sitten
vanhempi
sitoutus
f23f2a0ea7

+ 9 - 6
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -4965,11 +4965,7 @@ do_issue_material() {
   }
 #endif  // NDEBUG
 
-#ifndef OPENGLES
   GLenum face = material->get_twoside() ? GL_FRONT_AND_BACK : GL_FRONT;
-#else
-  static const GLenum face = GL_FRONT_AND_BACK;
-#endif  // OPENGLES
 
   call_glMaterialfv(face, GL_SPECULAR, material->get_specular());
   call_glMaterialfv(face, GL_EMISSION, material->get_emission());
@@ -5025,10 +5021,17 @@ do_issue_material() {
     }
   }
 
-#ifndef OPENGLES
   GLP(LightModeli)(GL_LIGHT_MODEL_LOCAL_VIEWER, material->get_local());
   GLP(LightModeli)(GL_LIGHT_MODEL_TWO_SIDE, material->get_twoside());
-#endif  // OPENGLES
+
+#ifndef OPENGLES
+  if (CLP(separate_specular_color)) {
+    GLP(LightModeli)(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
+  } else {
+    GLP(LightModeli)(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR);
+  }
+#endif
+
   report_my_gl_errors();
 #endif  // OPENGLES_2
 }

+ 8 - 0
panda/src/glstuff/glmisc_src.cxx

@@ -156,6 +156,14 @@ ConfigVariableBool CLP(force_no_flush)
   ("gl-force-no-flush", false, 
    PRC_DESC("Avoid calling glFlush(), for a potential performance benefit.  This may be a little dangerous."));
 
+ConfigVariableBool CLP(separate_specular_color)
+  ("gl-separate-specular-color", true, 
+   PRC_DESC("When separate specular mode is on, the specular component "
+            "will be written to the secondary instead of the primary "
+            "color, which is added after the texturing stage.  In other "
+            "words, the specular highlight will be unmodulated by the "
+            "color of the texture."));
+
 extern ConfigVariableBool CLP(parallel_arrays);
 
 void CLP(init_classes)() {

+ 1 - 0
panda/src/glstuff/glmisc_src.h

@@ -61,6 +61,7 @@ extern ConfigVariableBool CLP(force_depth_stencil);
 extern ConfigVariableBool CLP(matrix_palette);
 extern ConfigVariableBool CLP(force_no_error);
 extern ConfigVariableBool CLP(force_no_flush);
+extern ConfigVariableBool CLP(separate_specular_color);
 
 extern EXPCL_GL void CLP(init_classes)();