Esempio n. 1
0
 def test_get_rendering_styles_from_a_emission_bsdf(self):
     obj = bpy.data.materials.new("Material")
     obj.diffuse_color = [1, 1, 1, 1]
     obj.use_nodes = True
     node = obj.node_tree.nodes["Principled BSDF"]
     obj.node_tree.nodes.remove(node)
     node = obj.node_tree.nodes.new(type="ShaderNodeEmission")
     node.inputs["Color"].default_value = [0.5, 0.5, 0.5, 0.5]
     assert subject.get_surface_rendering_attributes(obj) == {
         "SurfaceColour": {
             "Name": None,
             "Red": 1,
             "Green": 1,
             "Blue": 1,
         },
         "Transparency": 1,
         "DiffuseColour": {
             "Name": None,
             "Red": 0.5,
             "Green": 0.5,
             "Blue": 0.5,
         },
         "SpecularHighlight": None,
         "ReflectanceMethod": "FLAT",
     }
Esempio n. 2
0
 def test_other_unsupported_bsdfs_copy_the_rendering_style_from_the_shading_colours_as_a_fallback(self):
     obj = bpy.data.materials.new("Material")
     obj.diffuse_color = [1, 1, 1, 1]
     obj.use_nodes = True
     node = obj.node_tree.nodes["Principled BSDF"]
     obj.node_tree.nodes.remove(node)
     node = obj.node_tree.nodes.new(type="ShaderNodeVolumePrincipled")
     node.inputs["Color"].default_value = [0.5, 0.5, 0.5, 0.5]
     assert subject.get_surface_rendering_attributes(obj) == {
         "SurfaceColour": {
             "Name": None,
             "Red": 1,
             "Green": 1,
             "Blue": 1,
         },
         "Transparency": 1,
         "DiffuseColour": {
             "Name": None,
             "Red": 1,
             "Green": 1,
             "Blue": 1,
         },
         "SpecularHighlight": None,
         "ReflectanceMethod": "NOTDEFINED",
     }
Esempio n. 3
0
 def test_get_different_surface_and_diffuse_colours_from_a_principled_bsdf(self):
     obj = bpy.data.materials.new("Material")
     obj.diffuse_color = [1, 1, 1, 1]
     obj.use_nodes = True
     node = obj.node_tree.nodes["Principled BSDF"]
     node.inputs["Alpha"].default_value = 0.8
     node.inputs["Base Color"].default_value = [0.5, 0.5, 0.5, 0.5]
     node.inputs["Roughness"].default_value = 0.2
     assert subject.get_surface_rendering_attributes(obj) == {
         "SurfaceColour": {
             "Name": None,
             "Red": 1,
             "Green": 1,
             "Blue": 1,
         },
         "Transparency": 1 - node.inputs["Alpha"].default_value,
         "DiffuseColour": {
             "Name": None,
             "Red": 0.5,
             "Green": 0.5,
             "Blue": 0.5,
         },
         "SpecularHighlight": {"IfcSpecularRoughness": 0.2},
         "ReflectanceMethod": "NOTDEFINED",
     }