Ejemplo n.º 1
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
        Dif.init(node_tree)

        geom_n = node_tree.nodes[Dif.GEOM_NODE]
        lighting_eval_n = node_tree.nodes[Dif.LIGHTING_EVAL_NODE]

        # nodes creation
        normal_trans_n = node_tree.nodes.new("ShaderNodeVectorTransform")
        normal_trans_n.name = normal_trans_n.label = Grass.NORMAL_TRANS_NODE
        normal_trans_n.location = (geom_n.location.x, geom_n.location.y - 250)
        normal_trans_n.vector_type = "NORMAL"
        normal_trans_n.convert_from = "OBJECT"
        normal_trans_n.convert_to = "WORLD"
        normal_trans_n.inputs['Vector'].default_value = (
            0, 0, 1)  # up normal in object space

        # links creation
        node_tree.links.new(lighting_eval_n.inputs['Normal Vector'],
                            normal_trans_n.outputs['Vector'])

        # enable hardcoded flavour
        Dif.set_alpha_test_flavor(node_tree, True)
Ejemplo n.º 2
0
    def set_blend_add_flavor(node_tree, switch_on):
        """Set blend add flavor to this shader.

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

        # remove alpha test flavor if it was set already. Because these two can not coexist
        if alpha_test.is_set(node_tree):
            Dif.set_alpha_test_flavor(node_tree, False)

        out_node = node_tree.nodes[Dif.OUT_MAT_NODE]
        in_node = node_tree.nodes[Dif.OPACITY_NODE]

        if switch_on:
            blend_add.init(node_tree, in_node.outputs['Color'], out_node.inputs['Alpha'])
        else:
            blend_add.delete(node_tree)
Ejemplo n.º 3
0
    def set_blend_add_flavor(node_tree, switch_on):
        """Set blend add flavor to this shader.

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

        # remove alpha test flavor if it was set already. Because these two can not coexist
        if alpha_test.is_set(node_tree):
            Dif.set_alpha_test_flavor(node_tree, False)

        out_node = node_tree.nodes[Dif.OUT_MAT_NODE]
        in_node = node_tree.nodes[Dif.OPACITY_NODE]

        if switch_on:
            blend_add.init(node_tree, in_node.outputs['Color'],
                           out_node.inputs['Alpha'])
        else:
            blend_add.delete(node_tree)