Example #1
0
    def test_get_the_leaf_node_of_each_map_in_a_principled_bsdf(self):
        obj = bpy.data.materials.new("Material")
        obj.use_nodes = True
        bsdf = obj.node_tree.nodes["Principled BSDF"]

        diffuse = obj.node_tree.nodes.new(type="ShaderNodeTexImage")
        obj.node_tree.links.new(bsdf.inputs["Base Color"], diffuse.outputs["Color"])
        shininess = obj.node_tree.nodes.new(type="ShaderNodeTexImage")
        obj.node_tree.links.new(bsdf.inputs["Roughness"], shininess.outputs["Color"])
        normal = obj.node_tree.nodes.new(type="ShaderNodeTexImage")
        obj.node_tree.links.new(bsdf.inputs["Normal"], normal.outputs["Color"])
        specular = obj.node_tree.nodes.new(type="ShaderNodeTexImage")
        obj.node_tree.links.new(bsdf.inputs["Specular"], specular.outputs["Color"])
        emission = obj.node_tree.nodes.new(type="ShaderNodeTexImage")
        obj.node_tree.links.new(bsdf.inputs["Emission Strength"], emission.outputs["Color"])
        opacity = obj.node_tree.nodes.new(type="ShaderNodeTexImage")
        obj.node_tree.links.new(bsdf.inputs["Alpha"], opacity.outputs["Color"])

        assert subject.get_surface_textures(obj) == {
            "DIFFUSE": diffuse,
            "SHININESS": shininess,
            "NORMAL": normal,
            "SPECULAR": specular,
            "SELFILLUMINATION": emission,
            "OPACITY": opacity,
        }
Example #2
0
    def test_get_the_leaf_node_of_each_map_in_a_emission_bsdf(self):
        obj = bpy.data.materials.new("Material")
        obj.use_nodes = True
        bsdf = obj.node_tree.nodes["Principled BSDF"]

        obj.node_tree.nodes.remove(bsdf)
        bsdf = obj.node_tree.nodes.new(type="ShaderNodeEmission")
        output = {n.type: n for n in obj.node_tree.nodes}.get("OUTPUT_MATERIAL", None)
        obj.node_tree.links.new(output.inputs["Surface"], bsdf.outputs["Emission"])

        diffuse = obj.node_tree.nodes.new(type="ShaderNodeTexImage")
        obj.node_tree.links.new(bsdf.inputs["Color"], diffuse.outputs["Color"])

        assert subject.get_surface_textures(obj) == {"DIFFUSE": diffuse}
Example #3
0
    def test_get_the_leaf_node_of_each_map_in_a_glass_bsdf(self):
        obj = bpy.data.materials.new("Material")
        obj.use_nodes = True
        bsdf = obj.node_tree.nodes["Principled BSDF"]

        obj.node_tree.nodes.remove(bsdf)
        bsdf = obj.node_tree.nodes.new(type="ShaderNodeBsdfGlass")
        output = {n.type: n for n in obj.node_tree.nodes}.get("OUTPUT_MATERIAL", None)
        obj.node_tree.links.new(output.inputs["Surface"], bsdf.outputs["BSDF"])

        diffuse = obj.node_tree.nodes.new(type="ShaderNodeTexImage")
        obj.node_tree.links.new(bsdf.inputs["Color"], diffuse.outputs["Color"])
        shininess = obj.node_tree.nodes.new(type="ShaderNodeTexImage")
        obj.node_tree.links.new(bsdf.inputs["Roughness"], shininess.outputs["Color"])
        normal = obj.node_tree.nodes.new(type="ShaderNodeTexImage")
        obj.node_tree.links.new(bsdf.inputs["Normal"], normal.outputs["Color"])

        assert subject.get_surface_textures(obj) == {"DIFFUSE": diffuse, "SHININESS": shininess, "NORMAL": normal}