OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011, Blender Foundation. | 2 * Copyright 2011, Blender Foundation. |
3 * | 3 * |
4 * This program is free software; you can redistribute it and/or | 4 * This program is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU General Public License | 5 * modify it under the terms of the GNU General Public License |
6 * as published by the Free Software Foundation; either version 2 | 6 * as published by the Free Software Foundation; either version 2 |
7 * of the License, or (at your option) any later version. | 7 * of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 static void get_tex_mapping(TextureMapping *mapping, BL::ShaderNodeMapping b_map
ping) | 92 static void get_tex_mapping(TextureMapping *mapping, BL::ShaderNodeMapping b_map
ping) |
93 { | 93 { |
94 if(!b_mapping) | 94 if(!b_mapping) |
95 return; | 95 return; |
96 | 96 |
97 mapping->translation = get_float3(b_mapping.location()); | 97 mapping->translation = get_float3(b_mapping.location()); |
98 mapping->rotation = get_float3(b_mapping.rotation()); | 98 mapping->rotation = get_float3(b_mapping.rotation()); |
99 mapping->scale = get_float3(b_mapping.scale()); | 99 mapping->scale = get_float3(b_mapping.scale()); |
100 } | 100 } |
101 | 101 |
| 102 static ShaderSocketType convert_socket_type(BL::NodeSocket::type_enum b_type) |
| 103 { |
| 104 switch (b_type) { |
| 105 case BL::NodeSocket::type_VALUE: |
| 106 return SHADER_SOCKET_FLOAT; |
| 107 case BL::NodeSocket::type_VECTOR: |
| 108 return SHADER_SOCKET_VECTOR; |
| 109 case BL::NodeSocket::type_RGBA: |
| 110 return SHADER_SOCKET_COLOR; |
| 111 case BL::NodeSocket::type_SHADER: |
| 112 return SHADER_SOCKET_CLOSURE; |
| 113 ········ |
| 114 case BL::NodeSocket::type_BOOLEAN: |
| 115 case BL::NodeSocket::type_MESH: |
| 116 case BL::NodeSocket::type_INT: |
| 117 default: |
| 118 return SHADER_SOCKET_FLOAT; |
| 119 } |
| 120 } |
| 121 |
102 static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Shader
Node b_node) | 122 static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Shader
Node b_node) |
103 { | 123 { |
104 ShaderNode *node = NULL; | 124 ShaderNode *node = NULL; |
105 | 125 |
106 switch(b_node.type()) { | 126 switch(b_node.type()) { |
107 /* not supported */ | 127 /* not supported */ |
108 case BL::ShaderNode::type_CURVE_RGB: break; | 128 case BL::ShaderNode::type_CURVE_RGB: break; |
109 case BL::ShaderNode::type_CURVE_VEC: break; | 129 case BL::ShaderNode::type_CURVE_VEC: break; |
110 case BL::ShaderNode::type_GEOMETRY: break; | 130 case BL::ShaderNode::type_GEOMETRY: break; |
111 case BL::ShaderNode::type_MATERIAL: break; | 131 case BL::ShaderNode::type_MATERIAL: break; |
112 case BL::ShaderNode::type_MATERIAL_EXT: break; | 132 case BL::ShaderNode::type_MATERIAL_EXT: break; |
113 case BL::ShaderNode::type_OUTPUT: break; | 133 case BL::ShaderNode::type_OUTPUT: break; |
114 case BL::ShaderNode::type_SCRIPT: break; | 134 case BL::ShaderNode::type_SCRIPT: break; |
115 case BL::ShaderNode::type_SQUEEZE: break; | 135 case BL::ShaderNode::type_SQUEEZE: break; |
116 case BL::ShaderNode::type_TEXTURE: break; | 136 case BL::ShaderNode::type_TEXTURE: break; |
117 case BL::ShaderNode::type_VALTORGB: break; | 137 case BL::ShaderNode::type_VALTORGB: break; |
118 /* handled outside this function */ | 138 /* handled outside this function */ |
119 case BL::ShaderNode::type_GROUP: break; | 139 case BL::ShaderNode::type_GROUP: break; |
120 /* existing blender nodes */ | 140 /* existing blender nodes */ |
| 141 case BL::ShaderNode::type_PROXY_INPUT: { |
| 142 BL::NodeProxyInput b_proxy_node(b_node); |
| 143 ProxyNode *proxy = new ProxyNode(convert_socket_type(b_p
roxy_node.socket().type())); |
| 144 node = proxy; |
| 145 break; |
| 146 } |
| 147 case BL::ShaderNode::type_PROXY_OUTPUT: { |
| 148 BL::NodeProxyOutput b_proxy_node(b_node); |
| 149 ProxyNode *proxy = new ProxyNode(convert_socket_type(b_p
roxy_node.socket().type())); |
| 150 node = proxy; |
| 151 break; |
| 152 } |
121 case BL::ShaderNode::type_RGB: { | 153 case BL::ShaderNode::type_RGB: { |
122 ColorNode *color = new ColorNode(); | 154 ColorNode *color = new ColorNode(); |
123 color->value = get_node_output_rgba(b_node, "Color"); | 155 color->value = get_node_output_rgba(b_node, "Color"); |
124 node = color; | 156 node = color; |
125 break; | 157 break; |
126 } | 158 } |
127 case BL::ShaderNode::type_VALUE: { | 159 case BL::ShaderNode::type_VALUE: { |
128 ValueNode *value = new ValueNode(); | 160 ValueNode *value = new ValueNode(); |
129 value->value = get_node_output_value(b_node, "Value"); | 161 value->value = get_node_output_value(b_node, "Value"); |
130 node = value; | 162 node = value; |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 /* rename if needed */ | 484 /* rename if needed */ |
453 if(name == "Shader") | 485 if(name == "Shader") |
454 name = "Closure"; | 486 name = "Closure"; |
455 | 487 |
456 if(total > 1) | 488 if(total > 1) |
457 name = string_printf("%s%d", name.c_str(), counter); | 489 name = string_printf("%s%d", name.c_str(), counter); |
458 | 490 |
459 return SocketPair(node_map[b_node.ptr.data], name); | 491 return SocketPair(node_map[b_node.ptr.data], name); |
460 } | 492 } |
461 | 493 |
462 static ShaderSocketType convert_socket_type(BL::NodeSocket::type_enum b_type) | |
463 { | |
464 switch (b_type) { | |
465 case BL::NodeSocket::type_VALUE: | |
466 return SHADER_SOCKET_FLOAT; | |
467 case BL::NodeSocket::type_VECTOR: | |
468 return SHADER_SOCKET_VECTOR; | |
469 case BL::NodeSocket::type_RGBA: | |
470 return SHADER_SOCKET_COLOR; | |
471 case BL::NodeSocket::type_SHADER: | |
472 return SHADER_SOCKET_CLOSURE; | |
473 ········ | |
474 case BL::NodeSocket::type_BOOLEAN: | |
475 case BL::NodeSocket::type_MESH: | |
476 case BL::NodeSocket::type_INT: | |
477 default: | |
478 return SHADER_SOCKET_FLOAT; | |
479 } | |
480 } | |
481 | |
482 static void set_default_value(ShaderInput *input, BL::NodeSocket sock) | 494 static void set_default_value(ShaderInput *input, BL::NodeSocket sock) |
483 { | 495 { |
484 /* copy values for non linked inputs */ | 496 /* copy values for non linked inputs */ |
485 switch(input->type) { | 497 switch(input->type) { |
486 case SHADER_SOCKET_FLOAT: { | 498 case SHADER_SOCKET_FLOAT: { |
487 BL::NodeSocketFloatNone value_sock(sock); | 499 BL::NodeSocketFloatNone value_sock(sock); |
488 input->set(value_sock.default_value()); | 500 input->set(value_sock.default_value()); |
489 break; | 501 break; |
490 } | 502 } |
491 case SHADER_SOCKET_COLOR: { | 503 case SHADER_SOCKET_COLOR: { |
492 BL::NodeSocketRGBA rgba_sock(sock); | 504 BL::NodeSocketRGBA rgba_sock(sock); |
493 input->set(get_float3(rgba_sock.default_value())); | 505 input->set(get_float3(rgba_sock.default_value())); |
494 break; | 506 break; |
495 } | 507 } |
496 case SHADER_SOCKET_NORMAL: | 508 case SHADER_SOCKET_NORMAL: |
497 case SHADER_SOCKET_POINT: | 509 case SHADER_SOCKET_POINT: |
498 case SHADER_SOCKET_VECTOR: { | 510 case SHADER_SOCKET_VECTOR: { |
499 BL::NodeSocketVectorNone vec_sock(sock); | 511 BL::NodeSocketVectorNone vec_sock(sock); |
500 input->set(get_float3(vec_sock.default_value())); | 512 input->set(get_float3(vec_sock.default_value())); |
501 break; | 513 break; |
502 } | 514 } |
503 case SHADER_SOCKET_CLOSURE: | 515 case SHADER_SOCKET_CLOSURE: |
504 break; | 516 break; |
505 } | 517 } |
506 } | 518 } |
507 | 519 |
508 static void add_nodes(BL::BlendData b_data, ShaderGraph *graph, BL::ShaderNodeTr
ee b_ntree, PtrSockMap& sockets_map) | 520 static void add_nodes(BL::BlendData b_data, ShaderGraph *graph, BL::ShaderNodeTr
ee b_ntree, PtrNodeMap &node_map) |
509 { | 521 { |
510 /* add nodes */ | 522 /* add nodes */ |
511 BL::ShaderNodeTree::nodes_iterator b_node; | 523 BL::ShaderNodeTree::nodes_iterator b_node; |
512 PtrNodeMap node_map; | |
513 PtrSockMap proxy_map; | 524 PtrSockMap proxy_map; |
514 | 525 |
515 for(b_ntree.nodes.begin(b_node); b_node != b_ntree.nodes.end(); ++b_node
) { | 526 for(b_ntree.nodes.begin(b_node); b_node != b_ntree.nodes.end(); ++b_node
) { |
516 if(b_node->is_a(&RNA_NodeGroup)) { | 527 if(b_node->is_a(&RNA_NodeGroup)) { |
517 /* add proxy converter nodes for inputs and outputs */ | |
518 BL::NodeGroup b_gnode(*b_node); | 528 BL::NodeGroup b_gnode(*b_node); |
519 BL::ShaderNodeTree b_group_ntree(b_gnode.node_tree()); | 529 BL::ShaderNodeTree b_group_ntree(b_gnode.node_tree()); |
| 530 PtrNodeMap group_node_map; |
| 531 ························ |
520 BL::Node::inputs_iterator b_input; | 532 BL::Node::inputs_iterator b_input; |
521 BL::Node::outputs_iterator b_output; | 533 BL::Node::outputs_iterator b_output; |
| 534 BL::NodeTree::inputs_iterator b_group_input; |
| 535 BL::NodeTree::outputs_iterator b_group_output; |
522 ························ | 536 ························ |
523 » » » PtrSockMap group_sockmap; | 537 » » » add_nodes(b_data, graph, b_group_ntree, group_node_map); |
524 ························ | 538 ························ |
525 » » » for(b_node->inputs.begin(b_input); b_input != b_node->in
puts.end(); ++b_input) { | 539 » » » /* iterate node and ntree inputs in parallel, these are
in sync */ |
526 » » » » ShaderSocketType extern_type = convert_socket_ty
pe(b_input->type()); | 540 » » » for(b_node->inputs.begin(b_input), b_group_ntree.inputs.
begin(b_group_input); |
527 » » » » ShaderSocketType intern_type = convert_socket_ty
pe(b_input->group_socket().type()); | 541 » » » » b_input != b_node->inputs.end(); |
528 » » » » ShaderNode *proxy = graph->add(new ProxyNode(ext
ern_type, intern_type)); | 542 » » » » ++b_input, ++b_group_input) { |
529 ································ | 543 ································ |
530 » » » » /* map the external node socket to the proxy nod
e socket */ | 544 » » » » /* get internal proxy node from group node map *
/ |
| 545 » » » » assert(dynamic_cast<ProxyNode*>(group_node_map[b
_group_input->node()])); |
| 546 » » » » ProxyNode *proxy = static_cast<ProxyNode*>(group
_node_map[b_group_input->node()]); |
| 547 » » » »······· |
| 548 » » » » /* map the outer socket to the internal proxy no
de */ |
531 proxy_map[b_input->ptr.data] = SocketPair(proxy,
proxy->inputs[0]->name); | 549 proxy_map[b_input->ptr.data] = SocketPair(proxy,
proxy->inputs[0]->name); |
532 /* map the internal group socket to the proxy no
de socket */ | |
533 group_sockmap[b_input->group_socket().ptr.data]
= SocketPair(proxy, proxy->outputs[0]->name); | |
534 ································ | 550 ································ |
535 » » » » /* default input values of the group node */ | 551 » » » » /* input value for proxy inputs is defined by gr
oup node */ |
536 set_default_value(proxy->inputs[0], *b_input); | 552 set_default_value(proxy->inputs[0], *b_input); |
537 } | 553 } |
538 ························ | 554 ························ |
539 » » » for(b_node->outputs.begin(b_output); b_output != b_node-
>outputs.end(); ++b_output) { | 555 » » » /* iterate node and ntree outputs in parallel, these are
in sync */ |
540 » » » » ShaderSocketType extern_type = convert_socket_ty
pe(b_output->type()); | 556 » » » for(b_node->outputs.begin(b_output), b_group_ntree.outpu
ts.begin(b_group_output); |
541 » » » » ShaderSocketType intern_type = convert_socket_ty
pe(b_output->group_socket().type()); | 557 » » » » b_output != b_node->outputs.end(); |
542 » » » » ShaderNode *proxy = graph->add(new ProxyNode(int
ern_type, extern_type)); | 558 » » » » ++b_output, ++b_group_output) { |
543 ································ | 559 ································ |
544 » » » » /* map the external node socket to the proxy nod
e socket */ | 560 » » » » /* get internal proxy node from group node map *
/ |
| 561 » » » » assert(dynamic_cast<ProxyNode*>(group_node_map[b
_group_output->node()])); |
| 562 » » » » ProxyNode *proxy = static_cast<ProxyNode*>(group
_node_map[b_group_output->node()]); |
| 563 » » » »······· |
| 564 » » » » /* map the outer socket to the internal proxy no
de */ |
545 proxy_map[b_output->ptr.data] = SocketPair(proxy
, proxy->outputs[0]->name); | 565 proxy_map[b_output->ptr.data] = SocketPair(proxy
, proxy->outputs[0]->name); |
546 /* map the internal group socket to the proxy no
de socket */ | |
547 group_sockmap[b_output->group_socket().ptr.data]
= SocketPair(proxy, proxy->inputs[0]->name); | |
548 ································ | |
549 /* default input values of internal, unlinked gr
oup outputs */ | |
550 set_default_value(proxy->inputs[0], b_output->gr
oup_socket()); | |
551 } | 566 } |
552 ························ | |
553 add_nodes(b_data, graph, b_group_ntree, group_sockmap); | |
554 } | 567 } |
555 else { | 568 else { |
556 ShaderNode *node = add_node(b_data, graph, BL::ShaderNod
e(*b_node)); | 569 ShaderNode *node = add_node(b_data, graph, BL::ShaderNod
e(*b_node)); |
557 ························ | 570 ························ |
558 if(node) { | 571 if(node) { |
559 BL::Node::inputs_iterator b_input; | |
560 ································ | |
561 node_map[b_node->ptr.data] = node; | 572 node_map[b_node->ptr.data] = node; |
562 ································ | 573 ································ |
563 » » » » for(b_node->inputs.begin(b_input); b_input != b_
node->inputs.end(); ++b_input) { | 574 » » » » /* copy values for non linked inputs */ |
564 » » » » » SocketPair pair = node_socket_map_pair(n
ode_map, *b_node, *b_input); | 575 » » » » if(b_node->is_a(&RNA_NodeProxyInput)) { |
565 » » » » » ShaderInput *input = pair.first->input(p
air.second.c_str()); | 576 » » » » » /* input value for proxy input is define
d externally */ |
566 » » » » »······· | 577 » » » » } |
567 » » » » » assert(input); | 578 » » » » else if(b_node->is_a(&RNA_NodeProxyOutput)) { |
568 » » » » »······· | 579 » » » » » /* proxy output stores default output va
lue */ |
569 » » » » » /* copy values for non linked inputs */ | 580 » » » » » BL::NodeProxyOutput b_proxy_node(*b_node
); |
570 » » » » » set_default_value(input, *b_input); | 581 » » » » » set_default_value(node->inputs[0], b_pro
xy_node.socket()); |
| 582 » » » » } |
| 583 » » » » else { |
| 584 » » » » » /* for standard nodes: map to node input
s by socket name */ |
| 585 » » » » » BL::Node::inputs_iterator b_input; |
| 586 » » » » » for(b_node->inputs.begin(b_input); b_inp
ut != b_node->inputs.end(); ++b_input) { |
| 587 » » » » » » SocketPair pair = node_socket_ma
p_pair(node_map, *b_node, *b_input); |
| 588 » » » » » » ShaderInput *input = pair.first-
>input(pair.second.c_str()); |
| 589 » » » » » »······· |
| 590 » » » » » » assert(input); |
| 591 » » » » » »······· |
| 592 » » » » » » set_default_value(input, *b_inpu
t); |
| 593 » » » » » } |
571 } | 594 } |
572 } | 595 } |
573 } | 596 } |
574 } | 597 } |
575 | 598 |
576 /* connect nodes */ | 599 /* connect nodes */ |
577 BL::NodeTree::links_iterator b_link; | 600 BL::NodeTree::links_iterator b_link; |
578 | 601 |
579 for(b_ntree.links.begin(b_link); b_link != b_ntree.links.end(); ++b_link
) { | 602 for(b_ntree.links.begin(b_link); b_link != b_ntree.links.end(); ++b_link
) { |
580 /* get blender link data */ | 603 /* get blender link data */ |
581 BL::Node b_from_node = b_link->from_node(); | 604 BL::Node b_from_node = b_link->from_node(); |
582 BL::Node b_to_node = b_link->to_node(); | 605 BL::Node b_to_node = b_link->to_node(); |
583 | 606 |
584 BL::NodeSocket b_from_sock = b_link->from_socket(); | 607 BL::NodeSocket b_from_sock = b_link->from_socket(); |
585 BL::NodeSocket b_to_sock = b_link->to_socket(); | 608 BL::NodeSocket b_to_sock = b_link->to_socket(); |
586 | 609 |
587 » » SocketPair from_pair, to_pair; | 610 » » ShaderOutput *output = 0; |
588 | 611 » » ShaderInput *input = 0; |
589 » » /* links without a node pointer are connections to group inputs/
outputs */ | |
590 | 612 |
591 /* from sock */ | 613 /* from sock */ |
592 » » if(b_from_node) { | 614 » » if (b_from_node.is_a(&RNA_NodeGroup)) { |
593 » » » if (b_from_node.is_a(&RNA_NodeGroup)) | 615 » » » SocketPair from_pair = proxy_map[b_from_sock.ptr.data]; |
594 » » » » from_pair = proxy_map[b_from_sock.ptr.data]; | 616 » » » if (from_pair.first) |
595 » » » else | 617 » » » » output = from_pair.first->output(from_pair.secon
d.c_str()); |
596 » » » » from_pair = node_socket_map_pair(node_map, b_fro
m_node, b_from_sock); | |
597 } | 618 } |
598 » » else | 619 » » else if (b_from_node.is_a(&RNA_NodeProxyInput)) { |
599 » » » from_pair = sockets_map[b_from_sock.ptr.data]; | 620 » » » ShaderNode *proxy = node_map[b_from_node.ptr.data]; |
| 621 » » » if (proxy) |
| 622 » » » » output = proxy->outputs[0]; |
| 623 » » } |
| 624 » » else { |
| 625 » » » SocketPair from_pair = node_socket_map_pair(node_map, b_
from_node, b_from_sock); |
| 626 » » » if (from_pair.first) |
| 627 » » » » output = from_pair.first->output(from_pair.secon
d.c_str()); |
| 628 » » } |
600 | 629 |
601 /* to sock */ | 630 /* to sock */ |
602 » » if(b_to_node) { | 631 » » if (b_to_node.is_a(&RNA_NodeGroup)) { |
603 » » » if (b_to_node.is_a(&RNA_NodeGroup)) | 632 » » » SocketPair to_pair = proxy_map[b_to_sock.ptr.data]; |
604 » » » » to_pair = proxy_map[b_to_sock.ptr.data]; | 633 » » » if (to_pair.first) |
605 » » » else | 634 » » » » input = to_pair.first->input(to_pair.second.c_st
r()); |
606 » » » » to_pair = node_socket_map_pair(node_map, b_to_no
de, b_to_sock); | |
607 } | 635 } |
608 » » else | 636 » » else if (b_to_node.is_a(&RNA_NodeProxyOutput)) { |
609 » » » to_pair = sockets_map[b_to_sock.ptr.data]; | 637 » » » ShaderNode *proxy = node_map[b_to_node.ptr.data]; |
| 638 » » » if (proxy) |
| 639 » » » » input = proxy->inputs[0]; |
| 640 » » } |
| 641 » » else { |
| 642 » » » SocketPair to_pair = node_socket_map_pair(node_map, b_to
_node, b_to_sock); |
| 643 » » » if (to_pair.first) |
| 644 » » » » input = to_pair.first->input(to_pair.second.c_st
r()); |
| 645 » » } |
610 | 646 |
611 /* either node may be NULL when the node was not exported, typic
ally | 647 /* either node may be NULL when the node was not exported, typic
ally |
612 because the node type is not supported */ | 648 because the node type is not supported */ |
613 » » if(from_pair.first && to_pair.first) { | 649 » » if(output && input) |
614 » » » ShaderOutput *output = from_pair.first->output(from_pair
.second.c_str()); | |
615 » » » ShaderInput *input = to_pair.first->input(to_pair.second
.c_str()); | |
616 | |
617 graph->connect(output, input); | 650 graph->connect(output, input); |
618 } | |
619 } | 651 } |
620 } | 652 } |
621 | 653 |
622 /* Sync Materials */ | 654 /* Sync Materials */ |
623 | 655 |
624 void BlenderSync::sync_materials() | 656 void BlenderSync::sync_materials() |
625 { | 657 { |
626 shader_map.set_default(scene->shaders[scene->default_surface]); | 658 shader_map.set_default(scene->shaders[scene->default_surface]); |
627 | 659 |
628 /* material loop */ | 660 /* material loop */ |
629 BL::BlendData::materials_iterator b_mat; | 661 BL::BlendData::materials_iterator b_mat; |
630 | 662 |
631 for(b_data.materials.begin(b_mat); b_mat != b_data.materials.end(); ++b_
mat) { | 663 for(b_data.materials.begin(b_mat); b_mat != b_data.materials.end(); ++b_
mat) { |
632 Shader *shader; | 664 Shader *shader; |
633 ················ | 665 ················ |
634 /* test if we need to sync */ | 666 /* test if we need to sync */ |
635 if(shader_map.sync(&shader, *b_mat)) { | 667 if(shader_map.sync(&shader, *b_mat)) { |
636 ShaderGraph *graph = new ShaderGraph(); | 668 ShaderGraph *graph = new ShaderGraph(); |
637 | 669 |
638 shader->name = b_mat->name().c_str(); | 670 shader->name = b_mat->name().c_str(); |
639 shader->pass_id = b_mat->pass_index(); | 671 shader->pass_id = b_mat->pass_index(); |
640 | 672 |
641 /* create nodes */ | 673 /* create nodes */ |
642 if(b_mat->use_nodes() && b_mat->node_tree()) { | 674 if(b_mat->use_nodes() && b_mat->node_tree()) { |
643 » » » » PtrSockMap sock_to_node; | 675 » » » » PtrNodeMap node_map; |
644 BL::ShaderNodeTree b_ntree(b_mat->node_tree()); | 676 BL::ShaderNodeTree b_ntree(b_mat->node_tree()); |
645 | 677 |
646 » » » » add_nodes(b_data, graph, b_ntree, sock_to_node); | 678 » » » » add_nodes(b_data, graph, b_ntree, node_map); |
647 } | 679 } |
648 else { | 680 else { |
649 ShaderNode *closure, *out; | 681 ShaderNode *closure, *out; |
650 | 682 |
651 closure = graph->add(new DiffuseBsdfNode()); | 683 closure = graph->add(new DiffuseBsdfNode()); |
652 closure->input("Color")->value = get_float3(b_ma
t->diffuse_color()); | 684 closure->input("Color")->value = get_float3(b_ma
t->diffuse_color()); |
653 out = graph->output(); | 685 out = graph->output(); |
654 | 686 |
655 graph->connect(closure->output("BSDF"), out->inp
ut("Surface")); | 687 graph->connect(closure->output("BSDF"), out->inp
ut("Surface")); |
656 } | 688 } |
(...skipping 17 matching lines...) Expand all Loading... |
674 Background prevbackground = *background; | 706 Background prevbackground = *background; |
675 | 707 |
676 BL::World b_world = b_scene.world(); | 708 BL::World b_world = b_scene.world(); |
677 | 709 |
678 if(world_recalc || b_world.ptr.data != world_map) { | 710 if(world_recalc || b_world.ptr.data != world_map) { |
679 Shader *shader = scene->shaders[scene->default_background]; | 711 Shader *shader = scene->shaders[scene->default_background]; |
680 ShaderGraph *graph = new ShaderGraph(); | 712 ShaderGraph *graph = new ShaderGraph(); |
681 | 713 |
682 /* create nodes */ | 714 /* create nodes */ |
683 if(b_world && b_world.use_nodes() && b_world.node_tree()) { | 715 if(b_world && b_world.use_nodes() && b_world.node_tree()) { |
684 » » » PtrSockMap sock_to_node; | 716 » » » PtrNodeMap node_map; |
685 BL::ShaderNodeTree b_ntree(b_world.node_tree()); | 717 BL::ShaderNodeTree b_ntree(b_world.node_tree()); |
686 | 718 |
687 » » » add_nodes(b_data, graph, b_ntree, sock_to_node); | 719 » » » add_nodes(b_data, graph, b_ntree, node_map); |
688 } | 720 } |
689 else if(b_world) { | 721 else if(b_world) { |
690 ShaderNode *closure, *out; | 722 ShaderNode *closure, *out; |
691 | 723 |
692 closure = graph->add(new BackgroundNode()); | 724 closure = graph->add(new BackgroundNode()); |
693 closure->input("Color")->value = get_float3(b_world.hori
zon_color()); | 725 closure->input("Color")->value = get_float3(b_world.hori
zon_color()); |
694 out = graph->output(); | 726 out = graph->output(); |
695 | 727 |
696 graph->connect(closure->output("Background"), out->input
("Surface")); | 728 graph->connect(closure->output("Background"), out->input
("Surface")); |
697 } | 729 } |
(...skipping 22 matching lines...) Expand all Loading... |
720 Shader *shader; | 752 Shader *shader; |
721 ················ | 753 ················ |
722 /* test if we need to sync */ | 754 /* test if we need to sync */ |
723 if(shader_map.sync(&shader, *b_lamp)) { | 755 if(shader_map.sync(&shader, *b_lamp)) { |
724 ShaderGraph *graph = new ShaderGraph(); | 756 ShaderGraph *graph = new ShaderGraph(); |
725 | 757 |
726 /* create nodes */ | 758 /* create nodes */ |
727 if(b_lamp->use_nodes() && b_lamp->node_tree()) { | 759 if(b_lamp->use_nodes() && b_lamp->node_tree()) { |
728 shader->name = b_lamp->name().c_str(); | 760 shader->name = b_lamp->name().c_str(); |
729 | 761 |
730 » » » » PtrSockMap sock_to_node; | 762 » » » » PtrNodeMap node_map; |
731 BL::ShaderNodeTree b_ntree(b_lamp->node_tree()); | 763 BL::ShaderNodeTree b_ntree(b_lamp->node_tree()); |
732 | 764 |
733 » » » » add_nodes(b_data, graph, b_ntree, sock_to_node); | 765 » » » » add_nodes(b_data, graph, b_ntree, node_map); |
734 } | 766 } |
735 else { | 767 else { |
736 ShaderNode *closure, *out; | 768 ShaderNode *closure, *out; |
737 float strength = 1.0f; | 769 float strength = 1.0f; |
738 | 770 |
739 if(b_lamp->type() == BL::Lamp::type_POINT || | 771 if(b_lamp->type() == BL::Lamp::type_POINT || |
740 b_lamp->type() == BL::Lamp::type_SPOT || | 772 b_lamp->type() == BL::Lamp::type_SPOT || |
741 b_lamp->type() == BL::Lamp::type_AREA) | 773 b_lamp->type() == BL::Lamp::type_AREA) |
742 strength = 100.0f; | 774 strength = 100.0f; |
743 | 775 |
(...skipping 18 matching lines...) Expand all Loading... |
762 sync_world(); | 794 sync_world(); |
763 sync_lamps(); | 795 sync_lamps(); |
764 sync_materials(); | 796 sync_materials(); |
765 | 797 |
766 /* false = don't delete unused shaders, not supported */ | 798 /* false = don't delete unused shaders, not supported */ |
767 shader_map.post_sync(false); | 799 shader_map.post_sync(false); |
768 } | 800 } |
769 | 801 |
770 CCL_NAMESPACE_END | 802 CCL_NAMESPACE_END |
771 | 803 |
OLD | NEW |