I made a program to generate a curtain image with blender. The original story is [How to make 3D from 2D — A story that it was surprisingly cool when I tried running Blender in the server --pixiv inside](http://inside.pixiv.net/entry/2015/09 / 24/173447).
Version: 2.74, Rendering engine: cycles
First, start blender and
Create a landscape with curtains. This time, the room is simply a room with curtains, and the white curtains are lace curtains that allow the light from the outside to pass through. By the way, I referred to Modeling with Cloth Simulation in Blender --YouTube for how to make curtains. It is explained in a very easy-to-understand manner.
Materials are set for each of the left and right curtains. The material names should be curtain.left
and curtain.right
.
This process is done programmatically. Written in python, it looks like this:
import sys
import os
import bpy
# How to pass command line arguments to a Blender Python script? - Blender Stack Exchange
# http://blender.stackexchange.com/questions/6817/how-to-pass-command-line-arguments-to-a-blender-python-script
argv = sys.argv
[left, right, out] = argv[argv.index("--") + 1:] # get all args after "--"
def update_filepath(material_name, filepath):
t = bpy.data.materials[material_name].node_tree.nodes.get('Image Texture')
t.image.filepath = filepath
update_filepath('curtain.left', os.path.abspath(left))
update_filepath('curtain.right', os.path.abspath(right))
bpy.ops.render.render()
bpy.data.images['Render Result'].save_render(filepath = os.path.abspath(out + '.png'))
When you do this
$ blender --background path/to/file.blend --python path/to/script.py -- left.png right.png rendered
This is what it looks like! I got a little noise, but I don't have time so far.
Recommended Posts