Ejemplo n.º 1
0
    def set_base_uv(node_tree, uv_layer):
        """Set UV layer to base texture in shader.

        :param node_tree: node tree of current shader
        :type node_tree: bpy.types.NodeTree
        :param uv_layer: uv layer string used for first base and mult texture
        :type uv_layer: str
        """

        DifSpecWeightMult2.set_mult_uv(node_tree, uv_layer)
Ejemplo n.º 2
0
    def set_base_uv(node_tree, uv_layer):
        """Set UV layer to base texture in shader.

        :param node_tree: node tree of current shader
        :type node_tree: bpy.types.NodeTree
        :param uv_layer: uv layer string used for first base and mult texture
        :type uv_layer: str
        """

        DifSpecWeightMult2.set_mult_uv(node_tree, uv_layer)
Ejemplo n.º 3
0
    def set_aux5(node_tree, aux_property):
        """Set UV scaling factors for the shader.

        :param node_tree: node tree of current shader
        :type node_tree: bpy.types.NodeTree
        :param aux_property: UV scale factor represented with property group
        :type aux_property: bpy.types.IDPropertyGroup
        """

        DifSpecWeightMult2.set_aux5(node_tree, aux_property)

        node_tree.nodes[DifSpecWeightMult2Weight2.SEC_UV_SCALE_NODE].scale[0] = aux_property[2]["value"]
        node_tree.nodes[DifSpecWeightMult2Weight2.SEC_UV_SCALE_NODE].scale[1] = aux_property[3]["value"]
Ejemplo n.º 4
0
    def set_aux5(node_tree, aux_property):
        """Set UV scaling factors for the shader.

        :param node_tree: node tree of current shader
        :type node_tree: bpy.types.NodeTree
        :param aux_property: UV scale factor represented with property group
        :type aux_property: bpy.types.IDPropertyGroup
        """

        DifSpecWeightMult2.set_aux5(node_tree, aux_property)

        node_tree.nodes[DifSpecWeightMult2Weight2.SEC_UV_SCALE_NODE].inputs['Scale'].default_value[0] = aux_property[2]["value"]
        node_tree.nodes[DifSpecWeightMult2Weight2.SEC_UV_SCALE_NODE].inputs['Scale'].default_value[1] = aux_property[3]["value"]
