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:
authorScurest <scurest>2021-05-17 20:49:15 +0300
committerGaia Clary <gaia.clary@machinimatrix.org>2021-05-17 20:56:01 +0300
commit1a4e7b16b2640750f6dfe380218aba028f998ae1 (patch)
tree18cf628cfbb7c9ef75008296050a3fe33af155b6 /source/blender/io/collada
parenta86e815dd86fb77d910bbc857106bedb4b691874 (diff)
Collada import: respect zero-specularity
Collada shaders with black <specular> should import with Specular=0. (A missing <specular> is the same as black.) The general specular conversion is hard, but this case is common and easy. Fixes the specular for all <constant>/<lambert> shaders, and <blinn>/<phong> shaders with black/omitted <specular>. Before this they all looked too "shiny". Reviewed By: gaiaclary Differential Revision: https://developer.blender.org/D10939
Diffstat (limited to 'source/blender/io/collada')
-rw-r--r--source/blender/io/collada/Materials.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/source/blender/io/collada/Materials.cpp b/source/blender/io/collada/Materials.cpp
index c7244575752..508844de042 100644
--- a/source/blender/io/collada/Materials.cpp
+++ b/source/blender/io/collada/Materials.cpp
@@ -376,18 +376,34 @@ void MaterialNode::set_opacity(COLLADAFW::ColorOrTexture &cot)
void MaterialNode::set_specular(COLLADAFW::ColorOrTexture &cot)
{
+ bool is_zero = false;
int locy = -300 * (node_map.size() - 2);
if (cot.isColor()) {
COLLADAFW::Color col = cot.getColor();
- bNode *node = add_node(SH_NODE_RGB, -300, locy, "Specular");
- set_color(node, col);
- /* TODO: Connect node */
+
+ if (col.getRed() == 0 && col.getGreen() == 0 && col.getBlue() == 0) {
+ is_zero = true;
+ }
+ else {
+ bNode *node = add_node(SH_NODE_RGB, -300, locy, "Specular");
+ set_color(node, col);
+ /* TODO: Connect node */
+ }
}
/* texture */
else if (cot.isTexture()) {
add_texture_node(cot, -300, locy, "Specular");
/* TODO: Connect node */
}
+ /* not specified (no specular term) */
+ else {
+ is_zero = true;
+ }
+
+ if (is_zero) {
+ bNodeSocket *socket = nodeFindSocket(shader_node, SOCK_IN, "Specular");
+ ((bNodeSocketValueFloat *)socket->default_value)->value = 0.0f;
+ }
}
bNode *MaterialNode::add_texture_node(COLLADAFW::ColorOrTexture &cot,