Make a curtain generator in Blender

Overview

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).

environment

Version: 2.74, Rendering engine: cycles

Preparation

First, start blender and blender1.png

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. blender2.png

Implementation

Materials are set for each of the left and right curtains. The material names should be curtain.left and curtain.right.

  1. Set texture
  2. Rendering
  3. Output as png

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. out.png

reference

Recommended Posts

Make a curtain generator in Blender
Make a bookmarklet in Python
[Blender] How to make a Blender plugin
Let's make a combination calculation in Python
Make a simple pixel art generator with Flask
Make a copy of the list in Python
Make a cocos2d game in a pixel double window
Make a rock-paper-scissors game in one line (python)
Make a joyplot-like plot of R in python
Make a squash game
Try to make a Python module in C language
Generator function in JavaScript
Make a simple Slackbot with interactive button in python
Make a function decorator
Make a distance matrix
dict in dict Makes a dict a dict
Put pip in Blender
I'll make a password!
Zundokokiyoshi (generator) in Python
Make a Nyan button
Make a Tetris-style game!
Let's make a cron program in Java! !! (Task Scheduler)
Make a Base64 decoder
Loop through a generator that returns a date iterator in Python
Make a tky2jgd plugin with no practicality in QGIS Part 2
Make a table of multiplication of each element in a spreadsheet (Python)
Make a tky2jgd plugin with no practicality in QGIS Part 1
Let's make a spot sale service 4 (in Python mini Hack-a-thon)
Put the lists together in pandas to make a DataFrame
Let's make a number guessing game in your own language!
I tried to make a stopwatch using tkinter in python
I want to make input () a nice complement in python
I want a mox generator
Take a screenshot in Python
Let's make a Discord Bot.
Make a Blueqat backend ~ Part 1
Create a function in Python
Create a dictionary in Python
Make a Blueqat backend ~ Part 2
Collaborate in a remote environment
[Django] Make a pull-down menu
Don't make test.py in Python!
Make a LINE BOT (chat)
I want a mox generator (2)
Make a fortune with Python
Make Responder a daemon (service)
Make Opencv available in Python
Make python segfault in 2 lines
Blender Python API in Houdini (Python 3)
Let's make a rock-paper-scissors game
Generate 8 * 8 (64) cubes in Blender Python
Make a fire with kdeplot
Make a math drill print
[Tutorial] Make a named entity extractor in 30 minutes using machine learning
How to make a string into an array or an array into a string in Python
Make a Spinbox that can be displayed in Binary with Tkinter
Make a Spinbox that can be displayed in HEX with Tkinter