Exemplo n.º 1
0
    def set_nmap_flavor(node_tree, switch_on):
        """Set normal map flavor to this shader.

        :param node_tree: node tree of current shader
        :type node_tree: bpy.types.NodeTree
        :param switch_on: flag indication if normal map should be switched on or off
        :type switch_on: bool
        """

        if switch_on:

            # find minimal y position for input nodes and position flavor beneath it
            min_y = None
            for node in node_tree.nodes:
                if node.location.x <= 185 and (min_y is None
                                               or min_y > node.location.y):
                    min_y = node.location.y

            lighting_eval_n = node_tree.nodes[Dif.LIGHTING_EVAL_NODE]
            geom_n = node_tree.nodes[Dif.GEOM_NODE]
            location = (lighting_eval_n.location.x - 185, min_y - 400)

            nmap.init(node_tree, location,
                      lighting_eval_n.inputs['Normal Vector'],
                      geom_n.outputs['Normal'])
        else:
            nmap.delete(node_tree)
Exemplo n.º 2
0
    def set_nmap_flavor(node_tree, switch_on):
        """Set normal map flavor to this shader.

        :param node_tree: node tree of current shader
        :type node_tree: bpy.types.NodeTree
        :param switch_on: flag indication if normal map should be switched on or off
        :type switch_on: bool
        """

        if switch_on:
            out_node = node_tree.nodes[Dif.OUT_MAT_NODE]
            location = (out_node.location.x - 185, out_node.location.y - 400)

            nmap.init(node_tree, location, out_node.inputs['Normal'])
        else:
            nmap.delete(node_tree)
Exemplo n.º 3
0
    def set_nmap_flavor(node_tree, switch_on):
        """Set normal map flavor to this shader.

        :param node_tree: node tree of current shader
        :type node_tree: bpy.types.NodeTree
        :param switch_on: flag indication if normal map should be switched on or off
        :type switch_on: bool
        """

        if switch_on:
            out_node = node_tree.nodes[Dif.OUT_MAT_NODE]
            location = (out_node.location.x - 185, out_node.location.y - 400)

            nmap.init(node_tree, location, out_node.inputs['Normal'])
        else:
            nmap.delete(node_tree)
Exemplo n.º 4
0
def init(node_tree, location, uv_scale_from, det_nmap_strength_from, normal_to):
    """Initialize normal map nodes.

    :param node_tree: node tree on which normal map will be used
    :type node_tree: bpy.types.NodeTree
    :param location: x position in node tree
    :type location: tuple[int, int]
    :param uv_scale_from: node socket from which UV scale factor should be taken
    :type uv_scale_from: bpy.types.NodeSocket
    :param det_nmap_strength_from: node socket from which detail normal map strength should be taken
    :type det_nmap_strength_from: bpy.types.NodeSocket
    :param normal_to: node socket to which result of normal map material should be send
    :type normal_to: bpy.types.NodeSocket
    """

    if nmap.NMAP_FLAVOR_FRAME_NODE not in node_tree.nodes:
        nmap.init(node_tree, location, normal_to)
        __create_nodes__(node_tree, location, uv_scale_from, det_nmap_strength_from, normal_to)
Exemplo n.º 5
0
    def set_nmap_flavor(node_tree, switch_on):
        """Set normal map flavor to this shader.

        :param node_tree: node tree of current shader
        :type node_tree: bpy.types.NodeTree
        :param switch_on: flag indication if normal map should be switched on or off
        :type switch_on: bool
        """

        if switch_on:

            # find minimal y position for input nodes and position flavor beneath it
            min_y = None
            for node in node_tree.nodes:
                if node.location.x <= 185 and (min_y is None or min_y > node.location.y):
                    min_y = node.location.y

            out_node = node_tree.nodes[Dif.OUT_MAT_NODE]
            location = (out_node.location.x - 185, min_y - 400)

            nmap.init(node_tree, location, out_node.inputs['Normal'])
        else:
            nmap.delete(node_tree)
Exemplo n.º 6
0
    def set_nmap_flavor(node_tree, switch_on):
        """Set normal map flavor to this shader.

        :param node_tree: node tree of current shader
        :type node_tree: bpy.types.NodeTree
        :param switch_on: flag indication if normal map should be switched on or off
        :type switch_on: bool
        """

        if switch_on:

            # find minimal y position for input nodes and position flavor beneath it
            min_y = None
            for node in node_tree.nodes:
                if node.location.x <= 185 and (min_y is None
                                               or min_y > node.location.y):
                    min_y = node.location.y

            out_node = node_tree.nodes[Dif.OUT_MAT_NODE]
            location = (out_node.location.x - 185, min_y - 400)

            nmap.init(node_tree, location, out_node.inputs['Normal'])
        else:
            nmap.delete(node_tree)