def init(node_tree): """Initialize node tree with links for this shader. :param node_tree: node tree on which this shader should be created :type node_tree: bpy.types.NodeTree """ start_pos_x = 0 start_pos_y = 0 # init parent DifSpecAddEnv.init(node_tree) geom_n = node_tree.nodes[DifSpecAddEnv.GEOM_NODE] spec_col_n = node_tree.nodes[DifSpecAddEnv.SPEC_COL_NODE] base_tex_n = node_tree.nodes[DifSpecAddEnv.BASE_TEX_NODE] out_mat_n = node_tree.nodes[DifSpecAddEnv.OUT_MAT_NODE] node_tree.nodes.remove(node_tree.nodes[DifSpecAddEnv.SPEC_MULT_NODE]) # create nodes uv_recalc_gn = node_tree.nodes.new("ShaderNodeGroup") uv_recalc_gn.name = window_uv_offset.WINDOW_UV_OFFSET_G uv_recalc_gn.label = window_uv_offset.WINDOW_UV_OFFSET_G uv_recalc_gn.location = (start_pos_x, start_pos_y + 1500) uv_recalc_gn.node_tree = window_uv_offset.get_node_group() # create links node_tree.links.new(out_mat_n.inputs["Spec"], spec_col_n.outputs["Color"]) node_tree.links.new(uv_recalc_gn.inputs["UV"], geom_n.outputs["UV"]) node_tree.links.new(uv_recalc_gn.inputs["Normal"], geom_n.outputs["Normal"]) node_tree.links.new(base_tex_n.inputs["Vector"], uv_recalc_gn.outputs["UV Final"])
def init(node_tree): """Initialize node tree with links for this shader. :param node_tree: node tree on which this shader should be created :type node_tree: bpy.types.NodeTree """ # init parent DifSpecAddEnv.init(node_tree)
def init(node_tree): """Initialize node tree with links for this shader. :param node_tree: node tree on which this shader should be created :type node_tree: bpy.types.NodeTree """ # init parents DifSpecAddEnv.init(node_tree) Lamp.init(node_tree, init_dif_spec=False, start_pos_x=0, start_pos_y=500)
def init(node_tree): """Initialize node tree with links for this shader. :param node_tree: node tree on which this shader should be created :type node_tree: bpy.types.NodeTree """ # init parent DifSpecAddEnv.init(node_tree) # set fresnel factor to 0 node_tree.nodes[DifSpecAddEnv.ADD_ENV_GROUP_NODE].inputs['Apply Fresnel'].default_value = 0.0
def init(node_tree): """Initialize node tree with links for this shader. :param node_tree: node tree on which this shader should be created :type node_tree: bpy.types.NodeTree """ # init parent DifSpecAddEnv.init(node_tree) # set fresnel factor to 0 node_tree.nodes[DifSpecAddEnv.ADD_ENV_GROUP_NODE].inputs[ 'Apply Fresnel'].default_value = 0.0
def init(node_tree): """Initialize node tree with links for this shader. :param node_tree: node tree on which this shader should be created :type node_tree: bpy.types.NodeTree """ # init parent DifSpecAddEnv.init(node_tree) geometry_n = node_tree.nodes[DifSpecAddEnv.GEOM_NODE] refl_tex_n = node_tree.nodes[DifSpecAddEnv.REFL_TEX_NODE] # change mapping of reflection texture to View coordinates, it gives better effect for plain surfaces node_tree.links.new(refl_tex_n.inputs['Vector'], geometry_n.outputs['View'])
def init(node_tree): """Initialize node tree with links for this shader. :param node_tree: node tree on which this shader should be created :type node_tree: bpy.types.NodeTree """ # init parents DifSpecAddEnv.init(node_tree) Lamp.init(node_tree, init_dif_spec=False, start_pos_x=0, start_pos_y=500) out_add_lampmask_n = node_tree.nodes[Lamp.OUT_ADD_LAMPMASK_NODE] out_add_lampmask_n.location.y -= 300 out_add_refl_n = node_tree.nodes[DifSpecAddEnv.OUT_ADD_REFL_NODE] # links fixing node_tree.links.new(out_add_lampmask_n.inputs["Color2"], out_add_refl_n.outputs["Color"])
def init(node_tree): """Initialize node tree with links for this shader. :param node_tree: node tree on which this shader should be created :type node_tree: bpy.types.NodeTree """ # init parents DifSpecAddEnv.init(node_tree) Lamp.init(node_tree, init_dif_spec=False, start_pos_x=0, start_pos_y=500) out_add_lampmask_n = node_tree.nodes[Lamp.OUT_ADD_LAMPMASK_NODE] out_add_lampmask_n.location.y -= 300 compose_lighting_n = node_tree.nodes[DifSpecAddEnv.COMPOSE_LIGHTING_NODE] # links fixing node_tree.links.new(out_add_lampmask_n.inputs["Color2"], compose_lighting_n.outputs["Composed Color"])
def init(node_tree): """Initialize node tree with links for this shader. :param node_tree: node tree on which this shader should be created :type node_tree: bpy.types.NodeTree """ start_pos_x = 0 start_pos_y = 0 # init parent DifSpecAddEnv.init(node_tree) geom_n = node_tree.nodes[DifSpecAddEnv.GEOM_NODE] uv_map_n = node_tree.nodes[DifSpecAddEnv.UVMAP_NODE] spec_col_n = node_tree.nodes[DifSpecAddEnv.SPEC_COL_NODE] base_tex_n = node_tree.nodes[DifSpecAddEnv.BASE_TEX_NODE] compose_lighting_n = node_tree.nodes[ DifSpecAddEnv.COMPOSE_LIGHTING_NODE] node_tree.nodes.remove(node_tree.nodes[DifSpecAddEnv.SPEC_MULT_NODE]) # create nodes uv_recalc_n = node_tree.nodes.new("ShaderNodeGroup") uv_recalc_n.name = window_uv_offset_ng.WINDOW_UV_OFFSET_G uv_recalc_n.label = window_uv_offset_ng.WINDOW_UV_OFFSET_G uv_recalc_n.location = (start_pos_x, start_pos_y + 1500) uv_recalc_n.node_tree = window_uv_offset_ng.get_node_group() # create links node_tree.links.new(compose_lighting_n.inputs['Specular Color'], spec_col_n.outputs['Color']) node_tree.links.new(uv_recalc_n.inputs['UV'], uv_map_n.outputs['UV']) node_tree.links.new(uv_recalc_n.inputs['Normal'], geom_n.outputs['Normal']) node_tree.links.new(uv_recalc_n.inputs['Incoming'], geom_n.outputs['Incoming']) node_tree.links.new(base_tex_n.inputs['Vector'], uv_recalc_n.outputs['UV Final'])
def init(node_tree): """Initialize node tree with links for this shader. :param node_tree: node tree on which this shader should be created :type node_tree: bpy.types.NodeTree """ pos_x_shift = 185 start_pos_x = 0 start_pos_y = 0 # init parent DifSpecAddEnv.init(node_tree) geom_n = node_tree.nodes[DifSpecAddEnv.GEOM_NODE] spec_col_n = node_tree.nodes[DifSpecAddEnv.SPEC_COL_NODE] base_tex_n = node_tree.nodes[DifSpecAddEnv.BASE_TEX_NODE] diff_mult_n = node_tree.nodes[DifSpecAddEnv.DIFF_MULT_NODE] out_mat_n = node_tree.nodes[DifSpecAddEnv.OUT_MAT_NODE] compose_lighting_n = node_tree.nodes[ DifSpecAddEnv.COMPOSE_LIGHTING_NODE] output_n = node_tree.nodes[DifSpecAddEnv.OUTPUT_NODE] # move existing output_n.location.x += pos_x_shift out_mat_n.location.y -= 150 # remove existing node_tree.nodes.remove(node_tree.nodes[DifSpecAddEnv.SPEC_MULT_NODE]) node_tree.nodes.remove(node_tree.nodes[DifSpecAddEnv.VCOL_GROUP_NODE]) node_tree.nodes.remove( node_tree.nodes[DifSpecAddEnv.VCOLOR_SCALE_NODE]) node_tree.nodes.remove(node_tree.nodes[DifSpecAddEnv.VCOLOR_MULT_NODE]) node_tree.nodes.remove(node_tree.nodes[DifSpecAddEnv.OPACITY_NODE]) for link in node_tree.links: if link.from_node == diff_mult_n and link.to_node == out_mat_n: node_tree.links.remove(link) break # create nodes uv_recalc_gn = node_tree.nodes.new("ShaderNodeGroup") uv_recalc_gn.name = window_uv_offset.WINDOW_UV_OFFSET_G uv_recalc_gn.label = window_uv_offset.WINDOW_UV_OFFSET_G uv_recalc_gn.location = (start_pos_x, start_pos_y + 1500) uv_recalc_gn.node_tree = window_uv_offset.get_node_group() sec_geom_n = node_tree.nodes.new("ShaderNodeGeometry") sec_geom_n.name = sec_geom_n.label = WindowNight.SEC_GEOM_NODE sec_geom_n.location = (start_pos_x - pos_x_shift, start_pos_y + 1200) sec_geom_n.uv_layer = _MESH_consts.none_uv lightmap_tex_n = node_tree.nodes.new("ShaderNodeTexture") lightmap_tex_n.name = lightmap_tex_n.label = WindowNight.LIGHTMAP_TEX_NODE lightmap_tex_n.location = (start_pos_x + pos_x_shift, start_pos_y + 1200) base_lightmap_mult_n = node_tree.nodes.new("ShaderNodeMixRGB") base_lightmap_mult_n.name = base_lightmap_mult_n.label = WindowNight.BASE_LIGHTMAP_MULT_NODE base_lightmap_mult_n.location = (start_pos_x + pos_x_shift * 3, start_pos_y + 1300) base_lightmap_mult_n.blend_type = "MULTIPLY" base_lightmap_mult_n.inputs["Fac"].default_value = 1.0 base_alpha_mult_n = node_tree.nodes.new("ShaderNodeMixRGB") base_alpha_mult_n.name = base_alpha_mult_n.label = WindowNight.BASE_ALPHA_MULT_NODE base_alpha_mult_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 1500) base_alpha_mult_n.blend_type = "MULTIPLY" base_alpha_mult_n.inputs["Fac"].default_value = 1.0 out_add_spec_n = node_tree.nodes.new("ShaderNodeMixRGB") out_add_spec_n.name = out_add_spec_n.label = WindowNight.BASE_ALPHA_MULT_NODE out_add_spec_n.location = (start_pos_x + pos_x_shift * 9, start_pos_y + 1900) out_add_spec_n.blend_type = "ADD" out_add_spec_n.inputs["Fac"].default_value = 1.0 # create links node_tree.links.new(uv_recalc_gn.inputs["UV"], geom_n.outputs["UV"]) node_tree.links.new(uv_recalc_gn.inputs["Normal"], geom_n.outputs["Normal"]) node_tree.links.new(base_tex_n.inputs["Vector"], uv_recalc_gn.outputs["UV Final"]) node_tree.links.new(lightmap_tex_n.inputs["Vector"], sec_geom_n.outputs["UV"]) # pass 1 node_tree.links.new(base_lightmap_mult_n.inputs["Color1"], base_tex_n.outputs["Color"]) node_tree.links.new(base_lightmap_mult_n.inputs["Color2"], lightmap_tex_n.outputs["Color"]) # pass 2 node_tree.links.new(base_alpha_mult_n.inputs["Color1"], base_tex_n.outputs["Value"]) node_tree.links.new(base_alpha_mult_n.inputs["Color2"], base_lightmap_mult_n.outputs["Color"]) # pass 3 node_tree.links.new(diff_mult_n.inputs["Color2"], base_alpha_mult_n.outputs["Color"]) # output material node_tree.links.new(out_mat_n.inputs["Spec"], spec_col_n.outputs["Color"]) # post pass 1 node_tree.links.new(compose_lighting_n.inputs["Diffuse Color"], diff_mult_n.outputs["Color"]) node_tree.links.new(compose_lighting_n.inputs["Material Color"], diff_mult_n.outputs["Color"]) # post pass 2 node_tree.links.new(out_add_spec_n.inputs["Color1"], compose_lighting_n.outputs["Composed Color"]) node_tree.links.new(out_add_spec_n.inputs["Color2"], out_mat_n.outputs["Spec"]) # output pass node_tree.links.new(output_n.inputs["Color"], out_add_spec_n.outputs["Color"])
def init(node_tree): """Initialize node tree with links for this shader. :param node_tree: node tree on which this shader should be created :type node_tree: bpy.types.NodeTree """ start_pos_x = 0 start_pos_y = 0 pos_x_shift = 185 # init parent DifSpecAddEnv.init(node_tree) base_tex_n = node_tree.nodes[DifSpecAddEnv.BASE_TEX_NODE] env_color_n = node_tree.nodes[DifSpecAddEnv.ENV_COLOR_NODE] spec_color_n = node_tree.nodes[DifSpecAddEnv.SPEC_COL_NODE] diff_mult_n = node_tree.nodes[DifSpecAddEnv.DIFF_MULT_NODE] add_refl_gn = node_tree.nodes[DifSpecAddEnv.ADD_ENV_GROUP_NODE] spec_mult_n = node_tree.nodes[DifSpecAddEnv.SPEC_MULT_NODE] vcol_scale_n = node_tree.nodes[DifSpecAddEnv.VCOLOR_SCALE_NODE] opacity_n = node_tree.nodes[DifSpecAddEnv.OPACITY_NODE] out_mat_n = node_tree.nodes[DifSpecAddEnv.OUT_MAT_NODE] compose_lighting_n = node_tree.nodes[ DifSpecAddEnv.COMPOSE_LIGHTING_NODE] output_n = node_tree.nodes[DifSpecAddEnv.OUTPUT_NODE] # move existing add_refl_gn.location.x += pos_x_shift * 3 spec_mult_n.location.x += pos_x_shift * 3 out_mat_n.location.x += pos_x_shift * 2 compose_lighting_n.location.x += pos_x_shift * 2 output_n.location.x += pos_x_shift * 2 # set fresnel factor to 1 node_tree.nodes[DifSpecAddEnv.ADD_ENV_GROUP_NODE].inputs[ 'Apply Fresnel'].default_value = 1.0 # node creation - level 3 env_vcol_mix_n = node_tree.nodes.new("ShaderNodeMixRGB") env_vcol_mix_n.name = Truckpaint.ENV_VCOL_MULT_NODE env_vcol_mix_n.label = Truckpaint.ENV_VCOL_MULT_NODE env_vcol_mix_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 2000) env_vcol_mix_n.blend_type = "MULTIPLY" env_vcol_mix_n.inputs['Fac'].default_value = 1 spec_vcol_mix_n = node_tree.nodes.new("ShaderNodeMixRGB") spec_vcol_mix_n.name = Truckpaint.SPEC_VCOL_MULT_NODE spec_vcol_mix_n.label = Truckpaint.SPEC_VCOL_MULT_NODE spec_vcol_mix_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 1750) spec_vcol_mix_n.blend_type = "MULTIPLY" spec_vcol_mix_n.inputs['Fac'].default_value = 1 opacity_vcol_n = node_tree.nodes.new("ShaderNodeMath") opacity_vcol_n.name = Truckpaint.OPACITY_VCOL_MULT_NODE opacity_vcol_n.label = Truckpaint.OPACITY_VCOL_MULT_NODE opacity_vcol_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 1300) opacity_vcol_n.operation = "MULTIPLY" # node creation - level 5 base_paint_mult_n = node_tree.nodes.new("ShaderNodeMixRGB") base_paint_mult_n.name = Truckpaint.BASE_PAINT_MULT_NODE base_paint_mult_n.label = Truckpaint.BASE_PAINT_MULT_NODE base_paint_mult_n.location = (start_pos_x + pos_x_shift * 6, start_pos_y + 1500) base_paint_mult_n.blend_type = "MULTIPLY" base_paint_mult_n.inputs['Fac'].default_value = 1 base_paint_mult_n.inputs[ 'Color2'].default_value = _convert_utils.to_node_color( _get_scs_globals().base_paint_color) # node creation - level 6 paint_mult_n = node_tree.nodes.new("ShaderNodeMixRGB") paint_mult_n.name = Truckpaint.PAINT_MULT_NODE paint_mult_n.label = Truckpaint.PAINT_MULT_NODE paint_mult_n.location = (start_pos_x + pos_x_shift * 7, start_pos_y + 1400) paint_mult_n.blend_type = "MULTIPLY" paint_mult_n.inputs['Fac'].default_value = 0 # make links - level 2 node_tree.links.new(env_vcol_mix_n.inputs['Color1'], env_color_n.outputs['Color']) node_tree.links.new(env_vcol_mix_n.inputs['Color2'], vcol_scale_n.outputs['Color']) node_tree.links.new(spec_vcol_mix_n.inputs['Color1'], base_tex_n.outputs['Value']) node_tree.links.new(spec_vcol_mix_n.inputs['Color2'], vcol_scale_n.outputs['Color']) # make links - level 3 node_tree.links.new(add_refl_gn.inputs['Env Factor Color'], env_vcol_mix_n.outputs['Color']) node_tree.links.new(spec_mult_n.inputs['Color1'], spec_color_n.outputs['Color']) node_tree.links.new(spec_mult_n.inputs['Color2'], spec_vcol_mix_n.outputs['Color']) node_tree.links.new(opacity_vcol_n.inputs[0], vcol_scale_n.outputs['Color']) node_tree.links.new(opacity_vcol_n.inputs[1], opacity_n.outputs[0]) # make links - level 4 node_tree.links.new(base_paint_mult_n.inputs['Color1'], diff_mult_n.outputs['Color']) # make links - level 5 node_tree.links.new(paint_mult_n.inputs['Color1'], base_paint_mult_n.outputs['Color']) # make links - output node_tree.links.new(out_mat_n.inputs['Color'], paint_mult_n.outputs['Color']) node_tree.links.new(compose_lighting_n.inputs['Diffuse Color'], paint_mult_n.outputs['Color'])
def init(node_tree): """Initialize node tree with links for this shader. :param node_tree: node tree on which this shader should be created :type node_tree: bpy.types.NodeTree """ start_pos_x = 0 start_pos_y = 0 pos_x_shift = 185 # init parent DifSpecAddEnv.init(node_tree) base_tex_n = node_tree.nodes[DifSpecAddEnv.BASE_TEX_NODE] env_color_n = node_tree.nodes[DifSpecAddEnv.ENV_COLOR_NODE] spec_color_n = node_tree.nodes[DifSpecAddEnv.SPEC_COL_NODE] diff_mult_n = node_tree.nodes[DifSpecAddEnv.DIFF_MULT_NODE] add_refl_gn = node_tree.nodes[DifSpecAddEnv.ADD_ENV_GROUP_NODE] spec_mult_n = node_tree.nodes[DifSpecAddEnv.SPEC_MULT_NODE] vcol_scale_n = node_tree.nodes[DifSpecAddEnv.VCOLOR_SCALE_NODE] opacity_n = node_tree.nodes[DifSpecAddEnv.OPACITY_NODE] out_mat_n = node_tree.nodes[DifSpecAddEnv.OUT_MAT_NODE] out_add_refl_n = node_tree.nodes[DifSpecAddEnv.OUT_ADD_REFL_NODE] output_n = node_tree.nodes[DifSpecAddEnv.OUTPUT_NODE] # move existing add_refl_gn.location.x += pos_x_shift * 2 spec_mult_n.location.x += pos_x_shift * 2 out_mat_n.location.x += pos_x_shift out_add_refl_n.location.x += pos_x_shift output_n.location.x += pos_x_shift # set fresnel factor to 0 node_tree.nodes[DifSpecAddEnv.ADD_ENV_GROUP_NODE].inputs['Apply Fresnel'].default_value = 0.0 # node creation - level 0 paint_geom_n = node_tree.nodes.new("ShaderNodeGeometry") paint_geom_n.name = Truckpaint.PAINT_GEOM_NODE paint_geom_n.label = Truckpaint.PAINT_GEOM_NODE paint_geom_n.location = (start_pos_x - pos_x_shift, start_pos_y + 950) paint_geom_n.uv_layer = _MESH_consts.none_uv # node creation - level 1 paint_base_col_n = node_tree.nodes.new("ShaderNodeRGB") paint_base_col_n.name = Truckpaint.PAINT_BASE_COL_NODE paint_base_col_n.label = Truckpaint.PAINT_BASE_COL_NODE paint_base_col_n.location = (start_pos_x + pos_x_shift, start_pos_y + 950) paint_tex_n = node_tree.nodes.new("ShaderNodeTexture") paint_tex_n.name = Truckpaint.PAINT_TEX_NODE paint_tex_n.label = Truckpaint.PAINT_TEX_NODE paint_tex_n.location = (start_pos_x + pos_x_shift, start_pos_y + 750) paint_b_col_n = node_tree.nodes.new("ShaderNodeRGB") paint_b_col_n.name = Truckpaint.PAINT_B_COL_NODE paint_b_col_n.label = Truckpaint.PAINT_B_COL_NODE paint_b_col_n.location = (start_pos_x + pos_x_shift, start_pos_y + 450) paint_g_col_n = node_tree.nodes.new("ShaderNodeRGB") paint_g_col_n.name = Truckpaint.PAINT_G_COL_NODE paint_g_col_n.label = Truckpaint.PAINT_G_COL_NODE paint_g_col_n.location = (start_pos_x + pos_x_shift, start_pos_y + 250) paint_r_col_n = node_tree.nodes.new("ShaderNodeRGB") paint_r_col_n.name = Truckpaint.PAINT_R_COL_NODE paint_r_col_n.label = Truckpaint.PAINT_R_COL_NODE paint_r_col_n.location = (start_pos_x + pos_x_shift, start_pos_y + 50) # node creation - level 2 paint_tex_sep = node_tree.nodes.new("ShaderNodeSeparateRGB") paint_tex_sep.name = Truckpaint.PAINT_TEX_SEP_NODE paint_tex_sep.label = Truckpaint.PAINT_TEX_SEP_NODE paint_tex_sep.location = (start_pos_x + pos_x_shift * 3, start_pos_y + 650) # node creation - level 3 env_vcol_mix_n = node_tree.nodes.new("ShaderNodeMixRGB") env_vcol_mix_n.name = Truckpaint.ENV_VCOL_MULT_NODE env_vcol_mix_n.label = Truckpaint.ENV_VCOL_MULT_NODE env_vcol_mix_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 2000) env_vcol_mix_n.blend_type = "MULTIPLY" env_vcol_mix_n.inputs['Fac'].default_value = 1 spec_vcol_mix_n = node_tree.nodes.new("ShaderNodeMixRGB") spec_vcol_mix_n.name = Truckpaint.SPEC_VCOL_MULT_NODE spec_vcol_mix_n.label = Truckpaint.SPEC_VCOL_MULT_NODE spec_vcol_mix_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 1750) spec_vcol_mix_n.blend_type = "MULTIPLY" spec_vcol_mix_n.inputs['Fac'].default_value = 1 opacity_vcol_n = node_tree.nodes.new("ShaderNodeMath") opacity_vcol_n.name = Truckpaint.OPACITY_VCOL_MULT_NODE opacity_vcol_n.label = Truckpaint.OPACITY_VCOL_MULT_NODE opacity_vcol_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 1300) opacity_vcol_n.operation = "MULTIPLY" airbrush_mix_n = node_tree.nodes.new("ShaderNodeMixRGB") airbrush_mix_n.name = Truckpaint.AIRBRUSH_MIX_NODE airbrush_mix_n.label = Truckpaint.AIRBRUSH_MIX_NODE airbrush_mix_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 1000) airbrush_mix_n.blend_type = "MIX" col_mask_b_mix_n = node_tree.nodes.new("ShaderNodeMixRGB") col_mask_b_mix_n.name = Truckpaint.COL_MASK_B_MIX_NODE col_mask_b_mix_n.label = Truckpaint.COL_MASK_B_MIX_NODE col_mask_b_mix_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 600) col_mask_b_mix_n.blend_type = "MIX" col_mask_g_mix_n = node_tree.nodes.new("ShaderNodeMixRGB") col_mask_g_mix_n.name = Truckpaint.COL_MASK_G_MIX_NODE col_mask_g_mix_n.label = Truckpaint.COL_MASK_G_MIX_NODE col_mask_g_mix_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 400) col_mask_g_mix_n.blend_type = "MIX" col_mask_r_mix_n = node_tree.nodes.new("ShaderNodeMixRGB") col_mask_r_mix_n.name = Truckpaint.COL_MASK_R_MIX_NODE col_mask_r_mix_n.label = Truckpaint.COL_MASK_R_MIX_NODE col_mask_r_mix_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 200) col_mask_r_mix_n.blend_type = "MIX" # node creation - level 4 blend_mix_n = node_tree.nodes.new("ShaderNodeMixRGB") blend_mix_n.name = Truckpaint.BLEND_MIX_NODE blend_mix_n.label = Truckpaint.BLEND_MIX_NODE blend_mix_n.location = (start_pos_x + pos_x_shift * 5, start_pos_y + 800) blend_mix_n.inputs['Fac'].default_value = 1.0 blend_mix_n.blend_type = "MIX" # node creation - level 5 paint_mult_n = node_tree.nodes.new("ShaderNodeMixRGB") paint_mult_n.name = Truckpaint.PAINT_MULT_NODE paint_mult_n.label = Truckpaint.PAINT_MULT_NODE paint_mult_n.location = (start_pos_x + pos_x_shift * 6, start_pos_y + 1400) paint_mult_n.blend_type = "MULTIPLY" paint_mult_n.inputs['Fac'].default_value = 0 # make links - level 0 node_tree.links.new(paint_tex_n.inputs['Vector'], paint_geom_n.outputs['UV']) # make links - level 1 node_tree.links.new(paint_tex_sep.inputs['Image'], paint_tex_n.outputs['Color']) # make links - level 2 node_tree.links.new(env_vcol_mix_n.inputs['Color1'], env_color_n.outputs['Color']) node_tree.links.new(env_vcol_mix_n.inputs['Color2'], vcol_scale_n.outputs['Color']) node_tree.links.new(spec_vcol_mix_n.inputs['Color1'], base_tex_n.outputs['Value']) node_tree.links.new(spec_vcol_mix_n.inputs['Color2'], vcol_scale_n.outputs['Color']) node_tree.links.new(airbrush_mix_n.inputs['Fac'], paint_tex_n.outputs['Value']) node_tree.links.new(airbrush_mix_n.inputs['Color1'], paint_base_col_n.outputs['Color']) node_tree.links.new(airbrush_mix_n.inputs['Color2'], paint_tex_n.outputs['Color']) node_tree.links.new(col_mask_b_mix_n.inputs['Fac'], paint_tex_sep.outputs['B']) node_tree.links.new(col_mask_b_mix_n.inputs['Color1'], paint_base_col_n.outputs['Color']) node_tree.links.new(col_mask_b_mix_n.inputs['Color2'], paint_b_col_n.outputs['Color']) node_tree.links.new(col_mask_g_mix_n.inputs['Fac'], paint_tex_sep.outputs['G']) node_tree.links.new(col_mask_g_mix_n.inputs['Color1'], col_mask_b_mix_n.outputs['Color']) node_tree.links.new(col_mask_g_mix_n.inputs['Color2'], paint_g_col_n.outputs['Color']) node_tree.links.new(col_mask_r_mix_n.inputs['Fac'], paint_tex_sep.outputs['R']) node_tree.links.new(col_mask_r_mix_n.inputs['Color1'], col_mask_g_mix_n.outputs['Color']) node_tree.links.new(col_mask_r_mix_n.inputs['Color2'], paint_r_col_n.outputs['Color']) # make links - level 3 node_tree.links.new(add_refl_gn.inputs['Env Factor Color'], env_vcol_mix_n.outputs['Color']) node_tree.links.new(spec_mult_n.inputs['Color1'], spec_color_n.outputs['Color']) node_tree.links.new(spec_mult_n.inputs['Color2'], spec_vcol_mix_n.outputs['Color']) node_tree.links.new(opacity_vcol_n.inputs[0], vcol_scale_n.outputs['Color']) node_tree.links.new(opacity_vcol_n.inputs[1], opacity_n.outputs[0]) node_tree.links.new(blend_mix_n.inputs['Color1'], airbrush_mix_n.outputs['Color']) node_tree.links.new(blend_mix_n.inputs['Color2'], col_mask_r_mix_n.outputs['Color']) # make links - level 4 node_tree.links.new(paint_mult_n.inputs['Color1'], diff_mult_n.outputs['Color']) node_tree.links.new(paint_mult_n.inputs['Color2'], blend_mix_n.outputs['Color']) # make links - output node_tree.links.new(out_mat_n.inputs['Color'], paint_mult_n.outputs['Color'])
def init(node_tree): """Initialize node tree with links for this shader. :param node_tree: node tree on which this shader should be created :type node_tree: bpy.types.NodeTree """ pos_x_shift = 185 start_pos_x = 0 start_pos_y = 0 # init parent DifSpecAddEnv.init(node_tree) geom_n = node_tree.nodes[DifSpecAddEnv.GEOM_NODE] spec_col_n = node_tree.nodes[DifSpecAddEnv.SPEC_COL_NODE] base_tex_n = node_tree.nodes[DifSpecAddEnv.BASE_TEX_NODE] diff_mult_n = node_tree.nodes[DifSpecAddEnv.DIFF_MULT_NODE] out_mat_n = node_tree.nodes[DifSpecAddEnv.OUT_MAT_NODE] out_add_refl_n = node_tree.nodes[DifSpecAddEnv.OUT_ADD_REFL_NODE] output_n = node_tree.nodes[DifSpecAddEnv.OUTPUT_NODE] # move existing output_n.location.x += pos_x_shift out_mat_n.location.y -= 150 # remove existing node_tree.nodes.remove(node_tree.nodes[DifSpecAddEnv.SPEC_MULT_NODE]) node_tree.nodes.remove(node_tree.nodes[DifSpecAddEnv.VCOL_GROUP_NODE]) node_tree.nodes.remove(node_tree.nodes[DifSpecAddEnv.VCOLOR_SCALE_NODE]) node_tree.nodes.remove(node_tree.nodes[DifSpecAddEnv.VCOLOR_MULT_NODE]) node_tree.nodes.remove(node_tree.nodes[DifSpecAddEnv.OPACITY_NODE]) for link in node_tree.links: if link.from_node == diff_mult_n and link.to_node == out_mat_n: node_tree.links.remove(link) break # create nodes uv_recalc_gn = node_tree.nodes.new("ShaderNodeGroup") uv_recalc_gn.name = window_uv_offset.WINDOW_UV_OFFSET_G uv_recalc_gn.label = window_uv_offset.WINDOW_UV_OFFSET_G uv_recalc_gn.location = (start_pos_x, start_pos_y + 1500) uv_recalc_gn.node_tree = window_uv_offset.get_node_group() sec_geom_n = node_tree.nodes.new("ShaderNodeGeometry") sec_geom_n.name = sec_geom_n.label = WindowNight.SEC_GEOM_NODE sec_geom_n.location = (start_pos_x - pos_x_shift, start_pos_y + 1200) sec_geom_n.uv_layer = _MESH_consts.none_uv lightmap_tex_n = node_tree.nodes.new("ShaderNodeTexture") lightmap_tex_n.name = lightmap_tex_n.label = WindowNight.LIGHTMAP_TEX_NODE lightmap_tex_n.location = (start_pos_x + pos_x_shift, start_pos_y + 1200) base_lightmap_mult_n = node_tree.nodes.new("ShaderNodeMixRGB") base_lightmap_mult_n.name = base_lightmap_mult_n.label = WindowNight.BASE_LIGHTMAP_MULT_NODE base_lightmap_mult_n.location = (start_pos_x + pos_x_shift * 3, start_pos_y + 1300) base_lightmap_mult_n.blend_type = "MULTIPLY" base_lightmap_mult_n.inputs["Fac"].default_value = 1.0 base_alpha_mult_n = node_tree.nodes.new("ShaderNodeMixRGB") base_alpha_mult_n.name = base_alpha_mult_n.label = WindowNight.BASE_ALPHA_MULT_NODE base_alpha_mult_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 1500) base_alpha_mult_n.blend_type = "MULTIPLY" base_alpha_mult_n.inputs["Fac"].default_value = 1.0 out_add_spec_n = node_tree.nodes.new("ShaderNodeMixRGB") out_add_spec_n.name = out_add_spec_n.label = WindowNight.BASE_ALPHA_MULT_NODE out_add_spec_n.location = (start_pos_x + pos_x_shift * 9, start_pos_y + 1900) out_add_spec_n.blend_type = "ADD" out_add_spec_n.inputs["Fac"].default_value = 1.0 # create links node_tree.links.new(uv_recalc_gn.inputs["UV"], geom_n.outputs["UV"]) node_tree.links.new(uv_recalc_gn.inputs["Normal"], geom_n.outputs["Normal"]) node_tree.links.new(base_tex_n.inputs["Vector"], uv_recalc_gn.outputs["UV Final"]) node_tree.links.new(lightmap_tex_n.inputs["Vector"], sec_geom_n.outputs["UV"]) # pass 1 node_tree.links.new(base_lightmap_mult_n.inputs["Color1"], base_tex_n.outputs["Color"]) node_tree.links.new(base_lightmap_mult_n.inputs["Color2"], lightmap_tex_n.outputs["Color"]) # pass 2 node_tree.links.new(base_alpha_mult_n.inputs["Color1"], base_tex_n.outputs["Value"]) node_tree.links.new(base_alpha_mult_n.inputs["Color2"], base_lightmap_mult_n.outputs["Color"]) # pass 3 node_tree.links.new(diff_mult_n.inputs["Color2"], base_alpha_mult_n.outputs["Color"]) # output material node_tree.links.new(out_mat_n.inputs["Spec"], spec_col_n.outputs["Color"]) # post pass 1 node_tree.links.new(out_add_refl_n.inputs["Color2"], diff_mult_n.outputs["Color"]) # post pass 2 node_tree.links.new(out_add_spec_n.inputs["Color1"], out_add_refl_n.outputs["Color"]) node_tree.links.new(out_add_spec_n.inputs["Color2"], out_mat_n.outputs["Spec"]) # output pass node_tree.links.new(output_n.inputs["Color"], out_add_spec_n.outputs["Color"])
def init(node_tree): """Initialize node tree with links for this shader. :param node_tree: node tree on which this shader should be created :type node_tree: bpy.types.NodeTree """ start_pos_x = 0 start_pos_y = 0 pos_x_shift = 185 # init parent DifSpecAddEnv.init(node_tree) base_tex_n = node_tree.nodes[DifSpecAddEnv.BASE_TEX_NODE] env_color_n = node_tree.nodes[DifSpecAddEnv.ENV_COLOR_NODE] spec_color_n = node_tree.nodes[DifSpecAddEnv.SPEC_COL_NODE] diff_mult_n = node_tree.nodes[DifSpecAddEnv.DIFF_MULT_NODE] add_refl_gn = node_tree.nodes[DifSpecAddEnv.ADD_ENV_GROUP_NODE] spec_mult_n = node_tree.nodes[DifSpecAddEnv.SPEC_MULT_NODE] vcol_scale_n = node_tree.nodes[DifSpecAddEnv.VCOLOR_SCALE_NODE] opacity_n = node_tree.nodes[DifSpecAddEnv.OPACITY_NODE] out_mat_n = node_tree.nodes[DifSpecAddEnv.OUT_MAT_NODE] out_add_refl_n = node_tree.nodes[DifSpecAddEnv.OUT_ADD_REFL_NODE] output_n = node_tree.nodes[DifSpecAddEnv.OUTPUT_NODE] # move existing add_refl_gn.location.x += pos_x_shift * 3 spec_mult_n.location.x += pos_x_shift * 3 out_mat_n.location.x += pos_x_shift * 2 out_add_refl_n.location.x += pos_x_shift * 2 output_n.location.x += pos_x_shift * 2 # set fresnel factor to 0 node_tree.nodes[DifSpecAddEnv.ADD_ENV_GROUP_NODE].inputs['Apply Fresnel'].default_value = 0.0 # node creation - level 3 env_vcol_mix_n = node_tree.nodes.new("ShaderNodeMixRGB") env_vcol_mix_n.name = Truckpaint.ENV_VCOL_MULT_NODE env_vcol_mix_n.label = Truckpaint.ENV_VCOL_MULT_NODE env_vcol_mix_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 2000) env_vcol_mix_n.blend_type = "MULTIPLY" env_vcol_mix_n.inputs['Fac'].default_value = 1 spec_vcol_mix_n = node_tree.nodes.new("ShaderNodeMixRGB") spec_vcol_mix_n.name = Truckpaint.SPEC_VCOL_MULT_NODE spec_vcol_mix_n.label = Truckpaint.SPEC_VCOL_MULT_NODE spec_vcol_mix_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 1750) spec_vcol_mix_n.blend_type = "MULTIPLY" spec_vcol_mix_n.inputs['Fac'].default_value = 1 opacity_vcol_n = node_tree.nodes.new("ShaderNodeMath") opacity_vcol_n.name = Truckpaint.OPACITY_VCOL_MULT_NODE opacity_vcol_n.label = Truckpaint.OPACITY_VCOL_MULT_NODE opacity_vcol_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 1300) opacity_vcol_n.operation = "MULTIPLY" # node creation - level 5 base_paint_mult_n = node_tree.nodes.new("ShaderNodeMixRGB") base_paint_mult_n.name = Truckpaint.BASE_PAINT_MULT_NODE base_paint_mult_n.label = Truckpaint.BASE_PAINT_MULT_NODE base_paint_mult_n.location = (start_pos_x + pos_x_shift * 6, start_pos_y + 1500) base_paint_mult_n.blend_type = "MULTIPLY" base_paint_mult_n.inputs['Fac'].default_value = 1 base_paint_mult_n.inputs['Color2'].default_value = _convert_utils.to_node_color(_get_scs_globals().base_paint_color) # node creation - level 6 paint_mult_n = node_tree.nodes.new("ShaderNodeMixRGB") paint_mult_n.name = Truckpaint.PAINT_MULT_NODE paint_mult_n.label = Truckpaint.PAINT_MULT_NODE paint_mult_n.location = (start_pos_x + pos_x_shift * 7, start_pos_y + 1400) paint_mult_n.blend_type = "MULTIPLY" paint_mult_n.inputs['Fac'].default_value = 0 # make links - level 2 node_tree.links.new(env_vcol_mix_n.inputs['Color1'], env_color_n.outputs['Color']) node_tree.links.new(env_vcol_mix_n.inputs['Color2'], vcol_scale_n.outputs['Color']) node_tree.links.new(spec_vcol_mix_n.inputs['Color1'], base_tex_n.outputs['Value']) node_tree.links.new(spec_vcol_mix_n.inputs['Color2'], vcol_scale_n.outputs['Color']) # make links - level 3 node_tree.links.new(add_refl_gn.inputs['Env Factor Color'], env_vcol_mix_n.outputs['Color']) node_tree.links.new(spec_mult_n.inputs['Color1'], spec_color_n.outputs['Color']) node_tree.links.new(spec_mult_n.inputs['Color2'], spec_vcol_mix_n.outputs['Color']) node_tree.links.new(opacity_vcol_n.inputs[0], vcol_scale_n.outputs['Color']) node_tree.links.new(opacity_vcol_n.inputs[1], opacity_n.outputs[0]) # make links - level 4 node_tree.links.new(base_paint_mult_n.inputs['Color1'], diff_mult_n.outputs['Color']) # make links - level 5 node_tree.links.new(paint_mult_n.inputs['Color1'], base_paint_mult_n.outputs['Color']) # make links - output node_tree.links.new(out_mat_n.inputs['Color'], paint_mult_n.outputs['Color'])
def init(node_tree): """Initialize node tree with links for this shader. :param node_tree: node tree on which this shader should be created :type node_tree: bpy.types.NodeTree """ start_pos_x = 0 start_pos_y = 0 pos_x_shift = 185 # init parent DifSpecAddEnv.init(node_tree) diff_mult_n = node_tree.nodes[DifSpecAddEnv.DIFF_MULT_NODE] out_mat_n = node_tree.nodes[DifSpecAddEnv.OUT_MAT_NODE] out_add_refl_n = node_tree.nodes[DifSpecAddEnv.OUT_ADD_REFL_NODE] output_n = node_tree.nodes[DifSpecAddEnv.OUTPUT_NODE] # move existing out_mat_n.location.x += pos_x_shift out_add_refl_n.location.x += pos_x_shift output_n.location.x += pos_x_shift # set fresnel factor to 0 node_tree.nodes[DifSpecAddEnv.ADD_ENV_GROUP_NODE].inputs['Apply Fresnel'].default_value = 0.0 # node creation - level 0 paint_geom_n = node_tree.nodes.new("ShaderNodeGeometry") paint_geom_n.name = Truckpaint.PAINT_GEOM_NODE paint_geom_n.label = Truckpaint.PAINT_GEOM_NODE paint_geom_n.location = (start_pos_x - pos_x_shift, start_pos_y + 950) # node creation - level 1 paint_base_col_n = node_tree.nodes.new("ShaderNodeRGB") paint_base_col_n.name = Truckpaint.PAINT_BASE_COL_NODE paint_base_col_n.label = Truckpaint.PAINT_BASE_COL_NODE paint_base_col_n.location = (start_pos_x + pos_x_shift, start_pos_y + 1150) paint_tex_n = node_tree.nodes.new("ShaderNodeTexture") paint_tex_n.name = Truckpaint.PAINT_TEX_NODE paint_tex_n.label = Truckpaint.PAINT_TEX_NODE paint_tex_n.location = (start_pos_x + pos_x_shift, start_pos_y + 950) paint_b_col_n = node_tree.nodes.new("ShaderNodeRGB") paint_b_col_n.name = Truckpaint.PAINT_B_COL_NODE paint_b_col_n.label = Truckpaint.PAINT_B_COL_NODE paint_b_col_n.location = (start_pos_x + pos_x_shift, start_pos_y + 650) paint_g_col_n = node_tree.nodes.new("ShaderNodeRGB") paint_g_col_n.name = Truckpaint.PAINT_G_COL_NODE paint_g_col_n.label = Truckpaint.PAINT_G_COL_NODE paint_g_col_n.location = (start_pos_x + pos_x_shift, start_pos_y + 450) paint_r_col_n = node_tree.nodes.new("ShaderNodeRGB") paint_r_col_n.name = Truckpaint.PAINT_R_COL_NODE paint_r_col_n.label = Truckpaint.PAINT_R_COL_NODE paint_r_col_n.location = (start_pos_x + pos_x_shift, start_pos_y + 250) # node creation - level 2 paint_tex_sep = node_tree.nodes.new("ShaderNodeSeparateRGB") paint_tex_sep.name = Truckpaint.PAINT_TEX_SEP_NODE paint_tex_sep.label = Truckpaint.PAINT_TEX_SEP_NODE paint_tex_sep.location = (start_pos_x + pos_x_shift * 3, start_pos_y + 850) # node creation - level 3 airbrush_mix_n = node_tree.nodes.new("ShaderNodeMixRGB") airbrush_mix_n.name = Truckpaint.AIRBRUSH_MIX_NODE airbrush_mix_n.label = Truckpaint.AIRBRUSH_MIX_NODE airbrush_mix_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 1200) airbrush_mix_n.blend_type = "MIX" col_mask_b_mix_n = node_tree.nodes.new("ShaderNodeMixRGB") col_mask_b_mix_n.name = Truckpaint.COL_MASK_B_MIX_NODE col_mask_b_mix_n.label = Truckpaint.COL_MASK_B_MIX_NODE col_mask_b_mix_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 800) col_mask_b_mix_n.blend_type = "MIX" col_mask_g_mix_n = node_tree.nodes.new("ShaderNodeMixRGB") col_mask_g_mix_n.name = Truckpaint.COL_MASK_G_MIX_NODE col_mask_g_mix_n.label = Truckpaint.COL_MASK_G_MIX_NODE col_mask_g_mix_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 600) col_mask_g_mix_n.blend_type = "MIX" col_mask_r_mix_n = node_tree.nodes.new("ShaderNodeMixRGB") col_mask_r_mix_n.name = Truckpaint.COL_MASK_R_MIX_NODE col_mask_r_mix_n.label = Truckpaint.COL_MASK_R_MIX_NODE col_mask_r_mix_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 400) col_mask_r_mix_n.blend_type = "MIX" # node creation - level 4 blend_mix_n = node_tree.nodes.new("ShaderNodeMixRGB") blend_mix_n.name = Truckpaint.BLEND_MIX_NODE blend_mix_n.label = Truckpaint.BLEND_MIX_NODE blend_mix_n.location = (start_pos_x + pos_x_shift * 5, start_pos_y + 1000) blend_mix_n.inputs['Fac'].default_value = 1.0 blend_mix_n.blend_type = "MIX" # node creation - level 5 paint_mult_n = node_tree.nodes.new("ShaderNodeMixRGB") paint_mult_n.name = Truckpaint.PAINT_MULT_NODE paint_mult_n.label = Truckpaint.PAINT_MULT_NODE paint_mult_n.location = (start_pos_x + pos_x_shift * 6, start_pos_y + 1400) paint_mult_n.blend_type = "MULTIPLY" paint_mult_n.inputs['Fac'].default_value = 1 # make links - level 0 node_tree.links.new(paint_tex_n.inputs['Vector'], paint_geom_n.outputs['UV']) # make links - level 1 node_tree.links.new(paint_tex_sep.inputs['Image'], paint_tex_n.outputs['Color']) # make links - level 2 node_tree.links.new(airbrush_mix_n.inputs['Fac'], paint_tex_n.outputs['Value']) node_tree.links.new(airbrush_mix_n.inputs['Color1'], paint_base_col_n.outputs['Color']) node_tree.links.new(airbrush_mix_n.inputs['Color2'], paint_tex_n.outputs['Color']) node_tree.links.new(col_mask_b_mix_n.inputs['Fac'], paint_tex_sep.outputs['B']) node_tree.links.new(col_mask_b_mix_n.inputs['Color1'], paint_base_col_n.outputs['Color']) node_tree.links.new(col_mask_b_mix_n.inputs['Color2'], paint_b_col_n.outputs['Color']) node_tree.links.new(col_mask_g_mix_n.inputs['Fac'], paint_tex_sep.outputs['G']) node_tree.links.new(col_mask_g_mix_n.inputs['Color1'], col_mask_b_mix_n.outputs['Color']) node_tree.links.new(col_mask_g_mix_n.inputs['Color2'], paint_g_col_n.outputs['Color']) node_tree.links.new(col_mask_r_mix_n.inputs['Fac'], paint_tex_sep.outputs['R']) node_tree.links.new(col_mask_r_mix_n.inputs['Color1'], col_mask_g_mix_n.outputs['Color']) node_tree.links.new(col_mask_r_mix_n.inputs['Color2'], paint_r_col_n.outputs['Color']) # make links - level 3 node_tree.links.new(blend_mix_n.inputs['Color1'], airbrush_mix_n.outputs['Color']) node_tree.links.new(blend_mix_n.inputs['Color2'], col_mask_r_mix_n.outputs['Color']) # make links - level 4 node_tree.links.new(paint_mult_n.inputs['Color1'], diff_mult_n.outputs['Color']) node_tree.links.new(paint_mult_n.inputs['Color2'], blend_mix_n.outputs['Color']) # make links - output node_tree.links.new(out_mat_n.inputs['Color'], paint_mult_n.outputs['Color'])
def init(node_tree): """Initialize node tree with links for this shader. :param node_tree: node tree on which this shader should be created :type node_tree: bpy.types.NodeTree """ start_pos_x = 0 start_pos_y = 0 pos_x_shift = 185 # init parent DifSpecAddEnv.init(node_tree) base_tex_n = node_tree.nodes[DifSpecAddEnv.BASE_TEX_NODE] env_color_n = node_tree.nodes[DifSpecAddEnv.ENV_COLOR_NODE] spec_color_n = node_tree.nodes[DifSpecAddEnv.SPEC_COL_NODE] diff_mult_n = node_tree.nodes[DifSpecAddEnv.DIFF_MULT_NODE] add_refl_gn = node_tree.nodes[DifSpecAddEnv.ADD_ENV_GROUP_NODE] spec_mult_n = node_tree.nodes[DifSpecAddEnv.SPEC_MULT_NODE] vcol_scale_n = node_tree.nodes[DifSpecAddEnv.VCOLOR_SCALE_NODE] opacity_n = node_tree.nodes[DifSpecAddEnv.OPACITY_NODE] out_mat_n = node_tree.nodes[DifSpecAddEnv.OUT_MAT_NODE] out_add_refl_n = node_tree.nodes[DifSpecAddEnv.OUT_ADD_REFL_NODE] output_n = node_tree.nodes[DifSpecAddEnv.OUTPUT_NODE] # move existing add_refl_gn.location.x += pos_x_shift * 2 spec_mult_n.location.x += pos_x_shift * 2 out_mat_n.location.x += pos_x_shift out_add_refl_n.location.x += pos_x_shift output_n.location.x += pos_x_shift # set fresnel factor to 0 node_tree.nodes[DifSpecAddEnv.ADD_ENV_GROUP_NODE].inputs[ 'Apply Fresnel'].default_value = 0.0 # node creation - level 0 paint_geom_n = node_tree.nodes.new("ShaderNodeGeometry") paint_geom_n.name = Truckpaint.PAINT_GEOM_NODE paint_geom_n.label = Truckpaint.PAINT_GEOM_NODE paint_geom_n.location = (start_pos_x - pos_x_shift, start_pos_y + 950) paint_geom_n.uv_layer = _MESH_consts.none_uv # node creation - level 1 paint_base_col_n = node_tree.nodes.new("ShaderNodeRGB") paint_base_col_n.name = Truckpaint.PAINT_BASE_COL_NODE paint_base_col_n.label = Truckpaint.PAINT_BASE_COL_NODE paint_base_col_n.location = (start_pos_x + pos_x_shift, start_pos_y + 950) paint_tex_n = node_tree.nodes.new("ShaderNodeTexture") paint_tex_n.name = Truckpaint.PAINT_TEX_NODE paint_tex_n.label = Truckpaint.PAINT_TEX_NODE paint_tex_n.location = (start_pos_x + pos_x_shift, start_pos_y + 750) paint_b_col_n = node_tree.nodes.new("ShaderNodeRGB") paint_b_col_n.name = Truckpaint.PAINT_B_COL_NODE paint_b_col_n.label = Truckpaint.PAINT_B_COL_NODE paint_b_col_n.location = (start_pos_x + pos_x_shift, start_pos_y + 450) paint_g_col_n = node_tree.nodes.new("ShaderNodeRGB") paint_g_col_n.name = Truckpaint.PAINT_G_COL_NODE paint_g_col_n.label = Truckpaint.PAINT_G_COL_NODE paint_g_col_n.location = (start_pos_x + pos_x_shift, start_pos_y + 250) paint_r_col_n = node_tree.nodes.new("ShaderNodeRGB") paint_r_col_n.name = Truckpaint.PAINT_R_COL_NODE paint_r_col_n.label = Truckpaint.PAINT_R_COL_NODE paint_r_col_n.location = (start_pos_x + pos_x_shift, start_pos_y + 50) # node creation - level 2 paint_tex_sep = node_tree.nodes.new("ShaderNodeSeparateRGB") paint_tex_sep.name = Truckpaint.PAINT_TEX_SEP_NODE paint_tex_sep.label = Truckpaint.PAINT_TEX_SEP_NODE paint_tex_sep.location = (start_pos_x + pos_x_shift * 3, start_pos_y + 650) # node creation - level 3 env_vcol_mix_n = node_tree.nodes.new("ShaderNodeMixRGB") env_vcol_mix_n.name = Truckpaint.ENV_VCOL_MULT_NODE env_vcol_mix_n.label = Truckpaint.ENV_VCOL_MULT_NODE env_vcol_mix_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 2000) env_vcol_mix_n.blend_type = "MULTIPLY" env_vcol_mix_n.inputs['Fac'].default_value = 1 spec_vcol_mix_n = node_tree.nodes.new("ShaderNodeMixRGB") spec_vcol_mix_n.name = Truckpaint.SPEC_VCOL_MULT_NODE spec_vcol_mix_n.label = Truckpaint.SPEC_VCOL_MULT_NODE spec_vcol_mix_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 1750) spec_vcol_mix_n.blend_type = "MULTIPLY" spec_vcol_mix_n.inputs['Fac'].default_value = 1 opacity_vcol_n = node_tree.nodes.new("ShaderNodeMath") opacity_vcol_n.name = Truckpaint.OPACITY_VCOL_MULT_NODE opacity_vcol_n.label = Truckpaint.OPACITY_VCOL_MULT_NODE opacity_vcol_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 1300) opacity_vcol_n.operation = "MULTIPLY" airbrush_mix_n = node_tree.nodes.new("ShaderNodeMixRGB") airbrush_mix_n.name = Truckpaint.AIRBRUSH_MIX_NODE airbrush_mix_n.label = Truckpaint.AIRBRUSH_MIX_NODE airbrush_mix_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 1000) airbrush_mix_n.blend_type = "MIX" col_mask_b_mix_n = node_tree.nodes.new("ShaderNodeMixRGB") col_mask_b_mix_n.name = Truckpaint.COL_MASK_B_MIX_NODE col_mask_b_mix_n.label = Truckpaint.COL_MASK_B_MIX_NODE col_mask_b_mix_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 600) col_mask_b_mix_n.blend_type = "MIX" col_mask_g_mix_n = node_tree.nodes.new("ShaderNodeMixRGB") col_mask_g_mix_n.name = Truckpaint.COL_MASK_G_MIX_NODE col_mask_g_mix_n.label = Truckpaint.COL_MASK_G_MIX_NODE col_mask_g_mix_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 400) col_mask_g_mix_n.blend_type = "MIX" col_mask_r_mix_n = node_tree.nodes.new("ShaderNodeMixRGB") col_mask_r_mix_n.name = Truckpaint.COL_MASK_R_MIX_NODE col_mask_r_mix_n.label = Truckpaint.COL_MASK_R_MIX_NODE col_mask_r_mix_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 200) col_mask_r_mix_n.blend_type = "MIX" # node creation - level 4 blend_mix_n = node_tree.nodes.new("ShaderNodeMixRGB") blend_mix_n.name = Truckpaint.BLEND_MIX_NODE blend_mix_n.label = Truckpaint.BLEND_MIX_NODE blend_mix_n.location = (start_pos_x + pos_x_shift * 5, start_pos_y + 800) blend_mix_n.inputs['Fac'].default_value = 1.0 blend_mix_n.blend_type = "MIX" # node creation - level 5 paint_mult_n = node_tree.nodes.new("ShaderNodeMixRGB") paint_mult_n.name = Truckpaint.PAINT_MULT_NODE paint_mult_n.label = Truckpaint.PAINT_MULT_NODE paint_mult_n.location = (start_pos_x + pos_x_shift * 6, start_pos_y + 1400) paint_mult_n.blend_type = "MULTIPLY" paint_mult_n.inputs['Fac'].default_value = 0 # make links - level 0 node_tree.links.new(paint_tex_n.inputs['Vector'], paint_geom_n.outputs['UV']) # make links - level 1 node_tree.links.new(paint_tex_sep.inputs['Image'], paint_tex_n.outputs['Color']) # make links - level 2 node_tree.links.new(env_vcol_mix_n.inputs['Color1'], env_color_n.outputs['Color']) node_tree.links.new(env_vcol_mix_n.inputs['Color2'], vcol_scale_n.outputs['Color']) node_tree.links.new(spec_vcol_mix_n.inputs['Color1'], base_tex_n.outputs['Value']) node_tree.links.new(spec_vcol_mix_n.inputs['Color2'], vcol_scale_n.outputs['Color']) node_tree.links.new(airbrush_mix_n.inputs['Fac'], paint_tex_n.outputs['Value']) node_tree.links.new(airbrush_mix_n.inputs['Color1'], paint_base_col_n.outputs['Color']) node_tree.links.new(airbrush_mix_n.inputs['Color2'], paint_tex_n.outputs['Color']) node_tree.links.new(col_mask_b_mix_n.inputs['Fac'], paint_tex_sep.outputs['B']) node_tree.links.new(col_mask_b_mix_n.inputs['Color1'], paint_base_col_n.outputs['Color']) node_tree.links.new(col_mask_b_mix_n.inputs['Color2'], paint_b_col_n.outputs['Color']) node_tree.links.new(col_mask_g_mix_n.inputs['Fac'], paint_tex_sep.outputs['G']) node_tree.links.new(col_mask_g_mix_n.inputs['Color1'], col_mask_b_mix_n.outputs['Color']) node_tree.links.new(col_mask_g_mix_n.inputs['Color2'], paint_g_col_n.outputs['Color']) node_tree.links.new(col_mask_r_mix_n.inputs['Fac'], paint_tex_sep.outputs['R']) node_tree.links.new(col_mask_r_mix_n.inputs['Color1'], col_mask_g_mix_n.outputs['Color']) node_tree.links.new(col_mask_r_mix_n.inputs['Color2'], paint_r_col_n.outputs['Color']) # make links - level 3 node_tree.links.new(add_refl_gn.inputs['Env Factor Color'], env_vcol_mix_n.outputs['Color']) node_tree.links.new(spec_mult_n.inputs['Color1'], spec_color_n.outputs['Color']) node_tree.links.new(spec_mult_n.inputs['Color2'], spec_vcol_mix_n.outputs['Color']) node_tree.links.new(opacity_vcol_n.inputs[0], vcol_scale_n.outputs['Color']) node_tree.links.new(opacity_vcol_n.inputs[1], opacity_n.outputs[0]) node_tree.links.new(blend_mix_n.inputs['Color1'], airbrush_mix_n.outputs['Color']) node_tree.links.new(blend_mix_n.inputs['Color2'], col_mask_r_mix_n.outputs['Color']) # make links - level 4 node_tree.links.new(paint_mult_n.inputs['Color1'], diff_mult_n.outputs['Color']) node_tree.links.new(paint_mult_n.inputs['Color2'], blend_mix_n.outputs['Color']) # make links - output node_tree.links.new(out_mat_n.inputs['Color'], paint_mult_n.outputs['Color'])
def init(node_tree): """Initialize node tree with links for this shader. :param node_tree: node tree on which this shader should be created :type node_tree: bpy.types.NodeTree """ pos_x_shift = 185 start_pos_x = 0 start_pos_y = 0 # init parent DifSpecAddEnv.init(node_tree) uv_map_n = node_tree.nodes[DifSpecAddEnv.UVMAP_NODE] geom_n = node_tree.nodes[DifSpecAddEnv.GEOM_NODE] spec_col_n = node_tree.nodes[DifSpecAddEnv.SPEC_COL_NODE] base_tex_n = node_tree.nodes[DifSpecAddEnv.BASE_TEX_NODE] diff_mult_n = node_tree.nodes[DifSpecAddEnv.DIFF_MULT_NODE] compose_lighting_n = node_tree.nodes[ DifSpecAddEnv.COMPOSE_LIGHTING_NODE] # remove existing node_tree.nodes.remove(node_tree.nodes[DifSpecAddEnv.SPEC_MULT_NODE]) node_tree.nodes.remove(node_tree.nodes[DifSpecAddEnv.VCOL_GROUP_NODE]) node_tree.nodes.remove( node_tree.nodes[DifSpecAddEnv.VCOLOR_SCALE_NODE]) node_tree.nodes.remove(node_tree.nodes[DifSpecAddEnv.VCOLOR_MULT_NODE]) node_tree.nodes.remove(node_tree.nodes[DifSpecAddEnv.OPACITY_NODE]) # create nodes uv_recalc_n = node_tree.nodes.new("ShaderNodeGroup") uv_recalc_n.name = window_uv_offset_ng.WINDOW_UV_OFFSET_G uv_recalc_n.label = window_uv_offset_ng.WINDOW_UV_OFFSET_G uv_recalc_n.location = (start_pos_x, start_pos_y + 1500) uv_recalc_n.node_tree = window_uv_offset_ng.get_node_group() sec_uv_map_n = node_tree.nodes.new("ShaderNodeUVMap") sec_uv_map_n.name = sec_uv_map_n.label = WindowNight.SEC_UV_MAP sec_uv_map_n.location = (start_pos_x - pos_x_shift, start_pos_y + 1000) sec_uv_map_n.uv_map = _MESH_consts.none_uv lightmap_tex_n = node_tree.nodes.new("ShaderNodeTexImage") lightmap_tex_n.name = lightmap_tex_n.label = WindowNight.LIGHTMAP_TEX_NODE lightmap_tex_n.location = (start_pos_x + pos_x_shift, start_pos_y + 1200) lightmap_tex_n.width = 140 base_lightmap_mult_n = node_tree.nodes.new("ShaderNodeVectorMath") base_lightmap_mult_n.name = base_lightmap_mult_n.label = WindowNight.BASE_LIGHTMAP_MULT_NODE base_lightmap_mult_n.location = (start_pos_x + pos_x_shift * 3, start_pos_y + 1300) base_lightmap_mult_n.operation = "MULTIPLY" base_alpha_mult_n = node_tree.nodes.new("ShaderNodeVectorMath") base_alpha_mult_n.name = base_alpha_mult_n.label = WindowNight.BASE_ALPHA_MULT_NODE base_alpha_mult_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 1500) base_alpha_mult_n.operation = "MULTIPLY" # create links node_tree.links.new(uv_recalc_n.inputs['UV'], uv_map_n.outputs['UV']) node_tree.links.new(uv_recalc_n.inputs['Normal'], geom_n.outputs['Normal']) node_tree.links.new(uv_recalc_n.inputs['Incoming'], geom_n.outputs['Incoming']) node_tree.links.new(base_tex_n.inputs['Vector'], uv_recalc_n.outputs['UV Final']) node_tree.links.new(lightmap_tex_n.inputs['Vector'], sec_uv_map_n.outputs['UV']) # pass 1 node_tree.links.new(base_lightmap_mult_n.inputs[0], base_tex_n.outputs['Color']) node_tree.links.new(base_lightmap_mult_n.inputs[1], lightmap_tex_n.outputs['Color']) # pass 2 node_tree.links.new(base_alpha_mult_n.inputs[0], base_tex_n.outputs['Alpha']) node_tree.links.new(base_alpha_mult_n.inputs[1], base_lightmap_mult_n.outputs[0]) # pass 3 node_tree.links.new(diff_mult_n.inputs[1], base_alpha_mult_n.outputs[0]) # pass 4 node_tree.links.new(compose_lighting_n.inputs['Specular Color'], spec_col_n.outputs['Color'])