Prechádzať zdrojové kódy

support-rescale-normal

David Rose 20 rokov pred
rodič
commit
646aa49ea0

+ 9 - 0
panda/src/display/config_display.cxx

@@ -129,6 +129,15 @@ ConfigVariableBool support_render_texture
           "offscreen renders will be copied to a texture instead of directly "
           "offscreen renders will be copied to a texture instead of directly "
           "rendered there."));
           "rendered there."));
 
 
+ConfigVariableBool support_rescale_normal
+("support-rescale-normal", true,
+ PRC_DESC("Set this true allow use of the rescale-normal feature, if it "
+          "is supported by your graphics card.  This allows lighting normals "
+          "to be uniformly counter-scaled, instead of re-normalized, "
+          "in the presence of a uniform scale, which should in principle be "
+          "a bit faster.  This feature is only supported "
+          "by the OpenGL API."));
+
 ConfigVariableBool copy_texture_inverted
 ConfigVariableBool copy_texture_inverted
 ("copy-texture-inverted", false,
 ("copy-texture-inverted", false,
  PRC_DESC("Set this true to indicate that the GSG in use will invert textures when "
  PRC_DESC("Set this true to indicate that the GSG in use will invert textures when "

+ 1 - 0
panda/src/display/config_display.h

@@ -53,6 +53,7 @@ extern EXPCL_PANDA ConfigVariableBool prefer_parasite_buffer;
 extern EXPCL_PANDA ConfigVariableBool prefer_single_buffer;
 extern EXPCL_PANDA ConfigVariableBool prefer_single_buffer;
 
 
 extern EXPCL_PANDA ConfigVariableBool support_render_texture;
 extern EXPCL_PANDA ConfigVariableBool support_render_texture;
+extern EXPCL_PANDA ConfigVariableBool support_rescale_normal;
 extern EXPCL_PANDA ConfigVariableBool copy_texture_inverted;
 extern EXPCL_PANDA ConfigVariableBool copy_texture_inverted;
 extern EXPCL_PANDA ConfigVariableBool window_inverted;
 extern EXPCL_PANDA ConfigVariableBool window_inverted;
 extern EXPCL_PANDA ConfigVariableBool depth_offset_decals;
 extern EXPCL_PANDA ConfigVariableBool depth_offset_decals;

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

@@ -3665,13 +3665,13 @@ issue_rescale_normal(const RescaleNormalAttrib *attrib) {
   switch (mode) {
   switch (mode) {
   case RescaleNormalAttrib::M_none:
   case RescaleNormalAttrib::M_none:
     GLP(Disable)(GL_NORMALIZE);
     GLP(Disable)(GL_NORMALIZE);
-    if (_supports_rescale_normal) {
+    if (_supports_rescale_normal && support_rescale_normal) {
       GLP(Disable)(GL_RESCALE_NORMAL);
       GLP(Disable)(GL_RESCALE_NORMAL);
     }
     }
     break;
     break;
 
 
   case RescaleNormalAttrib::M_rescale:
   case RescaleNormalAttrib::M_rescale:
-    if (_supports_rescale_normal) {
+    if (_supports_rescale_normal && support_rescale_normal) {
       GLP(Enable)(GL_RESCALE_NORMAL);
       GLP(Enable)(GL_RESCALE_NORMAL);
       GLP(Disable)(GL_NORMALIZE);
       GLP(Disable)(GL_NORMALIZE);
     } else {
     } else {
@@ -3681,7 +3681,7 @@ issue_rescale_normal(const RescaleNormalAttrib *attrib) {
 
 
   case RescaleNormalAttrib::M_normalize:
   case RescaleNormalAttrib::M_normalize:
     GLP(Enable)(GL_NORMALIZE);
     GLP(Enable)(GL_NORMALIZE);
-    if (_supports_rescale_normal) {
+    if (_supports_rescale_normal && support_rescale_normal) {
       GLP(Disable)(GL_RESCALE_NORMAL);
       GLP(Disable)(GL_RESCALE_NORMAL);
     }
     }
     break;
     break;
@@ -5665,13 +5665,13 @@ do_auto_rescale_normal() {
     if (IS_NEARLY_EQUAL(_transform->get_uniform_scale(), 1.0f)) {
     if (IS_NEARLY_EQUAL(_transform->get_uniform_scale(), 1.0f)) {
       // If there's no scale at all, don't do anything.
       // If there's no scale at all, don't do anything.
       GLP(Disable)(GL_NORMALIZE);
       GLP(Disable)(GL_NORMALIZE);
-      if (_supports_rescale_normal) {
+      if (_supports_rescale_normal && support_rescale_normal) {
         GLP(Disable)(GL_RESCALE_NORMAL);
         GLP(Disable)(GL_RESCALE_NORMAL);
       }
       }
       
       
     } else {
     } else {
       // There's a uniform scale; use the rescale feature if available.
       // There's a uniform scale; use the rescale feature if available.
-      if (_supports_rescale_normal) {
+      if (_supports_rescale_normal && support_rescale_normal) {
         GLP(Enable)(GL_RESCALE_NORMAL);
         GLP(Enable)(GL_RESCALE_NORMAL);
         GLP(Disable)(GL_NORMALIZE);
         GLP(Disable)(GL_NORMALIZE);
       } else {
       } else {
@@ -5682,7 +5682,7 @@ do_auto_rescale_normal() {
   } else {
   } else {
     // If there's a non-uniform scale, normalize everything.
     // If there's a non-uniform scale, normalize everything.
     GLP(Enable)(GL_NORMALIZE);
     GLP(Enable)(GL_NORMALIZE);
-    if (_supports_rescale_normal) {
+    if (_supports_rescale_normal && support_rescale_normal) {
       GLP(Disable)(GL_RESCALE_NORMAL);
       GLP(Disable)(GL_RESCALE_NORMAL);
     }
     }
   }
   }