Beispiel #1
0
    def finalize(node_tree, material):
        """Finalize node tree and material settings. Should be called as last.

        :param node_tree: node tree on which this shader should be finalized
        :type node_tree: bpy.types.NodeTree
        :param material: material used for this shader
        :type material: bpy.types.Material
        """

        material.use_backface_culling = True
        material.blend_method = "OPAQUE"

        if blend_over.is_set(node_tree):
            material.blend_method = "BLEND"
Beispiel #2
0
    def set_alpha_test_flavor(node_tree, switch_on):
        """Set alpha test flavor to this shader.

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

        if switch_on and not blend_over.is_set(node_tree):
            out_node = node_tree.nodes[DifSpecMultDifSpec.OUT_MAT_NODE]
            in_node = node_tree.nodes[DifSpecMultDifSpec.VCOL_GROUP_NODE]
            location = (out_node.location.x - 185 * 2, out_node.location.y - 500)

            alpha_test.init(node_tree, location, in_node.outputs['Vertex Color Alpha'], out_node.inputs['Alpha'])
        else:
            alpha_test.delete(node_tree)
Beispiel #3
0
    def set_alpha_test_flavor(node_tree, switch_on):
        """Set alpha test flavor to this shader.

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

        if switch_on and not blend_over.is_set(node_tree):
            out_node = node_tree.nodes[UnlitVcolTex.OUTPUT_NODE]
            in_node = node_tree.nodes[UnlitVcolTex.OPACITY_NODE]
            location = (out_node.location.x - 185 * 2, out_node.location.y - 500)

            alpha_test.init(node_tree, location, in_node.outputs["Value"], out_node.inputs["Alpha"])
        else:
            alpha_test.delete(node_tree)
Beispiel #4
0
    def set_alpha_test_flavor(node_tree, switch_on):
        """Set alpha test flavor to this shader.

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

        if switch_on and not blend_over.is_set(node_tree):
            out_node = node_tree.nodes[Dif.OUT_MAT_NODE]
            in_node = node_tree.nodes[Dif.BASE_TEX_NODE]
            location = (out_node.location.x - 185 * 2, out_node.location.y - 500)

            alpha_test.init(node_tree, location, in_node.outputs['Value'], out_node.inputs['Alpha'])
        else:
            alpha_test.delete(node_tree)
Beispiel #5
0
    def finalize(node_tree, material):
        """Finalize node tree and material settings. Should be called as last.

        :param node_tree: node tree on which this shader should be finalized
        :type node_tree: bpy.types.NodeTree
        :param material: material used for this shader
        :type material: bpy.types.Material
        """

        material.use_backface_culling = True
        material.blend_method = "OPAQUE"

        # set proper blend method
        if alpha_test.is_set(node_tree):
            material.blend_method = "CLIP"
            material.alpha_threshold = 0.05

            # add alpha test pass if multiply blend enabled, where alphed pixels shouldn't be multiplied as they are discarded
            if blend_mult.is_set(node_tree):
                lum_out_shader_n = node_tree.nodes[
                    DifLumSpec.LUM_OUT_SHADER_NODE]

                # alpha test pass has to get fully opaque input, thus remove transparency linkage
                compose_lighting_n = node_tree.nodes[
                    DifSpec.COMPOSE_LIGHTING_NODE]
                if compose_lighting_n.inputs['Alpha'].links:
                    node_tree.links.remove(
                        compose_lighting_n.inputs['Alpha'].links[0])
                if lum_out_shader_n.inputs['Transparency'].links:
                    node_tree.links.remove(
                        lum_out_shader_n.inputs['Transparency'].links[0])

                shader_from = lum_out_shader_n.outputs['BSDF']
                alpha_from = node_tree.nodes[DifSpec.OPACITY_NODE].outputs[0]
                shader_to = lum_out_shader_n.outputs['BSDF'].links[0].to_socket

                alpha_test.add_pass(node_tree, shader_from, alpha_from,
                                    shader_to)

        if blend_add.is_set(node_tree):
            material.blend_method = "BLEND"
        if blend_mult.is_set(node_tree):
            material.blend_method = "BLEND"
        if blend_over.is_set(node_tree):
            material.blend_method = "BLEND"
Beispiel #6
0
    def finalize(node_tree, material):
        """Set output material for this shader.

        :param node_tree: node tree of current shader
        :type node_tree: bpy.types.NodeTree
        :param material: blender material for used in this tree node as output
        :type material: bpy.types.Material
        """

        material.use_backface_culling = True
        material.blend_method = "OPAQUE"

        # set proper blend method
        if alpha_test.is_set(node_tree):
            material.blend_method = "CLIP"
            material.alpha_threshold = 0.05

            # add alpha test pass if multiply blend enabled, where alphed pixels shouldn't be multiplied as they are discarded
            if blend_mult.is_set(node_tree):
                out_shader_n = node_tree.nodes[UnlitTex.OUT_SHADER_NODE]

                # alpha test pass has to get fully opaque input, thus remove transparency linkage
                if out_shader_n.inputs['Transparency'].links:
                    node_tree.links.remove(
                        out_shader_n.inputs['Transparency'].links[0])

                shader_from = out_shader_n.outputs['BSDF']
                alpha_from = node_tree.nodes[
                    UnlitTex.BASE_TEX_NODE].outputs['Alpha']
                shader_to = out_shader_n.outputs['BSDF'].links[0].to_socket

                alpha_test.add_pass(node_tree, shader_from, alpha_from,
                                    shader_to)

        if blend_add.is_set(node_tree):
            material.blend_method = "BLEND"
        if blend_mult.is_set(node_tree):
            material.blend_method = "BLEND"
        if blend_over.is_set(node_tree):
            material.blend_method = "BLEND"
Beispiel #7
0
    def finalize(node_tree, material):
        """Finalize node tree and material settings. Should be called as last.

        :param node_tree: node tree on which this shader should be finalized
        :type node_tree: bpy.types.NodeTree
        :param material: material used for this shader
        :type material: bpy.types.Material
        """

        material.use_backface_culling = True
        material.blend_method = "OPAQUE"

        # set proper blend method
        if alpha_test.is_set(node_tree):
            material.blend_method = "CLIP"
            material.alpha_threshold = 0.05

            # add alpha test pass if:
            # 1. awhite is enabled, as alpha test pass is called before awhite is aplied
            # 2. multiply blend enabled, where alphed pixels shouldn't be multiplied as they are discarded
            if awhite.is_set(node_tree) or blend_mult.is_set(node_tree):
                out_shader_n = node_tree.nodes[UnlitVcolTex.OUT_SHADER_NODE]

                # alpha test pass has to get fully opaque input, thus remove transparency linkage
                if out_shader_n.inputs['Transparency'].links:
                    node_tree.links.remove(out_shader_n.inputs['Transparency'].links[0])

                shader_from = out_shader_n.outputs['BSDF']
                alpha_from = node_tree.nodes[UnlitVcolTex.OPACITY_NODE].outputs[0]
                shader_to = out_shader_n.outputs['BSDF'].links[0].to_socket

                alpha_test.add_pass(node_tree, shader_from, alpha_from, shader_to)

        if blend_add.is_set(node_tree):
            material.blend_method = "BLEND"
        if blend_mult.is_set(node_tree):
            material.blend_method = "BLEND"
        if blend_over.is_set(node_tree):
            material.blend_method = "BLEND"