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
This commit is contained in:
parent
a86e815dd8
commit
1a4e7b16b2
|
@ -1 +1 @@
|
|||
Subproject commit bb16aba5bd3873794eefe167497118b6063b9a85
|
||||
Subproject commit 4fcdbfe7c20edfc1204c0aa46c98ea25354abcd9
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue