2019-12-05 22:56:16 +01:00
|
|
|
import bpy
|
|
|
|
|
|
|
|
|
|
|
|
base_collection = bpy.data.scenes["Base"].view_layers["RenderLayer"].layer_collection
|
|
|
|
highlight_collection = bpy.data.scenes["Toon Highlight"].view_layers["RenderLayer"].layer_collection
|
|
|
|
shadows_collection = bpy.data.scenes["Toon Shadows"].view_layers["RenderLayer"].layer_collection
|
|
|
|
|
2019-12-06 18:52:25 +01:00
|
|
|
def set_exclude(model, value):
|
|
|
|
base_collection.children[model].exclude = value
|
2019-12-05 22:56:16 +01:00
|
|
|
highlight_collection.children[f"Highlight {model}"].exclude = value
|
|
|
|
shadows_collection.children[f"Shadows {model}"].exclude = value
|
|
|
|
|
2019-12-06 18:52:25 +01:00
|
|
|
def set_color(model, color):
|
|
|
|
for obj in base_collection.children[model].collection.all_objects.values():
|
|
|
|
if len(obj.material_slots) != 3:
|
|
|
|
continue
|
|
|
|
obj.material_slots[1].material = bpy.data.materials[f"Liquid Surface {color}"]
|
|
|
|
obj.material_slots[2].material = bpy.data.materials[f"Liquid Glass {color}"]
|
2019-12-05 22:56:16 +01:00
|
|
|
|
|
|
|
def render_bottle(color, model, output):
|
2019-12-06 18:52:25 +01:00
|
|
|
set_exclude(model, False)
|
|
|
|
set_color(model, color)
|
2019-12-05 22:56:16 +01:00
|
|
|
bpy.data.scenes["Base"].render.filepath = output
|
|
|
|
bpy.ops.render.render(write_still=True)
|
2019-12-06 18:52:25 +01:00
|
|
|
set_exclude(model, True)
|
|
|
|
|
|
|
|
models = [
|
|
|
|
"Cube",
|
|
|
|
"Sphere",
|
|
|
|
"Spiked",
|
|
|
|
"Cone",
|
|
|
|
"Cylinder",
|
|
|
|
# "Tubes Duo",
|
|
|
|
"Tubes Trio",
|
|
|
|
"Pentagon",
|
|
|
|
"Hexagon",
|
|
|
|
]
|
2019-12-05 22:56:16 +01:00
|
|
|
|
|
|
|
bottles = [
|
|
|
|
["Red", "Cone", "//src/graphics/red.png"],
|
|
|
|
["Green", "Cube", "//src/graphics/green.png"],
|
|
|
|
["Black", "Spiked", "//src/graphics/black.png"],
|
|
|
|
["Cyan", "Sphere", "//src/graphics/cyan.png"],
|
2019-12-06 18:01:02 +01:00
|
|
|
["Purple", "Pentagon", "//src/graphics/purple.png"],
|
|
|
|
["Yellow", "Cylinder", "//src/graphics/yellow.png"],
|
2019-12-06 18:52:25 +01:00
|
|
|
["White", "Tubes Trio", "//src/graphics/white.png"],
|
2019-12-05 22:56:16 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
# Set active scene so the highlights/shadows isn't accidentally rendered
|
|
|
|
bpy.context.window.scene = bpy.data.scenes["Base"]
|
|
|
|
|
|
|
|
# Reset visibility of all bottles
|
2019-12-06 18:52:25 +01:00
|
|
|
for model in models:
|
|
|
|
set_exclude(model, True)
|
2019-12-05 22:56:16 +01:00
|
|
|
|
|
|
|
# Render the bottles
|
|
|
|
for color, model, output in bottles:
|
|
|
|
render_bottle(color, model, output)
|
|
|
|
|
|
|
|
print("Done!")
|