Commit: 43046d82b7d18398027afb6b92ea0be7588f08a8 Author: Gaia Clary Date: Mon May 17 21:05:20 2021 +0200 Branches: master https://developer.blender.org/rB43046d82b7d18398027afb6b92ea0be7588f08a8
Collada import: use black for Base Color when missing <diffuse> Treat a missing <diffuse> the same as a black diffuse color. The easiest way to see this bug is with a Collada shader like ``` <constant> <emission> <color sid="emission">1 0 0 1</color> </emission> </constant> ``` The Collada spec says this should be just ``` color = <emission> ``` ie. red everywhere. The importer slots the red into the Principled Emission socket, but since it leaves the Base Color as the default off-white, this is added to red, and the material looks white-pink in the light and red only in the shadows. Putting black in the Base Color makes it look red everywhere. D10939 will also eliminate the much-less-noticeable specular term for this case. Reviewed By: gaiaclary Differential Revision: https://developer.blender.org/D10941 =================================================================== M source/blender/io/collada/Materials.cpp =================================================================== diff --git a/source/blender/io/collada/Materials.cpp b/source/blender/io/collada/Materials.cpp index 4b90e459e61..ac4c65464c8 100644 --- a/source/blender/io/collada/Materials.cpp +++ b/source/blender/io/collada/Materials.cpp @@ -231,22 +231,32 @@ void MaterialNode::set_alpha(COLLADAFW::EffectCommon::OpaqueMode mode, void MaterialNode::set_diffuse(COLLADAFW::ColorOrTexture &cot) { int locy = -300 * (node_map.size() - 2); - if (cot.isColor()) { - COLLADAFW::Color col = cot.getColor(); - bNodeSocket *socket = nodeFindSocket(shader_node, SOCK_IN, "Base Color"); - float *fcol = (float *)socket->default_value; - fcol[0] = material->r = col.getRed(); - fcol[1] = material->g = col.getGreen(); - fcol[2] = material->b = col.getBlue(); - fcol[3] = material->a = col.getAlpha(); - } - else if (cot.isTexture()) { + if (cot.isTexture()) { bNode *texture_node = add_texture_node(cot, -300, locy, "Base Color"); if (texture_node != nullptr) { add_link(texture_node, 0, shader_node, 0); } } + else { + bNodeSocket *socket = nodeFindSocket(shader_node, SOCK_IN, "Base Color"); + float *fcol = (float *)socket->default_value; + + if (cot.isColor()) { + COLLADAFW::Color col = cot.getColor(); + fcol[0] = material->r = col.getRed(); + fcol[1] = material->g = col.getGreen(); + fcol[2] = material->b = col.getBlue(); + fcol[3] = material->a = col.getAlpha(); + } + else { + /* no diffuse term = same as black */ + fcol[0] = material->r = 0.0f; + fcol[1] = material->g = 0.0f; + fcol[2] = material->b = 0.0f; + fcol[3] = material->a = 1.0f; + } + } } Image *MaterialNode::get_diffuse_image() _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs