Browse Source

ShaderGenerator: fix error with normal map and only ambient light

Closes #331
rdb 7 years ago
parent
commit
c08339e8ce
1 changed files with 4 additions and 4 deletions
  1. 4 4
      panda/src/pgraphnodes/shaderGenerator.cxx

+ 4 - 4
panda/src/pgraphnodes/shaderGenerator.cxx

@@ -353,7 +353,7 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) {
       if (parallax_mapping_samples == 0) {
       if (parallax_mapping_samples == 0) {
         info._mode = TextureStage::M_normal;
         info._mode = TextureStage::M_normal;
       } else if (!shader_attrib->auto_normal_on() ||
       } else if (!shader_attrib->auto_normal_on() ||
-                 (!key._lighting && (key._outputs & AuxBitplaneAttrib::ABO_aux_normal) == 0)) {
+                 (key._lights.empty() && (key._outputs & AuxBitplaneAttrib::ABO_aux_normal) == 0)) {
         info._mode = TextureStage::M_height;
         info._mode = TextureStage::M_height;
         info._flags = ShaderKey::TF_has_alpha;
         info._flags = ShaderKey::TF_has_alpha;
       } else {
       } else {
@@ -362,7 +362,7 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) {
       break;
       break;
 
 
     case TextureStage::M_normal_gloss:
     case TextureStage::M_normal_gloss:
-      if (!shader_attrib->auto_gloss_on() || !key._lighting) {
+      if (!shader_attrib->auto_gloss_on() || key._lights.empty()) {
         info._mode = TextureStage::M_normal;
         info._mode = TextureStage::M_normal;
       } else if (!shader_attrib->auto_normal_on()) {
       } else if (!shader_attrib->auto_normal_on()) {
         info._mode = TextureStage::M_gloss;
         info._mode = TextureStage::M_gloss;
@@ -411,7 +411,7 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) {
     switch (info._mode) {
     switch (info._mode) {
     case TextureStage::M_normal:
     case TextureStage::M_normal:
       if (!shader_attrib->auto_normal_on() ||
       if (!shader_attrib->auto_normal_on() ||
-          (!key._lighting && (key._outputs & AuxBitplaneAttrib::ABO_aux_normal) == 0)) {
+          (key._lights.empty() && (key._outputs & AuxBitplaneAttrib::ABO_aux_normal) == 0)) {
         skip = true;
         skip = true;
       } else {
       } else {
         info._flags = ShaderKey::TF_map_normal;
         info._flags = ShaderKey::TF_map_normal;
@@ -425,7 +425,7 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) {
       }
       }
       break;
       break;
     case TextureStage::M_gloss:
     case TextureStage::M_gloss:
-      if (key._lighting && shader_attrib->auto_gloss_on()) {
+      if (!key._lights.empty() && shader_attrib->auto_gloss_on()) {
         info._flags = ShaderKey::TF_map_gloss;
         info._flags = ShaderKey::TF_map_gloss;
       } else {
       } else {
         skip = true;
         skip = true;