Collada import: connect Emission texture to Emission socket

An emission texture is currently connected to the Base Color socket. It should connect to the Emission socket, like a constant does.

Reviewed By: gaiaclary

Differential Revision: https://developer.blender.org/D10990
This commit is contained in:
Scurest
2021-05-13 23:14:57 +02:00
committed by Gaia Clary
parent d889e9684a
commit 2953732fc5
6 changed files with 16 additions and 5 deletions

View File

@@ -133,6 +133,16 @@ void MaterialNode::add_link(bNode *from_node, int from_index, bNode *to_node, in
nodeAddLink(ntree, from_node, from_socket, to_node, to_socket);
}
void MaterialNode::add_link(bNode *from_node, const char* from_label, bNode *to_node, const char* to_label)
{
bNodeSocket *from_socket = nodeFindSocket(from_node, SOCK_OUT, from_label);
bNodeSocket *to_socket = nodeFindSocket(to_node, SOCK_IN, to_label);
if (from_socket && to_socket) {
nodeAddLink(ntree, from_node, from_socket, to_node, to_socket);
}
}
void MaterialNode::set_reflectivity(COLLADAFW::FloatOrParam &val)
{
float reflectivity = val.getFloatValue();
@@ -326,7 +336,7 @@ void MaterialNode::set_emission(COLLADAFW::ColorOrTexture &cot)
else if (cot.isTexture()) {
bNode *texture_node = add_texture_node(cot, -300, locy, "Emission");
if (texture_node != nullptr) {
add_link(texture_node, 0, shader_node, 0);
add_link(texture_node, "Color", shader_node, "Emission");
}
}

View File

@@ -48,6 +48,7 @@ class MaterialNode {
bNodeTree *prepare_material_nodetree();
bNode *add_node(int node_type, int locx, int locy, std::string label);
void add_link(bNode *from_node, int from_index, bNode *to_node, int to_index);
void add_link(bNode *from_node, const char* from_label, bNode *to_node, const char* to_label);
bNode *add_texture_node(COLLADAFW::ColorOrTexture &cot, int locx, int locy, std::string label);
void setShaderType();