Changeset View
Changeset View
Standalone View
Standalone View
source/blender/io/collada/Materials.cpp
| Show First 20 Lines • Show All 225 Lines • ▼ Show 20 Lines | else if (cot.isTexture()) { | ||||
| int locy = -300 * (node_map.size() - 2); | int locy = -300 * (node_map.size() - 2); | ||||
| add_texture_node(cot, -300, locy, "Alpha"); | add_texture_node(cot, -300, locy, "Alpha"); | ||||
| } | } | ||||
| } | } | ||||
| void MaterialNode::set_diffuse(COLLADAFW::ColorOrTexture &cot) | void MaterialNode::set_diffuse(COLLADAFW::ColorOrTexture &cot) | ||||
| { | { | ||||
| int locy = -300 * (node_map.size() - 2); | int locy = -300 * (node_map.size() - 2); | ||||
| if (cot.isColor()) { | |||||
| COLLADAFW::Color col = cot.getColor(); | 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"); | bNodeSocket *socket = nodeFindSocket(shader_node, SOCK_IN, "Base Color"); | ||||
| float *fcol = (float *)socket->default_value; | float *fcol = (float *)socket->default_value; | ||||
| if (cot.isColor()) { | |||||
| COLLADAFW::Color col = cot.getColor(); | |||||
| fcol[0] = material->r = col.getRed(); | fcol[0] = material->r = col.getRed(); | ||||
| fcol[1] = material->g = col.getGreen(); | fcol[1] = material->g = col.getGreen(); | ||||
| fcol[2] = material->b = col.getBlue(); | fcol[2] = material->b = col.getBlue(); | ||||
| fcol[3] = material->a = col.getAlpha(); | fcol[3] = material->a = col.getAlpha(); | ||||
| } | } | ||||
| else if (cot.isTexture()) { | else { | ||||
| bNode *texture_node = add_texture_node(cot, -300, locy, "Base Color"); | /* no diffuse term = same as black */ | ||||
| if (texture_node != nullptr) { | fcol[0] = material->r = 0.0f; | ||||
| add_link(texture_node, 0, shader_node, 0); | fcol[1] = material->g = 0.0f; | ||||
| fcol[2] = material->b = 0.0f; | |||||
| fcol[3] = material->a = 1.0f; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Image *MaterialNode::get_diffuse_image() | Image *MaterialNode::get_diffuse_image() | ||||
| { | { | ||||
| bNode *shader = ntreeFindType(ntree, SH_NODE_BSDF_PRINCIPLED); | bNode *shader = ntreeFindType(ntree, SH_NODE_BSDF_PRINCIPLED); | ||||
| if (shader == nullptr) { | if (shader == nullptr) { | ||||
| ▲ Show 20 Lines • Show All 185 Lines • Show Last 20 Lines | |||||