diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2014-01-03 01:05:07 +0400 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2014-05-03 04:19:09 +0400 |
commit | eec3eaba084725a978f4aefb773a16ae9c0420db (patch) | |
tree | 68e34c3e8ff42af5263c010895b6649961f82eb6 /intern/cycles/blender/blender_python.cpp | |
parent | 97641a0ec946005d9a042f075697109c6590a28d (diff) |
Cycles Bake
Expand Cycles to use the new baking API in Blender.
It works on the selected object, and the panel can be accessed in the Render panel (similar to where it is for the Blender Internal).
It bakes for the active texture of each material of the object. The active texture is currently defined as the active Image Texture node present in the material nodetree. If you don't want the baking to override an existent material, make sure the active Image Texture node is not connected to the nodetree. The active texture is also the texture shown in the viewport in the rendered mode.
Remember to save your images after the baking is complete.
Note: Bake currently only works in the CPU
Note: This is not supported by Cycles standalone because a lot of the work is done in Blender as part of the operator only, not the engine (Cycles).
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Bake
Supported Passes:
-----------------
Data Passes
* Normal
* UV
* Diffuse/Glossy/Transmission/Subsurface/Emit Color
Light Passes
* AO
* Combined
* Shadow
* Diffuse/Glossy/Transmission/Subsurface/Emit Direct/Indirect
* Environment
Review: D421
Reviewed by: Campbell Barton, Brecht van Lommel, Sergey Sharybin, Thomas Dinge
Original design by Brecht van Lommel.
The entire commit history can be found on the branch: bake-cycles
Diffstat (limited to 'intern/cycles/blender/blender_python.cpp')
-rw-r--r-- | intern/cycles/blender/blender_python.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp index 8b04a869a85..658fccaf12e 100644 --- a/intern/cycles/blender/blender_python.cpp +++ b/intern/cycles/blender/blender_python.cpp @@ -147,6 +147,38 @@ static PyObject *render_func(PyObject *self, PyObject *value) Py_RETURN_NONE; } +/* pixel_array and result passed as pointers */ +static PyObject *bake_func(PyObject *self, PyObject *args) +{ + PyObject *pysession, *pyobject; + PyObject *pypixel_array, *pyresult; + const char *pass_type; + int num_pixels, depth; + + if(!PyArg_ParseTuple(args, "OOsOiiO", &pysession, &pyobject, &pass_type, &pypixel_array, &num_pixels, &depth, &pyresult)) + return NULL; + + Py_BEGIN_ALLOW_THREADS + + BlenderSession *session = (BlenderSession*)PyLong_AsVoidPtr(pysession); + + PointerRNA objectptr; + RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pyobject), &objectptr); + BL::Object b_object(objectptr); + + void *b_result = PyLong_AsVoidPtr(pyresult); + + PointerRNA bakepixelptr; + RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pypixel_array), &bakepixelptr); + BL::BakePixel b_bake_pixel(bakepixelptr); + + session->bake(b_object, pass_type, b_bake_pixel, num_pixels, depth, (float *)b_result); + + Py_END_ALLOW_THREADS + + Py_RETURN_NONE; +} + static PyObject *draw_func(PyObject *self, PyObject *args) { PyObject *pysession, *pyv3d, *pyrv3d; @@ -418,6 +450,7 @@ static PyMethodDef methods[] = { {"create", create_func, METH_VARARGS, ""}, {"free", free_func, METH_O, ""}, {"render", render_func, METH_O, ""}, + {"bake", bake_func, METH_VARARGS, ""}, {"draw", draw_func, METH_VARARGS, ""}, {"sync", sync_func, METH_O, ""}, {"reset", reset_func, METH_VARARGS, ""}, |