Created
September 4, 2017 07:54
-
-
Save cyrildiagne/4f347a3d31c24cc0490603a09ff96855 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run as: blender -b <filename> -P <this_script> -- <image_path> | |
import bpy, sys, os | |
from random import random | |
# Assume the last argument is image path | |
output_folder = sys.argv[-1] | |
for i in range(806, 1000): | |
vase = bpy.data.objects["vase"] | |
scene = bpy.data.scenes['Scene'] | |
# Random color | |
mat_color = vase.active_material.node_tree.nodes["Glass BSDF"].inputs[0] | |
mat_color.default_value[0] = random() | |
mat_color.default_value[1] = random() | |
mat_color.default_value[2] = random() | |
# Random rotation | |
# vase.rotation_euler[2] = random() * 360 | |
# Random geom | |
ob = bpy.context.object # active object | |
# iterate over points of the curve's first spline | |
for j, p in enumerate(ob.data.splines.active.bezier_points): | |
p.co.x = random() | |
if j != 0: | |
p.co.z = random() * 1.5 | |
p.handle_left.x = random() | |
p.handle_left.z = random() | |
p.handle_right.x = random() | |
p.handle_right.z = random() | |
# Render outline | |
scene.render.engine = 'BLENDER_RENDER' | |
scene.render.use_freestyle = True | |
scene.render.filepath = '{}/vase{}-A.png'.format(output_folder, i) | |
bpy.ops.render.render(write_still=True) | |
# Render realistic | |
scene.render.engine = 'CYCLES' | |
scene.render.use_freestyle = False | |
scene.render.filepath = '{}/vase{}-B.png'.format(output_folder, i) | |
bpy.ops.render.render(write_still=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment