[Bf-blender-cvs] [8fc68a2e9cf] master: Fix T69090: Collada Exporter now exports the base color if Nodes are disabled

Gaia Clary noreply at git.blender.org
Wed Jan 22 18:04:22 CET 2020


Commit: 8fc68a2e9cf1d983b3d249988ab05905bd24f06f
Author: Gaia Clary
Date:   Wed Jan 22 18:00:33 2020 +0100
Branches: master
https://developer.blender.org/rB8fc68a2e9cf1d983b3d249988ab05905bd24f06f

Fix T69090: Collada Exporter now exports the base color if Nodes are disabled

I also changed the Collada importer scuh that the diffuse Alpha is now set
for the generated PBSDF Shader AND for the base color.

Note: we can not export the base color AND the color
from the PBSDF Shaders at the same time. And when importing
we do not know if the color was originally coming from a base
material or from a shader. Setting them both in import seems
to give the most consistent results.

===================================================================

M	source/blender/collada/Materials.cpp
M	source/blender/collada/collada_utils.cpp

===================================================================

diff --git a/source/blender/collada/Materials.cpp b/source/blender/collada/Materials.cpp
index 3b2c68ef95e..06f54884668 100644
--- a/source/blender/collada/Materials.cpp
+++ b/source/blender/collada/Materials.cpp
@@ -202,6 +202,7 @@ void MaterialNode::set_alpha(COLLADAFW::EffectCommon::OpaqueMode mode,
 
     bNodeSocket *socket = nodeFindSocket(shader_node, SOCK_IN, "Alpha");
     ((bNodeSocketValueFloat *)socket->default_value)->value = alpha;
+    material->a = alpha;
   }
   else if (cot.isTexture()) {
     int locy = -300 * (node_map.size() - 2);
diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp
index 6116b04e122..d5011581204 100644
--- a/source/blender/collada/collada_utils.cpp
+++ b/source/blender/collada/collada_utils.cpp
@@ -1321,7 +1321,7 @@ void bc_add_default_shader(bContext *C, Material *ma)
 
 COLLADASW::ColorOrTexture bc_get_base_color(Material *ma)
 {
-  Color default_color = {0.8, 0.8, 0.8, 1.0};
+  Color default_color = {ma->r, ma->g, ma->b, 1.0}; // for alpha see bc_get_alpha()
   bNode *shader = bc_get_master_shader(ma);
   if (ma->use_nodes && shader) {
     return bc_get_cot_from_shader(shader, "Base Color", default_color, false);
@@ -1424,7 +1424,7 @@ COLLADASW::ColorOrTexture bc_get_cot_from_shader(bNode *shader,
     return bc_get_cot(col, with_alpha);
   }
   else {
-    return bc_get_cot(default_color, with_alpha); /* default black */
+    return bc_get_cot(default_color, with_alpha);
   }
 }



More information about the Bf-blender-cvs mailing list