forked from bartvdbraak/blender
Cycles: for material/world/lamps, if use_nodes is disabled, show some
default shaders instead of black.
This commit is contained in:
parent
e2f2626179
commit
eedcba7ed5
@ -535,15 +535,24 @@ void BlenderSync::sync_materials()
|
||||
if(shader_map.sync(&shader, *b_mat)) {
|
||||
ShaderGraph *graph = new ShaderGraph();
|
||||
|
||||
/* create nodes */
|
||||
if(b_mat && b_mat->node_tree()) {
|
||||
shader->name = b_mat->name();
|
||||
shader->name = b_mat->name();
|
||||
|
||||
/* create nodes */
|
||||
if(b_mat->use_nodes() && b_mat->node_tree()) {
|
||||
PtrSockMap sock_to_node;
|
||||
BL::ShaderNodeTree b_ntree(b_mat->node_tree());
|
||||
|
||||
add_nodes(b_data, graph, b_ntree, NULL, sock_to_node);
|
||||
}
|
||||
else {
|
||||
ShaderNode *closure, *out;
|
||||
|
||||
closure = graph->add(new DiffuseBsdfNode());
|
||||
closure->input("Color")->value = get_float3(b_mat->diffuse_color());
|
||||
out = graph->output();
|
||||
|
||||
graph->connect(closure->output("BSDF"), out->input("Surface"));
|
||||
}
|
||||
|
||||
shader->set_graph(graph);
|
||||
shader->tag_update(scene);
|
||||
@ -565,12 +574,21 @@ void BlenderSync::sync_world()
|
||||
ShaderGraph *graph = new ShaderGraph();
|
||||
|
||||
/* create nodes */
|
||||
if(b_world && b_world.node_tree()) {
|
||||
if(b_world && b_world.use_nodes() && b_world.node_tree()) {
|
||||
PtrSockMap sock_to_node;
|
||||
BL::ShaderNodeTree b_ntree(b_world.node_tree());
|
||||
|
||||
add_nodes(b_data, graph, b_ntree, NULL, sock_to_node);
|
||||
}
|
||||
else if(b_world) {
|
||||
ShaderNode *closure, *out;
|
||||
|
||||
closure = graph->add(new BackgroundNode());
|
||||
closure->input("Color")->value = get_float3(b_world.horizon_color());
|
||||
out = graph->output();
|
||||
|
||||
graph->connect(closure->output("Background"), out->input("Surface"));
|
||||
}
|
||||
|
||||
shader->set_graph(graph);
|
||||
shader->tag_update(scene);
|
||||
@ -600,7 +618,7 @@ void BlenderSync::sync_lamps()
|
||||
ShaderGraph *graph = new ShaderGraph();
|
||||
|
||||
/* create nodes */
|
||||
if(b_lamp && b_lamp->node_tree()) {
|
||||
if(b_lamp->use_nodes() && b_lamp->node_tree()) {
|
||||
shader->name = b_lamp->name();
|
||||
|
||||
PtrSockMap sock_to_node;
|
||||
@ -608,6 +626,16 @@ void BlenderSync::sync_lamps()
|
||||
|
||||
add_nodes(b_data, graph, b_ntree, NULL, sock_to_node);
|
||||
}
|
||||
else {
|
||||
ShaderNode *closure, *out;
|
||||
|
||||
closure = graph->add(new EmissionNode());
|
||||
closure->input("Color")->value = get_float3(b_lamp->color());
|
||||
closure->input("Strength")->value.x = b_lamp->energy()*10.0f;
|
||||
out = graph->output();
|
||||
|
||||
graph->connect(closure->output("Emission"), out->input("Surface"));
|
||||
}
|
||||
|
||||
shader->set_graph(graph);
|
||||
shader->tag_update(scene);
|
||||
|
Loading…
Reference in New Issue
Block a user