Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2016-01-15 18:00:56 +0300
committerDalai Felinto <dfelinto@gmail.com>2016-01-15 18:00:56 +0300
commit9a76354585e2cd2011267e79bd99ca59a06588f8 (patch)
treee775e7c44dc210ef9978b483930ade6a9b4d6fc5 /intern/cycles/blender
parent9137a4401440d3f3206e989f49f3539079d685b8 (diff)
Cycles-Bake: Custom Baking passes
The combined pass is built with the contributions the user finds fit. It is useful for lightmap baking, as well as non-view dependent effects baking. The manual will be updated once we get closer to the 2.77 release. Meanwhile the new page can be found here: http://dalaifelinto.com/blender-manual/render/cycles/baking.html Reviewers: sergey, brecht Differential Revision: https://developer.blender.org/D1674
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r--intern/cycles/blender/addon/__init__.py4
-rw-r--r--intern/cycles/blender/addon/engine.py4
-rw-r--r--intern/cycles/blender/addon/properties.py16
-rw-r--r--intern/cycles/blender/addon/ui.py41
-rw-r--r--intern/cycles/blender/addon/version_update.py63
-rw-r--r--intern/cycles/blender/blender_python.cpp6
-rw-r--r--intern/cycles/blender/blender_session.cpp66
-rw-r--r--intern/cycles/blender/blender_session.h9
8 files changed, 166 insertions, 43 deletions
diff --git a/intern/cycles/blender/addon/__init__.py b/intern/cycles/blender/addon/__init__.py
index 0783c1c4cba..e883413d935 100644
--- a/intern/cycles/blender/addon/__init__.py
+++ b/intern/cycles/blender/addon/__init__.py
@@ -67,8 +67,8 @@ class CyclesRender(bpy.types.RenderEngine):
def render(self, scene):
engine.render(self)
- def bake(self, scene, obj, pass_type, object_id, pixel_array, num_pixels, depth, result):
- engine.bake(self, obj, pass_type, object_id, pixel_array, num_pixels, depth, result)
+ def bake(self, scene, obj, pass_type, pass_filter, object_id, pixel_array, num_pixels, depth, result):
+ engine.bake(self, obj, pass_type, pass_filter, object_id, pixel_array, num_pixels, depth, result)
# viewport render
def view_update(self, context):
diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py
index 19fa23bd74a..42ec253613f 100644
--- a/intern/cycles/blender/addon/engine.py
+++ b/intern/cycles/blender/addon/engine.py
@@ -110,11 +110,11 @@ def render(engine):
_cycles.render(engine.session)
-def bake(engine, obj, pass_type, object_id, pixel_array, num_pixels, depth, result):
+def bake(engine, obj, pass_type, pass_filter, object_id, pixel_array, num_pixels, depth, result):
import _cycles
session = getattr(engine, "session", None)
if session is not None:
- _cycles.bake(engine.session, obj.as_pointer(), pass_type, object_id, pixel_array.as_pointer(), num_pixels, depth, result.as_pointer())
+ _cycles.bake(engine.session, obj.as_pointer(), pass_type, pass_filter, object_id, pixel_array.as_pointer(), num_pixels, depth, result.as_pointer())
def reset(engine, data, scene):
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index ed6cea2bcb2..c83da3d5b54 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -493,18 +493,10 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
('UV', "UV", ""),
('EMIT', "Emit", ""),
('ENVIRONMENT', "Environment", ""),
- ('DIFFUSE_DIRECT', "Diffuse Direct", ""),
- ('DIFFUSE_INDIRECT', "Diffuse Indirect", ""),
- ('DIFFUSE_COLOR', "Diffuse Color", ""),
- ('GLOSSY_DIRECT', "Glossy Direct", ""),
- ('GLOSSY_INDIRECT', "Glossy Indirect", ""),
- ('GLOSSY_COLOR', "Glossy Color", ""),
- ('TRANSMISSION_DIRECT', "Transmission Direct", ""),
- ('TRANSMISSION_INDIRECT', "Transmission Indirect", ""),
- ('TRANSMISSION_COLOR', "Transmission Color", ""),
- ('SUBSURFACE_DIRECT', "Subsurface Direct", ""),
- ('SUBSURFACE_INDIRECT', "Subsurface Indirect", ""),
- ('SUBSURFACE_COLOR', "Subsurface Color", ""),
+ ('DIFFUSE', "Diffuse", ""),
+ ('GLOSSY', "Glossy", ""),
+ ('TRANSMISSION', "Transmission", ""),
+ ('SUBSURFACE', "Subsurface", ""),
),
)
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index 8d00e4850d7..22df14201e8 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -1448,16 +1448,49 @@ class CyclesRender_PT_bake(CyclesButtonsPanel, Panel):
if cscene.bake_type == 'NORMAL':
layout.separator()
- box = layout.box()
- box.label(text="Normal Settings:")
- box.prop(cbk, "normal_space", text="Space")
+ col = layout.column()
+ col.label(text="Normal Settings:")
+ col.prop(cbk, "normal_space", text="Space")
- row = box.row(align=True)
+ row = col.row(align=True)
row.label(text="Swizzle:")
row.prop(cbk, "normal_r", text="")
row.prop(cbk, "normal_g", text="")
row.prop(cbk, "normal_b", text="")
+ elif cscene.bake_type == 'COMBINED':
+ col = layout.column()
+ col.label(text="Combined Settings:")
+
+ row = col.row()
+ row.prop(cbk, "use_pass_ambient_occlusion")
+ row.prop(cbk, "use_pass_emit")
+
+ row = col.row(align=True)
+ row.prop(cbk, "use_pass_direct", toggle=True)
+ row.prop(cbk, "use_pass_indirect", toggle=True)
+
+ split = col.split()
+ split.active = cbk.use_pass_direct or cbk.use_pass_indirect
+
+ col = split.column()
+ col.prop(cbk, "use_pass_diffuse")
+ col.prop(cbk, "use_pass_glossy")
+
+ col = split.column()
+ col.prop(cbk, "use_pass_transmission")
+ col.prop(cbk, "use_pass_subsurface")
+
+ elif cscene.bake_type in {'DIFFUSE', 'GLOSSY', 'TRANSMISSION', 'SUBSURFACE'}:
+ layout.separator()
+ col = layout.column()
+ col.label(text="{0} Settings:".format(cscene.bake_type.title()))
+
+ row = col.row(align=True)
+ row.prop(cbk, "use_pass_direct", toggle=True)
+ row.prop(cbk, "use_pass_indirect", toggle=True)
+ row.prop(cbk, "use_pass_color", toggle=True)
+
class CyclesRender_PT_debug(CyclesButtonsPanel, Panel):
bl_label = "Debug"
diff --git a/intern/cycles/blender/addon/version_update.py b/intern/cycles/blender/addon/version_update.py
index eb6d5d957ad..d8b3f5bc672 100644
--- a/intern/cycles/blender/addon/version_update.py
+++ b/intern/cycles/blender/addon/version_update.py
@@ -113,6 +113,64 @@ def vector_curve_node_remap(node):
point.location.y = (point.location.y - 0.5) * 2.0
node.mapping.update()
+
+def custom_bake_remap(scene):
+ """
+ Remap bake types into the new types and set the flags accordingly
+ """
+ bake_lookup = (
+ 'COMBINED',
+ 'AO',
+ 'SHADOW',
+ 'NORMAL',
+ 'UV',
+ 'EMIT',
+ 'ENVIRONMENT',
+ 'DIFFUSE_DIRECT',
+ 'DIFFUSE_INDIRECT',
+ 'DIFFUSE_COLOR',
+ 'GLOSSY_DIRECT',
+ 'GLOSSY_INDIRECT',
+ 'GLOSSY_COLOR',
+ 'TRANSMISSION_DIRECT',
+ 'TRANSMISSION_INDIRECT',
+ 'TRANSMISSION_COLOR',
+ 'SUBSURFACE_DIRECT',
+ 'SUBSURFACE_INDIRECT',
+ 'SUBSURFACE_COLOR')
+
+ diffuse_direct_idx = bake_lookup.index('DIFFUSE_DIRECT')
+
+ cscene = scene.cycles
+
+ # Old bake type
+ bake_type_idx = cscene.get("bake_type")
+
+ if bake_type_idx is None:
+ cscene.bake_type = 'COMBINED'
+ return
+
+ # File doesn't need versioning
+ if bake_type_idx < diffuse_direct_idx:
+ return
+
+ # File needs versioning
+ bake_type = bake_lookup[bake_type_idx]
+ cscene.bake_type, end = bake_type.split('_')
+
+ if end == 'DIRECT':
+ scene.render.bake.use_pass_indirect = False
+ scene.render.bake.use_pass_color = False
+
+ elif end == 'INDIRECT':
+ scene.render.bake.use_pass_direct = False
+ scene.render.bake.use_pass_color = False
+
+ elif end == 'COLOR':
+ scene.render.bake.use_pass_direct = False
+ scene.render.bake.use_pass_indirect = False
+
+
@persistent
def do_versions(self):
# We don't modify startup file because it assumes to
@@ -156,3 +214,8 @@ def do_versions(self):
if bpy.data.version <= (2, 76, 5):
foreach_cycles_node(vector_curve_node_remap)
+
+ # Baking types changed
+ if bpy.data.version <= (2, 76, 6):
+ for scene in bpy.data.scenes:
+ custom_bake_remap(scene)
diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp
index acc6f4cde95..006301eead7 100644
--- a/intern/cycles/blender/blender_python.cpp
+++ b/intern/cycles/blender/blender_python.cpp
@@ -269,9 +269,9 @@ static PyObject *bake_func(PyObject * /*self*/, PyObject *args)
PyObject *pysession, *pyobject;
PyObject *pypixel_array, *pyresult;
const char *pass_type;
- int num_pixels, depth, object_id;
+ int num_pixels, depth, object_id, pass_filter;
- if(!PyArg_ParseTuple(args, "OOsiOiiO", &pysession, &pyobject, &pass_type, &object_id, &pypixel_array, &num_pixels, &depth, &pyresult))
+ if(!PyArg_ParseTuple(args, "OOsiiOiiO", &pysession, &pyobject, &pass_type, &pass_filter, &object_id, &pypixel_array, &num_pixels, &depth, &pyresult))
return NULL;
BlenderSession *session = (BlenderSession*)PyLong_AsVoidPtr(pysession);
@@ -288,7 +288,7 @@ static PyObject *bake_func(PyObject * /*self*/, PyObject *args)
python_thread_state_save(&session->python_thread_state);
- session->bake(b_object, pass_type, object_id, b_bake_pixel, (size_t)num_pixels, depth, (float *)b_result);
+ session->bake(b_object, pass_type, pass_filter, object_id, b_bake_pixel, (size_t)num_pixels, depth, (float *)b_result);
python_thread_state_restore(&session->python_thread_state);
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index 088748cc0ae..a2a399e6152 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -316,22 +316,14 @@ static ShaderEvalType get_shader_type(const string& pass_type)
return SHADER_EVAL_COMBINED;
else if(strcmp(shader_type, "SHADOW")==0)
return SHADER_EVAL_SHADOW;
- else if(strcmp(shader_type, "DIFFUSE_DIRECT")==0)
- return SHADER_EVAL_DIFFUSE_DIRECT;
- else if(strcmp(shader_type, "GLOSSY_DIRECT")==0)
- return SHADER_EVAL_GLOSSY_DIRECT;
- else if(strcmp(shader_type, "TRANSMISSION_DIRECT")==0)
- return SHADER_EVAL_TRANSMISSION_DIRECT;
- else if(strcmp(shader_type, "SUBSURFACE_DIRECT")==0)
- return SHADER_EVAL_SUBSURFACE_DIRECT;
- else if(strcmp(shader_type, "DIFFUSE_INDIRECT")==0)
- return SHADER_EVAL_DIFFUSE_INDIRECT;
- else if(strcmp(shader_type, "GLOSSY_INDIRECT")==0)
- return SHADER_EVAL_GLOSSY_INDIRECT;
- else if(strcmp(shader_type, "TRANSMISSION_INDIRECT")==0)
- return SHADER_EVAL_TRANSMISSION_INDIRECT;
- else if(strcmp(shader_type, "SUBSURFACE_INDIRECT")==0)
- return SHADER_EVAL_SUBSURFACE_INDIRECT;
+ else if(strcmp(shader_type, "DIFFUSE")==0)
+ return SHADER_EVAL_DIFFUSE;
+ else if(strcmp(shader_type, "GLOSSY")==0)
+ return SHADER_EVAL_GLOSSY;
+ else if(strcmp(shader_type, "TRANSMISSION")==0)
+ return SHADER_EVAL_TRANSMISSION;
+ else if(strcmp(shader_type, "SUBSURFACE")==0)
+ return SHADER_EVAL_SUBSURFACE;
/* extra */
else if(strcmp(shader_type, "ENVIRONMENT")==0)
@@ -543,11 +535,47 @@ static void populate_bake_data(BakeData *data, const int object_id, BL::BakePixe
}
}
-void BlenderSession::bake(BL::Object b_object, const string& pass_type, const int object_id, BL::BakePixel pixel_array, const size_t num_pixels, const int /*depth*/, float result[])
+static int bake_pass_filter_get(const int pass_filter)
+{
+ int flag = BAKE_FILTER_NONE;
+
+ if((pass_filter & BL::BakeSettings::pass_filter_DIRECT) != 0)
+ flag |= BAKE_FILTER_DIRECT;
+ if((pass_filter & BL::BakeSettings::pass_filter_INDIRECT) != 0)
+ flag |= BAKE_FILTER_INDIRECT;
+ if((pass_filter & BL::BakeSettings::pass_filter_COLOR) != 0)
+ flag |= BAKE_FILTER_COLOR;
+
+ if((pass_filter & BL::BakeSettings::pass_filter_DIFFUSE) != 0)
+ flag |= BAKE_FILTER_DIFFUSE;
+ if((pass_filter & BL::BakeSettings::pass_filter_GLOSSY) != 0)
+ flag |= BAKE_FILTER_GLOSSY;
+ if((pass_filter & BL::BakeSettings::pass_filter_TRANSMISSION) != 0)
+ flag |= BAKE_FILTER_TRANSMISSION;
+ if((pass_filter & BL::BakeSettings::pass_filter_SUBSURFACE) != 0)
+ flag |= BAKE_FILTER_SUBSURFACE;
+
+ if((pass_filter & BL::BakeSettings::pass_filter_EMIT) != 0)
+ flag |= BAKE_FILTER_EMISSION;
+ if((pass_filter & BL::BakeSettings::pass_filter_AO) != 0)
+ flag |= BAKE_FILTER_AO;
+
+ return flag;
+}
+
+void BlenderSession::bake(BL::Object b_object,
+ const string& pass_type,
+ const int pass_filter,
+ const int object_id,
+ BL::BakePixel pixel_array,
+ const size_t num_pixels,
+ const int /*depth*/,
+ float result[])
{
ShaderEvalType shader_type = get_shader_type(pass_type);
size_t object_index = OBJECT_NONE;
int tri_offset = 0;
+ int bake_pass_filter = bake_pass_filter_get(pass_filter);
/* Set baking flag in advance, so kernel loading can check if we need
* any baking capabilities.
@@ -565,7 +593,7 @@ void BlenderSession::bake(BL::Object b_object, const string& pass_type, const in
Pass::add(PASS_UV, scene->film->passes);
}
- if(BakeManager::is_light_pass(shader_type)) {
+ if(BakeManager::is_light_pass(shader_type, bake_pass_filter)) {
/* force use_light_pass to be true */
Pass::add(PASS_LIGHT, scene->film->passes);
}
@@ -617,7 +645,7 @@ void BlenderSession::bake(BL::Object b_object, const string& pass_type, const in
session->progress.set_update_callback(function_bind(&BlenderSession::update_bake_progress, this));
- scene->bake_manager->bake(scene->device, &scene->dscene, scene, session->progress, shader_type, bake_data, result);
+ scene->bake_manager->bake(scene->device, &scene->dscene, scene, session->progress, shader_type, bake_pass_filter, bake_data, result);
/* free all memory used (host and device), so we wouldn't leave render
* engine with extra memory allocated
diff --git a/intern/cycles/blender/blender_session.h b/intern/cycles/blender/blender_session.h
index 708776dc8ca..0d391cadc98 100644
--- a/intern/cycles/blender/blender_session.h
+++ b/intern/cycles/blender/blender_session.h
@@ -52,7 +52,14 @@ public:
/* offline render */
void render();
- void bake(BL::Object b_object, const string& pass_type, const int object_id, BL::BakePixel pixel_array, const size_t num_pixels, const int depth, float pixels[]);
+ void bake(BL::Object b_object,
+ const string& pass_type,
+ const int custom_flag,
+ const int object_id,
+ BL::BakePixel pixel_array,
+ const size_t num_pixels,
+ const int depth,
+ float pixels[]);
void write_render_result(BL::RenderResult b_rr, BL::RenderLayer b_rlay, RenderTile& rtile);
void write_render_tile(RenderTile& rtile);