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():
|
2019-12-07 18:02:46 +01:00
|
|
|
if len(obj.material_slots) < 3:
|
2019-12-06 18:52:25 +01:00
|
|
|
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 = [
|
|
|
|
"Cone",
|
2019-12-07 18:02:46 +01:00
|
|
|
"Cone Slim",
|
|
|
|
"Cone Inverted",
|
2019-12-06 18:52:25 +01:00
|
|
|
"Cylinder",
|
2019-12-07 18:02:46 +01:00
|
|
|
"Tube",
|
|
|
|
"Tubes Duo",
|
2019-12-06 18:52:25 +01:00
|
|
|
"Tubes Trio",
|
2019-12-07 18:02:46 +01:00
|
|
|
"Sphere",
|
|
|
|
"Sphere Tiny",
|
|
|
|
"Sphere Double",
|
|
|
|
"Sphere Tubed",
|
|
|
|
"Cube",
|
|
|
|
"Spiked",
|
|
|
|
"Pyramid",
|
|
|
|
"Triangle",
|
|
|
|
"Triangle Alt",
|
2019-12-06 18:52:25 +01:00
|
|
|
"Pentagon",
|
|
|
|
"Hexagon",
|
|
|
|
]
|
2019-12-05 22:56:16 +01:00
|
|
|
|
2019-12-07 18:02:46 +01:00
|
|
|
|
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-07 18:02:46 +01:00
|
|
|
["Purple", "Sphere Double", "//src/graphics/purple.png"],
|
|
|
|
["Yellow", "Triangle Alt", "//src/graphics/yellow.png"],
|
|
|
|
["White", "Cone Inverted", "//src/graphics/white.png"],
|
2019-12-05 22:56:16 +01:00
|
|
|
]
|
|
|
|
|
2019-12-07 18:02:46 +01:00
|
|
|
# Code to render a preview of all types
|
|
|
|
# bottles = [["Red", type, f"//types/{type}.png"] for type in models]
|
|
|
|
|
|
|
|
# Code for prototyping speedup
|
|
|
|
# bpy.data.scenes["Base"].cycles.samples = 1024
|
|
|
|
|
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!")
|