diff options
m--------- | release/datafiles/locale | 0 | ||||
m--------- | release/scripts/addons | 0 | ||||
m--------- | release/scripts/addons_contrib | 0 | ||||
-rw-r--r-- | source/blender/collada/EffectExporter.cpp | 11 | ||||
-rw-r--r-- | source/blender/collada/Materials.cpp | 29 |
5 files changed, 35 insertions, 5 deletions
diff --git a/release/datafiles/locale b/release/datafiles/locale -Subproject 0f771b0f380a1ae21d859416043c6119f66e40c +Subproject 6625026f62f492dd677f5f29c68b9d70c96fb34 diff --git a/release/scripts/addons b/release/scripts/addons -Subproject aa3366b7805bbe4d1afee890bda81b6d91bd47b +Subproject 979298511916b25ec97bb22feb1c06cc9fbc86d diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib -Subproject 0aa23a4d6177bed4c12392c81d0b767a8b35fe6 +Subproject b4fce25e94ec139554e821f58bbada3384b13af diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp index a784776d342..80f84738f6e 100644 --- a/source/blender/collada/EffectExporter.cpp +++ b/source/blender/collada/EffectExporter.cpp @@ -102,7 +102,12 @@ void EffectsExporter::set_shader_type(COLLADASW::EffectProfile &ep, Material *ma void EffectsExporter::set_transparency(COLLADASW::EffectProfile &ep, Material *ma) { double alpha = bc_get_alpha(ma); - ep.setTransparency(alpha, false, "alpha"); + if (alpha < 1) { + // workaround use <transparent> to avoid wrong handling of <transparency> by other tools + COLLADASW::ColorOrTexture cot = bc_get_cot(0, 0, 0, alpha); + ep.setTransparent(cot, false, "alpha"); + ep.setOpaque(COLLADASW::EffectProfile::A_ONE); + } } void EffectsExporter::set_diffuse_color(COLLADASW::EffectProfile &ep, Material *ma) @@ -134,7 +139,9 @@ void EffectsExporter::set_reflective(COLLADASW::EffectProfile &ep, Material *ma) void EffectsExporter::set_reflectivity(COLLADASW::EffectProfile &ep, Material *ma) { double reflectivity = bc_get_reflectivity(ma); - ep.setReflectivity(reflectivity, false, "specular"); + if (reflectivity > 0.0) { + ep.setReflectivity(reflectivity, false, "specular"); + } } void EffectsExporter::set_emission(COLLADASW::EffectProfile &ep, Material *ma) diff --git a/source/blender/collada/Materials.cpp b/source/blender/collada/Materials.cpp index d8a0f06c12b..e1d5b2e9d5c 100644 --- a/source/blender/collada/Materials.cpp +++ b/source/blender/collada/Materials.cpp @@ -168,13 +168,37 @@ void MaterialNode::set_alpha(COLLADAFW::EffectCommon::OpaqueMode mode, COLLADAFW::ColorOrTexture &cot, COLLADAFW::FloatOrParam &val) { + /* Handling the alpha value according to the Collada 1.4 reference guide + * see page 7-5 Determining Transparency (Opacity) + */ + if (effect == nullptr) { return; } if (cot.isColor() || !cot.isValid()) { - COLLADAFW::Color col = (cot.isValid()) ? cot.getColor() : COLLADAFW::Color(1, 1, 1, 1); - float alpha = val.getFloatValue() * col.getAlpha(); // Assuming A_ONE opaque mode + // transparent_cot is either a color or not defined + + float transparent_alpha; + if (cot.isValid()) { + COLLADAFW::Color col = cot.getColor(); + transparent_alpha = col.getAlpha(); + } + else { + // no transparent color defined + transparent_alpha = 1; + } + + float transparency_alpha = val.getFloatValue(); + if (transparency_alpha < 0) { + // transparency is not defined + transparency_alpha = 1; // set to opaque + } + + float alpha = transparent_alpha * transparency_alpha; + if (mode == COLLADASW::EffectProfile::RGB_ZERO) { + alpha = 1 - alpha; + } bNodeSocket *socket = nodeFindSocket(shader_node, SOCK_IN, "Alpha"); ((bNodeSocketValueFloat *)socket->default_value)->value = alpha; @@ -182,7 +206,6 @@ void MaterialNode::set_alpha(COLLADAFW::EffectCommon::OpaqueMode mode, else if (cot.isTexture()) { int locy = -300 * (node_map.size() - 2); add_texture_node(cot, -300, locy, "Alpha"); - // TODO: Connect node } } |