diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-07-05 13:44:15 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-07-05 19:43:48 +0300 |
commit | dbdafe1209a4787d6f8dcafa034bc9ced3c7f365 (patch) | |
tree | b9457d3f0c2c8e54de05dbc594d0e8caa4f514e0 /intern | |
parent | 5bd57aaa052d9578d089a92338d6f0977b5d6c5c (diff) |
Shaders: add target setting to material output node.
This makes it possible to have a single shading nodetree that contains
separate Cycles and Eevee shaders. By default the target is set to All
so shaders are shared.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/blender/addon/ui.py | 18 | ||||
-rw-r--r-- | intern/cycles/blender/blender_shader.cpp | 27 |
2 files changed, 10 insertions, 35 deletions
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index f8bc9ca8512..7a4ed4fbdaf 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -17,7 +17,7 @@ # <pep8 compliant> import bpy -from bpy_extras.node_utils import find_node_input, find_output_node +from bpy_extras.node_utils import find_node_input from bl_operators.presets import PresetMenu from bpy.types import ( @@ -1069,14 +1069,14 @@ class CYCLES_OT_use_shading_nodes(Operator): return {'FINISHED'} -def panel_node_draw(layout, id_data, output_types, input_name): +def panel_node_draw(layout, id_data, output_type, input_name): if not id_data.use_nodes: layout.operator("cycles.use_shading_nodes", icon='NODETREE') return False ntree = id_data.node_tree - node = find_output_node(ntree, output_types) + node = ntree.get_output_node('CYCLES') if node: input = find_node_input(node, input_name) if input: @@ -1176,7 +1176,7 @@ class CYCLES_LAMP_PT_nodes(CyclesButtonsPanel, Panel): layout = self.layout lamp = context.lamp - if not panel_node_draw(layout, lamp, ('OUTPUT_LAMP',), 'Surface'): + if not panel_node_draw(layout, lamp, 'OUTPUT_LAMP', 'Surface'): layout.prop(lamp, "color") @@ -1226,7 +1226,7 @@ class CYCLES_WORLD_PT_surface(CyclesButtonsPanel, Panel): world = context.world - if not panel_node_draw(layout, world, ('OUTPUT_WORLD',), 'Surface'): + if not panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Surface'): layout.prop(world, "horizon_color", text="Color") @@ -1244,7 +1244,7 @@ class CYCLES_WORLD_PT_volume(CyclesButtonsPanel, Panel): layout = self.layout world = context.world - panel_node_draw(layout, world, ('OUTPUT_WORLD',), 'Volume') + panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Volume') class CYCLES_WORLD_PT_ambient_occlusion(CyclesButtonsPanel, Panel): @@ -1425,7 +1425,7 @@ class CYCLES_MATERIAL_PT_surface(CyclesButtonsPanel, Panel): layout = self.layout mat = context.material - if not panel_node_draw(layout, mat, ('OUTPUT_MATERIAL', 'OUTPUT_EEVEE_MATERIAL'), 'Surface'): + if not panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Surface'): layout.prop(mat, "diffuse_color") @@ -1445,7 +1445,7 @@ class CYCLES_MATERIAL_PT_volume(CyclesButtonsPanel, Panel): mat = context.material # cmat = mat.cycles - panel_node_draw(layout, mat, ('OUTPUT_MATERIAL', 'OUTPUT_EEVEE_MATERIAL'), 'Volume') + panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Volume') class CYCLES_MATERIAL_PT_displacement(CyclesButtonsPanel, Panel): @@ -1461,7 +1461,7 @@ class CYCLES_MATERIAL_PT_displacement(CyclesButtonsPanel, Panel): layout = self.layout mat = context.material - panel_node_draw(layout, mat, ('OUTPUT_MATERIAL', 'OUTPUT_EEVEE_MATERIAL'), 'Displacement') + panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Displacement') class CYCLES_MATERIAL_PT_settings(CyclesButtonsPanel, Panel): diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index 66034919145..ed92cb71f04 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -1001,31 +1001,6 @@ static ShaderOutput *node_find_output_by_name(ShaderNode *node, return node->output(name.c_str()); } -static BL::ShaderNode find_output_node(BL::ShaderNodeTree& b_ntree) -{ - BL::ShaderNodeTree::nodes_iterator b_node; - BL::ShaderNode output_node(PointerRNA_NULL); - - for(b_ntree.nodes.begin(b_node); b_node != b_ntree.nodes.end(); ++b_node) { - BL::ShaderNodeOutputMaterial b_output_node(*b_node); - - if (b_output_node.is_a(&RNA_ShaderNodeOutputMaterial) || - b_output_node.is_a(&RNA_ShaderNodeOutputWorld) || - b_output_node.is_a(&RNA_ShaderNodeOutputLamp)) { - /* regular Cycles output node */ - if(b_output_node.is_active_output()) { - output_node = b_output_node; - break; - } - else if(!output_node.ptr.data) { - output_node = b_output_node; - } - } - } - - return output_node; -} - static void add_nodes(Scene *scene, BL::RenderEngine& b_engine, BL::BlendData& b_data, @@ -1045,7 +1020,7 @@ static void add_nodes(Scene *scene, BL::Node::outputs_iterator b_output; /* find the node to use for output if there are multiple */ - BL::ShaderNode output_node = find_output_node(b_ntree); + BL::ShaderNode output_node = b_ntree.get_output_node(BL::ShaderNodeOutputMaterial::target_CYCLES); /* add nodes */ for(b_ntree.nodes.begin(b_node); b_node != b_ntree.nodes.end(); ++b_node) { |