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:08 +0400 |
commit | 97641a0ec946005d9a042f075697109c6590a28d (patch) | |
tree | 7661e462d6426298453d1f5ddd6b7e2ffb74ed65 /source/blender/blenloader | |
parent | 3312b20ac8c8a5e45d87c5c1f59ce0907350d398 (diff) |
Bake API - bpy.ops.object.bake()
New operator that can calls a bake function to the current render engine when available. This commit provides no feature for the users, but allows external engines to be accessed by the operator and be integrated with the baking api.
The API itself is simple. Blender sends a populated array of BakePixels to the renderer, and gets back an array of floats with the result.
The Blender Internal (and multires) system is still running independent, but we eventually will pipe it through the API as well. Cycles baking will come next as a separated commit
Python Operator:
----------------
The operator can be called with some arguments, or a user interface can be created for it. In that case the arguments can be ommited and the interface can expose the settings from bpy.context.scene.render.bake
bpy.ops.object.bake(type='COMBINED', filepath="", width=512, height=512, margin=16, use_selected_to_active=False, cage_extrusion=0, cage="", normal_space='TANGENT', normal_r='POS_X', normal_g='POS_Y', normal_b='POS_Z', save_mode='INTERNAL', use_clear=False, use_split_materials=False, use_automatic_name=False)
Note: external save mode is currently disabled.
Supported Features:
------------------
* Margin - Baked result is extended this many pixels beyond the border of each UV "island," to soften seams in the texture.
* Selected to Active - bake shading on the surface of selected object to the active object. The rays are cast from the lowpoly object inwards towards the highpoly object. If the highpoly object is not entirely involved by the lowpoly object, you can tweak the rays start point with Cage Extrusion. For even more control of the cage you can use a Cage object.
* Cage Extrusion - distance to use for the inward ray cast when using selected to active
* Custom Cage - object to use as cage (instead of the lowpoly object).
* Normal swizzle - change the axis that gets mapped to RGB
* Normal space - save as tangent or object normal spaces
Supported Passes:
-----------------
Any pass that is supported by Blender renderlayer system. Though it's up to the external engine to provide a valid enum with its supported passes. Normal passes get a special treatment since we post-process them to converted and "swizzled"
Development Notes for External Engines:
---------------------------------------
(read them in bake_api.c)
* For a complete implementation example look at the Cycles Bake commit (next).
Review: D421
Reviewed by: Campbell Barton, Brecht van Lommel, Sergey Sharybin, Thomas Dinge
Normal map pipeline "consulting" by Andy Davies (metalliandy)
Original design by Brecht van Lommel.
The entire commit history can be found on the branch: bake-cycles
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/versioning_270.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 0fe105346a3..a6cd854d874 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -51,6 +51,9 @@ #include "BKE_main.h" #include "BKE_node.h" +#include "BLI_math.h" +#include "BLI_string.h" + #include "BLO_readfile.h" #include "readfile.h" @@ -254,4 +257,26 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) for (ma = main->mat.first; ma; ma = ma->id.next) ma->mode2 = MA_CASTSHADOW; } + + if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "BakeData", "bake")) { + Scene *sce; + + for (sce = main->scene.first; sce; sce = sce->id.next) { + sce->r.bake.flag = R_BAKE_CLEAR; + sce->r.bake.width = 512; + sce->r.bake.height = 512; + sce->r.bake.margin = 16; + sce->r.bake.normal_space = R_BAKE_SPACE_TANGENT; + sce->r.bake.normal_swizzle[0] = R_BAKE_POSX; + sce->r.bake.normal_swizzle[1] = R_BAKE_POSY; + sce->r.bake.normal_swizzle[2] = R_BAKE_POSZ; + BLI_strncpy(sce->r.bake.filepath, U.renderdir, sizeof(sce->r.bake.filepath)); + + sce->r.bake.im_format.planes = R_IMF_PLANES_RGBA; + sce->r.bake.im_format.imtype = R_IMF_IMTYPE_PNG; + sce->r.bake.im_format.depth = R_IMF_CHAN_DEPTH_8; + sce->r.bake.im_format.quality = 90; + sce->r.bake.im_format.compress = 15; + } + } } |