Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaia Clary <gaia.clary@machinimatrix.org>2021-05-17 22:05:20 +0300
committerGaia Clary <gaia.clary@machinimatrix.org>2021-05-17 22:10:05 +0300
commit43046d82b7d18398027afb6b92ea0be7588f08a8 (patch)
treec8d937700a29e0aef53848ef965bfa901586076b /source/blender/io
parent542b8da8315eabe4e8817255b82545b3b431c970 (diff)
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
Diffstat (limited to 'source/blender/io')
-rw-r--r--source/blender/io/collada/Materials.cpp30
1 files changed, 20 insertions, 10 deletions
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()