Add rendering pipeline
Add render script that renders all of the bottles into the graphics directory.
BIN
model.blend
2
render.cmd
Normal file
|
@ -0,0 +1,2 @@
|
|||
REM Pass the path to blender as the first argument
|
||||
%1 --background --python-exit-code 1 model.blend --python render.py
|
41
render.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
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
|
||||
|
||||
def set_exclude(color, model, value):
|
||||
base_collection.children[color].exclude = value
|
||||
highlight_collection.children[f"Highlight {model}"].exclude = value
|
||||
shadows_collection.children[f"Shadows {model}"].exclude = value
|
||||
|
||||
|
||||
def render_bottle(color, model, output):
|
||||
set_exclude(color, model, False)
|
||||
bpy.data.scenes["Base"].render.filepath = output
|
||||
bpy.ops.render.render(write_still=True)
|
||||
set_exclude(color, model, True)
|
||||
|
||||
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"],
|
||||
["Purple", "Cylinder", "//src/graphics/purple.png"],
|
||||
["Yellow", "Hexagon", "//src/graphics/yellow.png"],
|
||||
["White", "Tubes", "//src/graphics/white.png"],
|
||||
]
|
||||
|
||||
# Set active scene so the highlights/shadows isn't accidentally rendered
|
||||
bpy.context.window.scene = bpy.data.scenes["Base"]
|
||||
|
||||
# Reset visibility of all bottles
|
||||
for color, model, output in bottles:
|
||||
set_exclude(color, model, True)
|
||||
|
||||
# Render the bottles
|
||||
for color, model, output in bottles:
|
||||
render_bottle(color, model, output)
|
||||
|
||||
print("Done!")
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |