diff --git a/pandatool/src/maya/mayaShader.cxx b/pandatool/src/maya/mayaShader.cxx index 05d6453876..2072018c08 100644 --- a/pandatool/src/maya/mayaShader.cxx +++ b/pandatool/src/maya/mayaShader.cxx @@ -50,6 +50,8 @@ MayaShader(MObject engine) { << "Reading shading engine " << get_name() << "\n"; } + _alpha_is_luminance = true; + bool found_shader = false; MPlug shader_plug = engine_fn.findPlug("surfaceShader"); if (!shader_plug.isNull()) { diff --git a/pandatool/src/maya/mayaShader.h b/pandatool/src/maya/mayaShader.h index 48b75e700e..c0923b5c05 100644 --- a/pandatool/src/maya/mayaShader.h +++ b/pandatool/src/maya/mayaShader.h @@ -53,6 +53,8 @@ public: typedef pvector ColorDef; ColorDef _color; + bool _alpha_is_luminance; + private: bool read_surface_shader(MObject shader); }; diff --git a/pandatool/src/maya/mayaShaderColorDef.cxx b/pandatool/src/maya/mayaShaderColorDef.cxx index 96e2aa872c..d02055683b 100644 --- a/pandatool/src/maya/mayaShaderColorDef.cxx +++ b/pandatool/src/maya/mayaShaderColorDef.cxx @@ -58,6 +58,8 @@ MayaShaderColorDef() { _wrap_u = true; _wrap_v = true; + _alpha_is_luminance = false; + _repeat_uv.set(1.0, 1.0); _offset.set(0.0, 0.0); _rotate_uv = 0.0; @@ -95,6 +97,8 @@ MayaShaderColorDef(MayaShaderColorDef ©) { _wrap_u = copy._wrap_u; _wrap_v = copy._wrap_v; + _alpha_is_luminance = copy._alpha_is_luminance; + _repeat_uv = copy._repeat_uv; _offset = copy._offset; _rotate_uv = copy._rotate_uv; @@ -256,6 +260,8 @@ read_surface_color(MayaShader *shader, MObject color, bool trans) { get_vec2f_attribute(color, "translateFrame", _translate_frame); get_angle_attribute(color, "rotateFrame", _rotate_frame); + get_bool_attribute(color, "alphaIsLuminance", _alpha_is_luminance); + get_bool_attribute(color, "mirror", _mirror); get_bool_attribute(color, "stagger", _stagger); get_bool_attribute(color, "wrapU", _wrap_u); @@ -309,6 +315,10 @@ read_surface_color(MayaShader *shader, MObject color, bool trans) { //shader->_multi_texture = true; //get_enum_attribute(color,"blendMode",shader->_blend_mode); //maya_cat.debug() << "blend mode :" << shader->_blend_mode << endl; + + get_bool_attribute(color, "alphaIsLuminance", shader->_alpha_is_luminance); + // get_bool_attribute(color, "isVisible", test_b); + MFnDependencyNode layered_fn(color); MPlugArray color_pa; MStatus status = layered_fn.getConnections(color_pa); @@ -351,10 +361,10 @@ read_surface_color(MayaShader *shader, MObject color, bool trans) { /* string blah; get_enum_attribute(pl.node(),"blendMode",blah); - maya_cat.debug() << "blend mode :" << blah << endl; + maya_cat.info() << "rsc layer: blend mode :" << blah << endl; float alpha; get_maya_attribute(pl.node(),"alpha",alpha); - maya_cat.debug() << "alpha :" << alpha << endl; + maya_cat.info() << "rsc layer: alpha :" << alpha << endl; */ } } else { diff --git a/pandatool/src/maya/mayaShaderColorDef.h b/pandatool/src/maya/mayaShaderColorDef.h index 9479b73c6e..c0729823a7 100755 --- a/pandatool/src/maya/mayaShaderColorDef.h +++ b/pandatool/src/maya/mayaShaderColorDef.h @@ -80,6 +80,8 @@ public: bool _stagger; bool _wrap_u; bool _wrap_v; + + bool _alpha_is_luminance; LVector2f _repeat_uv; LVector2f _offset; diff --git a/pandatool/src/mayaegg/mayaToEggConverter.cxx b/pandatool/src/mayaegg/mayaToEggConverter.cxx index 8839d7a376..bb9481826a 100644 --- a/pandatool/src/mayaegg/mayaToEggConverter.cxx +++ b/pandatool/src/mayaegg/mayaToEggConverter.cxx @@ -2281,13 +2281,19 @@ set_shader_attributes(EggPrimitive &primitive, const MayaShader &shader, const M //tex.set_format(EggTexture::F_rgb); } - /* // if multi-textured, first texture in maya is on top, so - // default it to decal - if ((shader._color.size() > 1) && (i!=shader._color.size()-1)) - tex.set_env_type(EggTexture::ET_decal); - */ - + if (shader._color.size() > 1) { + 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) + tex.set_alpha_mode(EggRenderMode::AM_off); // Force alpha to be 'off' + } + } } else { // trans_def._has_texture // We have a texture on transparency only. Apply it as the // primary filename, and set the format accordingly.