Ejemplo n.º 5
0
    def init(node_tree):
        """Initialize node tree with links for this shader.

        NOTE: shininess is not set properly as we can't set shininess on material
        via node system. So currently only primary shininess is taken into account,
        but should be: lerp(shininnes, aux3[3], v_color_alpha)

        :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
        DifSpecWeightMult2.init(node_tree)

        base_tex_n = node_tree.nodes[DifSpecWeightMult2.BASE_TEX_NODE]
        geom_n = node_tree.nodes[DifSpecWeightMult2.GEOM_NODE]
        spec_col_n = node_tree.nodes[DifSpecWeightMult2.SPEC_COL_NODE]
        vcol_group_n = node_tree.nodes[DifSpecWeightMult2.VCOL_GROUP_NODE]
        mult2_mix_gn = node_tree.nodes[DifSpecWeightMult2.MULT2_MIX_GROUP_NODE]
        spec_mult_n = node_tree.nodes[DifSpecWeightMult2.SPEC_MULT_NODE]
        vcol_mult_n = node_tree.nodes[DifSpecWeightMult2.VCOLOR_MULT_NODE]
        opacity_mult_n = node_tree.nodes[DifSpecWeightMult2.OPACITY_NODE]

        # delete existing
        node_tree.nodes.remove(opacity_mult_n)

        # move existing
        for node in node_tree.nodes:
            if node.location.x > start_pos_x + pos_x_shift * 3:
                node.location.x += pos_x_shift

        # nodes creation
        thrd_geom_n = node_tree.nodes.new("ShaderNodeGeometry")
        thrd_geom_n.name = thrd_geom_n.label = DifSpecWeightMult2Weight2.THRD_GEOM_NODE
        thrd_geom_n.location = (start_pos_x - pos_x_shift * 3, start_pos_y + 600)
        thrd_geom_n.uv_layer = _MESH_consts.none_uv

        sec_uv_scale_n = node_tree.nodes.new("ShaderNodeMapping")
        sec_uv_scale_n.name = sec_uv_scale_n.label = DifSpecWeightMult2Weight2.SEC_UV_SCALE_NODE
        sec_uv_scale_n.location = (start_pos_x - pos_x_shift * 2, start_pos_y + 600)
        sec_uv_scale_n.vector_type = "POINT"
        sec_uv_scale_n.translation = sec_uv_scale_n.rotation = (0.0,) * 3
        sec_uv_scale_n.scale = (1.0,) * 3
        sec_uv_scale_n.use_min = sec_uv_scale_n.use_max = False

        sec_spec_col_n = node_tree.nodes.new("ShaderNodeRGB")
        sec_spec_col_n.name = sec_spec_col_n.label = DifSpecWeightMult2Weight2.SEC_SPEC_COLOR_NODE
        sec_spec_col_n.location = (start_pos_x + pos_x_shift, start_pos_y + 2100)

        base_1_tex_n = node_tree.nodes.new("ShaderNodeTexture")
        base_1_tex_n.name = base_1_tex_n.label = DifSpecWeightMult2Weight2.BASE_1_TEX_NODE
        base_1_tex_n.location = (start_pos_x + pos_x_shift, start_pos_y + 900)

        mult_1_tex_n = node_tree.nodes.new("ShaderNodeTexture")
        mult_1_tex_n.name = mult_1_tex_n.label = DifSpecWeightMult2Weight2.MULT_1_TEX_NODE
        mult_1_tex_n.location = (start_pos_x + pos_x_shift, start_pos_y + 600)

        spec_col_mix_n = node_tree.nodes.new("ShaderNodeMixRGB")
        spec_col_mix_n.name = spec_col_mix_n.label = DifSpecWeightMult2Weight2.SPEC_COLOR_MIX_NODE
        spec_col_mix_n.location = (start_pos_x + pos_x_shift * 3, start_pos_y + 2000)
        spec_col_mix_n.blend_type = "MIX"

        sec_mult2_mix_gn = node_tree.nodes.new("ShaderNodeGroup")
        sec_mult2_mix_gn.name = sec_mult2_mix_gn.label = DifSpecWeightMult2Weight2.SEC_MULT2_MIX_GROUP_NODE
        sec_mult2_mix_gn.location = (start_pos_x + pos_x_shift * 3, start_pos_y + 800)
        sec_mult2_mix_gn.node_tree = mult2_mix.get_node_group()

        combined_a_mix_n = node_tree.nodes.new("ShaderNodeMixRGB")
        combined_a_mix_n.name = combined_a_mix_n.label = DifSpecWeightMult2Weight2.COMBINED_ALPHA_MIX_NODE
        combined_a_mix_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 1200)
        combined_a_mix_n.blend_type = "MIX"

        combined_mix_n = node_tree.nodes.new("ShaderNodeMixRGB")
        combined_mix_n.name = combined_mix_n.label = DifSpecWeightMult2Weight2.COMBINED_MIX_NODE
        combined_mix_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 1000)
        combined_mix_n.blend_type = "MIX"

        # links creation
        node_tree.links.new(sec_uv_scale_n.inputs["Vector"], thrd_geom_n.outputs["UV"])
        node_tree.links.new(base_tex_n.inputs["Vector"], geom_n.outputs["UV"])

        node_tree.links.new(mult_1_tex_n.inputs["Vector"], sec_uv_scale_n.outputs["Vector"])
        node_tree.links.new(base_1_tex_n.inputs["Vector"], thrd_geom_n.outputs["UV"])

        # pass 1
        node_tree.links.new(spec_col_mix_n.inputs["Fac"], vcol_group_n.outputs["Vertex Color Alpha"])
        node_tree.links.new(spec_col_mix_n.inputs["Color1"], spec_col_n.outputs["Color"])
        node_tree.links.new(spec_col_mix_n.inputs["Color2"], sec_spec_col_n.outputs["Color"])

        node_tree.links.new(sec_mult2_mix_gn.inputs["Base Alpha"], base_1_tex_n.outputs["Value"])
        node_tree.links.new(sec_mult2_mix_gn.inputs["Base Color"], base_1_tex_n.outputs["Color"])
        node_tree.links.new(sec_mult2_mix_gn.inputs["Mult Alpha"], mult_1_tex_n.outputs["Value"])
        node_tree.links.new(sec_mult2_mix_gn.inputs["Mult Color"], mult_1_tex_n.outputs["Color"])

        # pass 2
        node_tree.links.new(combined_a_mix_n.inputs["Fac"], vcol_group_n.outputs["Vertex Color Alpha"])
        node_tree.links.new(combined_a_mix_n.inputs["Color1"], mult2_mix_gn.outputs["Mix Alpha"])
        node_tree.links.new(combined_a_mix_n.inputs["Color2"], sec_mult2_mix_gn.outputs["Mix Alpha"])

        node_tree.links.new(combined_mix_n.inputs["Fac"], vcol_group_n.outputs["Vertex Color Alpha"])
        node_tree.links.new(combined_mix_n.inputs["Color1"], mult2_mix_gn.outputs["Mix Color"])
        node_tree.links.new(combined_mix_n.inputs["Color2"], sec_mult2_mix_gn.outputs["Mix Color"])

        # pass 3
        node_tree.links.new(spec_mult_n.inputs["Color1"], spec_col_mix_n.outputs["Color"])
        node_tree.links.new(spec_mult_n.inputs["Color2"], combined_a_mix_n.outputs["Color"])

        node_tree.links.new(vcol_mult_n.inputs["Color2"], combined_mix_n.outputs["Color"])
Ejemplo n.º 6
0
    def init(node_tree):
        """Initialize node tree with links for this shader.

        NOTE: shininess is not set properly as we can't set shininess on material
        via node system. So currently only primary shininess is taken into account,
        but should be: lerp(shininnes, aux3[3], v_color_alpha)

        :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
        DifSpecWeightMult2.init(node_tree)

        first_uv_n = node_tree.nodes[DifSpecWeightMult2.UVMAP_NODE]
        base_tex_n = node_tree.nodes[DifSpecWeightMult2.BASE_TEX_NODE]
        spec_col_n = node_tree.nodes[DifSpecWeightMult2.SPEC_COL_NODE]
        vcol_group_n = node_tree.nodes[DifSpecWeightMult2.VCOL_GROUP_NODE]
        mult2_mix_gn = node_tree.nodes[DifSpecWeightMult2.MULT2_MIX_GROUP_NODE]
        spec_mult_n = node_tree.nodes[DifSpecWeightMult2.SPEC_MULT_NODE]
        vcol_mult_n = node_tree.nodes[DifSpecWeightMult2.VCOLOR_MULT_NODE]
        opacity_mult_n = node_tree.nodes[DifSpecWeightMult2.OPACITY_NODE]

        # delete existing
        node_tree.nodes.remove(opacity_mult_n)

        # move existing
        for node in node_tree.nodes:
            if node.location.x > start_pos_x + pos_x_shift * 3:
                node.location.x += pos_x_shift

        # nodes creation
        sec_uv_n = node_tree.nodes.new("ShaderNodeUVMap")
        sec_uv_n.name = sec_uv_n.label = DifSpecWeightMult2Weight2.SEC_UVMAP_NODE
        sec_uv_n.location = (start_pos_x - pos_x_shift * 3, start_pos_y + 600)
        sec_uv_n.uv_map = _MESH_consts.none_uv

        sec_uv_scale_n = node_tree.nodes.new("ShaderNodeMapping")
        sec_uv_scale_n.name = sec_uv_scale_n.label = DifSpecWeightMult2Weight2.SEC_UV_SCALE_NODE
        sec_uv_scale_n.location = (start_pos_x - pos_x_shift, start_pos_y + 600)
        sec_uv_scale_n.vector_type = "POINT"
        sec_uv_scale_n.inputs['Location'].default_value = sec_uv_scale_n.inputs['Rotation'].default_value = (0.0,) * 3
        sec_uv_scale_n.inputs['Scale'].default_value = (1.0,) * 3
        sec_uv_scale_n.width = 140

        sec_spec_col_n = node_tree.nodes.new("ShaderNodeRGB")
        sec_spec_col_n.name = sec_spec_col_n.label = DifSpecWeightMult2Weight2.SEC_SPEC_COLOR_NODE
        sec_spec_col_n.location = (start_pos_x + pos_x_shift, start_pos_y + 2100)

        base_1_tex_n = node_tree.nodes.new("ShaderNodeTexImage")
        base_1_tex_n.name = base_1_tex_n.label = DifSpecWeightMult2Weight2.BASE_1_TEX_NODE
        base_1_tex_n.location = (start_pos_x + pos_x_shift, start_pos_y + 900)
        base_1_tex_n.width = 140

        mult_1_tex_n = node_tree.nodes.new("ShaderNodeTexImage")
        mult_1_tex_n.name = mult_1_tex_n.label = DifSpecWeightMult2Weight2.MULT_1_TEX_NODE
        mult_1_tex_n.location = (start_pos_x + pos_x_shift, start_pos_y + 600)
        mult_1_tex_n.width = 140

        spec_col_mix_n = node_tree.nodes.new("ShaderNodeMixRGB")
        spec_col_mix_n.name = spec_col_mix_n.label = DifSpecWeightMult2Weight2.SPEC_COLOR_MIX_NODE
        spec_col_mix_n.location = (start_pos_x + pos_x_shift * 3, start_pos_y + 2100)
        spec_col_mix_n.blend_type = "MIX"

        sec_mult2_mix_n = node_tree.nodes.new("ShaderNodeGroup")
        sec_mult2_mix_n.name = sec_mult2_mix_n.label = DifSpecWeightMult2Weight2.SEC_MULT2_MIX_GROUP_NODE
        sec_mult2_mix_n.location = (start_pos_x + pos_x_shift * 3, start_pos_y + 800)
        sec_mult2_mix_n.node_tree = mult2_mix_ng.get_node_group()

        combined_a_mix_n = node_tree.nodes.new("ShaderNodeMixRGB")
        combined_a_mix_n.name = combined_a_mix_n.label = DifSpecWeightMult2Weight2.COMBINED_ALPHA_MIX_NODE
        combined_a_mix_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 1200)
        combined_a_mix_n.blend_type = "MIX"

        combined_mix_n = node_tree.nodes.new("ShaderNodeMixRGB")
        combined_mix_n.name = combined_mix_n.label = DifSpecWeightMult2Weight2.COMBINED_MIX_NODE
        combined_mix_n.location = (start_pos_x + pos_x_shift * 4, start_pos_y + 1000)
        combined_mix_n.blend_type = "MIX"

        # links creation
        node_tree.links.new(sec_uv_scale_n.inputs["Vector"], sec_uv_n.outputs["UV"])
        node_tree.links.new(base_tex_n.inputs["Vector"], first_uv_n.outputs["UV"])

        node_tree.links.new(mult_1_tex_n.inputs["Vector"], sec_uv_scale_n.outputs["Vector"])
        node_tree.links.new(base_1_tex_n.inputs["Vector"], sec_uv_n.outputs["UV"])

        # pass 1
        node_tree.links.new(spec_col_mix_n.inputs["Fac"], vcol_group_n.outputs["Vertex Color Alpha"])
        node_tree.links.new(spec_col_mix_n.inputs["Color1"], spec_col_n.outputs["Color"])
        node_tree.links.new(spec_col_mix_n.inputs["Color2"], sec_spec_col_n.outputs["Color"])

        node_tree.links.new(sec_mult2_mix_n.inputs["Base Alpha"], base_1_tex_n.outputs["Alpha"])
        node_tree.links.new(sec_mult2_mix_n.inputs["Base Color"], base_1_tex_n.outputs["Color"])
        node_tree.links.new(sec_mult2_mix_n.inputs["Mult Alpha"], mult_1_tex_n.outputs["Alpha"])
        node_tree.links.new(sec_mult2_mix_n.inputs["Mult Color"], mult_1_tex_n.outputs["Color"])

        # pass 2
        node_tree.links.new(combined_a_mix_n.inputs["Fac"], vcol_group_n.outputs["Vertex Color Alpha"])
        node_tree.links.new(combined_a_mix_n.inputs["Color1"], mult2_mix_gn.outputs["Mix Alpha"])
        node_tree.links.new(combined_a_mix_n.inputs["Color2"], sec_mult2_mix_n.outputs["Mix Alpha"])

        node_tree.links.new(combined_mix_n.inputs["Fac"], vcol_group_n.outputs["Vertex Color Alpha"])
        node_tree.links.new(combined_mix_n.inputs["Color1"], mult2_mix_gn.outputs["Mix Color"])
        node_tree.links.new(combined_mix_n.inputs["Color2"], sec_mult2_mix_n.outputs["Mix Color"])

        # pass 3
        node_tree.links.new(spec_mult_n.inputs[0], spec_col_mix_n.outputs["Color"])
        node_tree.links.new(spec_mult_n.inputs[1], combined_a_mix_n.outputs["Color"])

        node_tree.links.new(vcol_mult_n.inputs[1], combined_mix_n.outputs["Color"])