Advance M8-M11 parity workflows
This commit is contained in:
54
tools/web/generate-m11-compositor-allowlist.py
Normal file
54
tools/web/generate-m11-compositor-allowlist.py
Normal file
@@ -0,0 +1,54 @@
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
SCENES = (
|
||||
("M11 Constant", (0.125, 0.25, 0.5, 0.75), ()),
|
||||
("M11 Exposure", (0.125, 0.25, 0.5, 0.75), (("EXPOSURE", 1.0),)),
|
||||
("M11 Invert", (0.125, 0.25, 0.5, 0.75), (("INVERT", None),)),
|
||||
("M11 Chain", (0.125, 0.25, 0.5, 0.75), (("EXPOSURE", 1.0), ("INVERT", None))),
|
||||
)
|
||||
|
||||
|
||||
def add_graph(scene, color_value, operations):
|
||||
tree = bpy.data.node_groups.new(f"{scene.name} Tree", "CompositorNodeTree")
|
||||
scene.compositing_node_group = tree
|
||||
tree.interface.new_socket(name="Image", in_out="OUTPUT", socket_type="NodeSocketColor")
|
||||
color = tree.nodes.new("CompositorNodeRGB")
|
||||
color.name = f"{scene.name} Constant"
|
||||
color.outputs["Color"].default_value = color_value
|
||||
previous = color.outputs["Color"]
|
||||
for index, (operation, parameter) in enumerate(operations):
|
||||
if operation == "EXPOSURE":
|
||||
node = tree.nodes.new("CompositorNodeExposure")
|
||||
node.inputs["Exposure"].default_value = parameter
|
||||
else:
|
||||
node = tree.nodes.new("CompositorNodeInvert")
|
||||
node.name = f"{scene.name} {operation.title()} {index}"
|
||||
tree.links.new(previous, node.inputs["Image" if operation == "EXPOSURE" else "Color"])
|
||||
previous = node.outputs["Image" if operation == "EXPOSURE" else "Color"]
|
||||
output = tree.nodes.new("NodeGroupOutput")
|
||||
output.name = f"{scene.name} Composite"
|
||||
tree.links.new(previous, output.inputs["Image"])
|
||||
|
||||
|
||||
def main(output_path):
|
||||
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||
first = bpy.context.scene
|
||||
for index, (name, color, operations) in enumerate(SCENES):
|
||||
scene = first if index == 0 else bpy.data.scenes.new(name)
|
||||
scene.name = name
|
||||
add_graph(scene, color, operations)
|
||||
output = pathlib.Path(output_path).resolve()
|
||||
output.parent.mkdir(parents=True, exist_ok=True)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=str(output), compress=True)
|
||||
print(f"m11-compositor-allowlist fixture={output} scenes={len(SCENES)}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
arguments = sys.argv[sys.argv.index("--") + 1:]
|
||||
if len(arguments) != 1:
|
||||
raise SystemExit("usage: blender -b --python generate-m11-compositor-allowlist.py -- OUTPUT")
|
||||
main(arguments[0])
|
||||
Reference in New Issue
Block a user