Improve rendering pipeline
Control bottle shape and color from the rendering script such that these can be switched around easily.
This commit is contained in:
parent
67a4773187
commit
25f7041aab
2 changed files with 26 additions and 7 deletions
BIN
model.blend
BIN
model.blend
Binary file not shown.
33
render.py
33
render.py
|
@ -5,17 +5,36 @@ base_collection = bpy.data.scenes["Base"].view_layers["RenderLayer"].layer_colle
|
||||||
highlight_collection = bpy.data.scenes["Toon Highlight"].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
|
shadows_collection = bpy.data.scenes["Toon Shadows"].view_layers["RenderLayer"].layer_collection
|
||||||
|
|
||||||
def set_exclude(color, model, value):
|
def set_exclude(model, value):
|
||||||
base_collection.children[color].exclude = value
|
base_collection.children[model].exclude = value
|
||||||
highlight_collection.children[f"Highlight {model}"].exclude = value
|
highlight_collection.children[f"Highlight {model}"].exclude = value
|
||||||
shadows_collection.children[f"Shadows {model}"].exclude = value
|
shadows_collection.children[f"Shadows {model}"].exclude = value
|
||||||
|
|
||||||
|
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}"]
|
||||||
|
|
||||||
def render_bottle(color, model, output):
|
def render_bottle(color, model, output):
|
||||||
set_exclude(color, model, False)
|
set_exclude(model, False)
|
||||||
|
set_color(model, color)
|
||||||
bpy.data.scenes["Base"].render.filepath = output
|
bpy.data.scenes["Base"].render.filepath = output
|
||||||
bpy.ops.render.render(write_still=True)
|
bpy.ops.render.render(write_still=True)
|
||||||
set_exclude(color, model, True)
|
set_exclude(model, True)
|
||||||
|
|
||||||
|
models = [
|
||||||
|
"Cube",
|
||||||
|
"Sphere",
|
||||||
|
"Spiked",
|
||||||
|
"Cone",
|
||||||
|
"Cylinder",
|
||||||
|
# "Tubes Duo",
|
||||||
|
"Tubes Trio",
|
||||||
|
"Pentagon",
|
||||||
|
"Hexagon",
|
||||||
|
]
|
||||||
|
|
||||||
bottles = [
|
bottles = [
|
||||||
["Red", "Cone", "//src/graphics/red.png"],
|
["Red", "Cone", "//src/graphics/red.png"],
|
||||||
|
@ -24,15 +43,15 @@ bottles = [
|
||||||
["Cyan", "Sphere", "//src/graphics/cyan.png"],
|
["Cyan", "Sphere", "//src/graphics/cyan.png"],
|
||||||
["Purple", "Pentagon", "//src/graphics/purple.png"],
|
["Purple", "Pentagon", "//src/graphics/purple.png"],
|
||||||
["Yellow", "Cylinder", "//src/graphics/yellow.png"],
|
["Yellow", "Cylinder", "//src/graphics/yellow.png"],
|
||||||
["White", "Tubes", "//src/graphics/white.png"],
|
["White", "Tubes Trio", "//src/graphics/white.png"],
|
||||||
]
|
]
|
||||||
|
|
||||||
# Set active scene so the highlights/shadows isn't accidentally rendered
|
# Set active scene so the highlights/shadows isn't accidentally rendered
|
||||||
bpy.context.window.scene = bpy.data.scenes["Base"]
|
bpy.context.window.scene = bpy.data.scenes["Base"]
|
||||||
|
|
||||||
# Reset visibility of all bottles
|
# Reset visibility of all bottles
|
||||||
for color, model, output in bottles:
|
for model in models:
|
||||||
set_exclude(color, model, True)
|
set_exclude(model, True)
|
||||||
|
|
||||||
# Render the bottles
|
# Render the bottles
|
||||||
for color, model, output in bottles:
|
for color, model, output in bottles:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue