46 lines
1.8 KiB
Python
46 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
import pathlib
|
|
import sys
|
|
|
|
import bpy
|
|
|
|
|
|
def main(output):
|
|
bpy.ops.wm.read_factory_settings(use_empty=True)
|
|
scene = bpy.context.scene
|
|
scene.name = "WBV2P3001MaterialScene"
|
|
bpy.ops.mesh.primitive_cube_add(size=2, location=(0, 0, 0))
|
|
cube = bpy.context.object
|
|
cube.name = "WBV2P3001MaterialCube"
|
|
cube.data.name = "WBV2P3001MaterialCubeMesh"
|
|
material = bpy.data.materials.new("WBV2P3001PrincipledMaterial")
|
|
material.use_nodes = True
|
|
nodes = material.node_tree.nodes
|
|
principled = nodes.get("Principled BSDF")
|
|
if principled is None:
|
|
raise RuntimeError("material fixture could not create Principled BSDF")
|
|
principled.inputs["Base Color"].default_value = (0.12, 0.34, 0.56, 1.0)
|
|
principled.inputs["Roughness"].default_value = 0.23
|
|
principled.inputs["Metallic"].default_value = 0.67
|
|
principled.inputs["IOR"].default_value = 1.42
|
|
unsupported = nodes.new("ShaderNodeTexNoise")
|
|
unsupported.name = "WBV2P3001UnsupportedNoise"
|
|
unsupported.label = "retained unsupported node"
|
|
cube.data.materials.append(material)
|
|
cube.select_set(True)
|
|
bpy.context.view_layer.objects.active = cube
|
|
if cube.data.uv_layers.active is None:
|
|
cube.data.uv_layers.new(name="UVMap")
|
|
cube.data.uv_layers.active.name = "WBV2P3001UV"
|
|
cube.data.uv_layers.active_index = 0
|
|
scene.world = bpy.data.worlds.new("WBV2P3001MaterialWorld")
|
|
scene.world.color = (0.055, 0.065, 0.08)
|
|
bpy.ops.wm.save_as_mainfile(filepath=str(pathlib.Path(output).resolve()), check_existing=False, compress=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
arguments = sys.argv[sys.argv.index("--") + 1 :]
|
|
if len(arguments) != 1:
|
|
raise SystemExit("usage: blender -b --factory-startup --python WBV2-P3-001.py -- OUTPUT")
|
|
main(arguments[0])
|