Explorar el Código

ignoring outAlpha connection in layered texture

Asad M. Zaman hace 21 años
padre
commit
867b37b73a

+ 9 - 3
pandatool/src/maya/mayaShaderColorDef.cxx

@@ -331,8 +331,14 @@ read_surface_color(MayaShader *shader, MObject color, bool trans) {
       for (size_t j=0; j<pla.length(); ++j) {
         //maya_cat.debug() << pl.name() << " is(pl) " << pl.node().apiTypeStr() << endl;
         //maya_cat.debug() << pla[j].name() << " is(pla) " << pla[j].node().apiTypeStr() << endl;
+        string pla_name = pla[j].name().asChar();
+        // sometimes, by default, maya gives a outAlpha on subsequent plugs, ignore that
+        if (pla_name.find("outAlpha") != -1) {
+          maya_cat.debug() << pl.name() << " ignoring: " << pla_name << endl;
+          continue;
+        }
         if (!first) {
-          maya_cat.debug() << pl.name() << "next:connectedTo: " << pla[j].name() << endl;
+          maya_cat.debug() << pl.name() << " next:connectedTo: " << pla_name << endl;
           MayaShaderColorDef *color_p = new MayaShaderColorDef;
           color_p->read_surface_color(shader, pla[j].node());
           color_p->_texture_name.assign(pla[j].name().asChar());
@@ -342,7 +348,7 @@ read_surface_color(MayaShader *shader, MObject color, bool trans) {
           maya_cat.debug() << "uv_name : " << color_p->_texture_name << endl;
         }
         else {
-          maya_cat.debug() << pl.name() << " first:connectedTo: " << pla[j].name() << endl;
+          maya_cat.debug() << pl.name() << " first:connectedTo: " << pla_name << endl;
           read_surface_color(shader, pla[j].node());
           _texture_name.assign(pla[j].name().asChar());
           int loc = _texture_name.find('.',0);
@@ -356,7 +362,7 @@ read_surface_color(MayaShader *shader, MObject color, bool trans) {
         MPlug pl_temp = pla[j];
         MPlugArray pla_temp;
         pl_temp.connectedTo(pla_temp, true, false);
-        maya_cat.debug() << pl_temp.name() << "connectedTo:" << pla_temp.length() << " plugs\n";
+        maya_cat.debug() << pl_temp.name() << " connectedTo:" << pla_temp.length() << " plugs\n";
       }
       /*
       string blah;

+ 5 - 3
pandatool/src/mayaegg/mayaToEggConverter.cxx

@@ -2283,16 +2283,18 @@ set_shader_attributes(EggPrimitive &primitive, const MayaShader &shader, const M
         
         // if multi-textured, first texture in maya is on top, so
         if (shader._color.size() > 1) {
+          // last shader on the list is the base one, which should always pick up the alpha
+          // from the texture file. But the top textures may have to strip the alpha
           if (i!=shader._color.size()-1) {
             // read the _alpha_is_luminance to figure out env_type
             if (!shader._alpha_is_luminance)
               tex.set_env_type(EggTexture::ET_decal);
-          }
-          if (color_def->_alpha_is_luminance) {
             // multitexture modulate mode may specify, desired alpha on/off
-            if (color_def->_alpha_is_luminance)
+            if (!color_def->_alpha_is_luminance)
               tex.set_alpha_mode(EggRenderMode::AM_off);  // Force alpha to be 'off'
           }
+          if (color_def->_alpha_is_luminance) {
+          }
         }
       } else {  // trans_def._has_texture
         // We have a texture on transparency only.  Apply it as the