[Bf-blender-cvs] [52254ce] experimental-build: Cycles-Bake: Custom Baking pass
Dalai Felinto
noreply at git.blender.org
Tue Dec 15 21:20:59 CET 2015
Commit: 52254ce655597c430ced176272f5202fedad2c02
Author: Dalai Felinto
Date: Tue Dec 15 18:20:34 2015 -0200
Branches: experimental-build
https://developer.blender.org/rB52254ce655597c430ced176272f5202fedad2c02
Cycles-Bake: Custom Baking pass
This pass is built based on the passes the user finds fit.
It is useful for lightmap baking, as well as non-view dependent effects
baking.
===================================================================
M intern/cycles/blender/addon/__init__.py
M intern/cycles/blender/addon/engine.py
M intern/cycles/blender/addon/properties.py
M intern/cycles/blender/addon/ui.py
M intern/cycles/blender/blender_python.cpp
M intern/cycles/blender/blender_session.cpp
M intern/cycles/blender/blender_session.h
M intern/cycles/kernel/kernel_bake.h
M intern/cycles/kernel/kernel_types.h
M intern/cycles/render/bake.cpp
M intern/cycles/render/bake.h
M source/blender/editors/object/object_bake_api.c
M source/blender/makesdna/DNA_scene_types.h
M source/blender/makesrna/intern/rna_render.c
M source/blender/makesrna/intern/rna_scene.c
M source/blender/render/extern/include/RE_bake.h
M source/blender/render/extern/include/RE_engine.h
M source/blender/render/intern/source/external_engine.c
===================================================================
diff --git a/intern/cycles/blender/addon/__init__.py b/intern/cycles/blender/addon/__init__.py
index 0783c1c..89ad8ab 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, custom_flag, object_id, pixel_array, num_pixels, depth, result):
+ engine.bake(self, obj, pass_type, custom_flag, 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 030f0db..e706dfa 100644
--- a/intern/cycles/blender/addon/engine.py
+++ b/intern/cycles/blender/addon/engine.py
@@ -105,11 +105,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, custom_flag, 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, custom_flag, 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 cbd1a8b..f8721a9 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -486,6 +486,7 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
description="Type of pass to bake",
items=(
('COMBINED', "Combined", ""),
+ ('CUSTOM', "Custom", ""),
('AO', "Ambient Occlusion", ""),
('SHADOW', "Shadow", ""),
('NORMAL', "Normal", ""),
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index e2aa266..5a08b51 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -1438,6 +1438,41 @@ class CyclesRender_PT_bake(CyclesButtonsPanel, Panel):
row.prop(cbk, "normal_g", text="")
row.prop(cbk, "normal_b", text="")
+ elif cscene.bake_type == 'CUSTOM':
+ split = layout.split()
+
+ col = split.column()
+ col.label(text="Diffuse:")
+ row = col.row(align=True)
+ row.prop(cbk, "use_pass_diffuse_direct", text="Direct", toggle=True)
+ row.prop(cbk, "use_pass_diffuse_indirect", text="Indirect", toggle=True)
+ row.prop(cbk, "use_pass_diffuse_color", text="Color", toggle=True)
+ col.label(text="Glossy:")
+ row = col.row(align=True)
+ row.prop(cbk, "use_pass_glossy_direct", text="Direct", toggle=True)
+ row.prop(cbk, "use_pass_glossy_indirect", text="Indirect", toggle=True)
+ row.prop(cbk, "use_pass_glossy_color", text="Color", toggle=True)
+
+ col.separator()
+ col.prop(cbk, "use_pass_shadow")
+ col.prop(cbk, "use_pass_ambient_occlusion")
+
+ col = split.column()
+ col.label(text="Transmission:")
+ row = col.row(align=True)
+ row.prop(cbk, "use_pass_transmission_direct", text="Direct", toggle=True)
+ row.prop(cbk, "use_pass_transmission_indirect", text="Indirect", toggle=True)
+ row.prop(cbk, "use_pass_transmission_color", text="Color", toggle=True)
+ col.label(text="Subsurface:")
+ row = col.row(align=True)
+ row.prop(cbk, "use_pass_subsurface_direct", text="Direct", toggle=True)
+ row.prop(cbk, "use_pass_subsurface_indirect", text="Indirect", toggle=True)
+ row.prop(cbk, "use_pass_subsurface_color", text="Color", toggle=True)
+
+ col.separator()
+ col.prop(cbk, "use_pass_emit", text="Emission")
+ col.prop(cbk, "use_pass_environment")
+
class CyclesParticle_PT_CurveSettings(CyclesButtonsPanel, Panel):
bl_label = "Cycles Hair Settings"
diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp
index 6581d0b..e2812f4 100644
--- a/intern/cycles/blender/blender_python.cpp
+++ b/intern/cycles/blender/blender_python.cpp
@@ -190,9 +190,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, custom_flag;
- 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, &custom_flag, &object_id, &pypixel_array, &num_pixels, &depth, &pyresult))
return NULL;
BlenderSession *session = (BlenderSession*)PyLong_AsVoidPtr(pysession);
@@ -209,7 +209,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, custom_flag, 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 088748c..513f0be 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -271,6 +271,7 @@ static PassType get_pass_type(BL::RenderPass b_pass)
case BL::RenderPass::type_REFRACTION:
case BL::RenderPass::type_SPECULAR:
case BL::RenderPass::type_REFLECTION:
+ case BL::RenderPass::type_CUSTOM:
return PASS_NONE;
#ifdef WITH_CYCLES_DEBUG
case BL::RenderPass::type_DEBUG:
@@ -336,6 +337,8 @@ static ShaderEvalType get_shader_type(const string& pass_type)
/* extra */
else if(strcmp(shader_type, "ENVIRONMENT")==0)
return SHADER_EVAL_ENVIRONMENT;
+ else if(strcmp(shader_type, "CUSTOM")==0)
+ return SHADER_EVAL_CUSTOM;
else
return SHADER_EVAL_BAKE;
@@ -543,11 +546,49 @@ 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_custom_flag_get(const int custom_flag)
+{
+ int flag = PASS_NONE;
+
+ if((custom_flag & BL::RenderPass::type_DIFFUSE_DIRECT) != 0)
+ flag |= PASS_DIFFUSE_DIRECT;
+ if((custom_flag & BL::RenderPass::type_DIFFUSE_INDIRECT) != 0)
+ flag |= PASS_DIFFUSE_INDIRECT;
+ if((custom_flag & BL::RenderPass::type_DIFFUSE_COLOR) != 0)
+ flag |= PASS_DIFFUSE_COLOR;
+
+ if((custom_flag & BL::RenderPass::type_GLOSSY_DIRECT) != 0)
+ flag |= PASS_GLOSSY_DIRECT;
+ if((custom_flag & BL::RenderPass::type_GLOSSY_INDIRECT) != 0)
+ flag |= PASS_GLOSSY_INDIRECT;
+ if((custom_flag & BL::RenderPass::type_GLOSSY_COLOR) != 0)
+ flag |= PASS_GLOSSY_COLOR;
+
+ if((custom_flag & BL::RenderPass::type_TRANSMISSION_DIRECT) != 0)
+ flag |= PASS_TRANSMISSION_DIRECT;
+ if((custom_flag & BL::RenderPass::type_TRANSMISSION_INDIRECT) != 0)
+ flag |= PASS_TRANSMISSION_INDIRECT;
+ if((custom_flag & BL::RenderPass::type_TRANSMISSION_COLOR) != 0)
+ flag |= PASS_TRANSMISSION_COLOR;
+
+ if((custom_flag & BL::RenderPass::type_EMIT) != 0)
+ flag |= PASS_EMISSION;
+ if((custom_flag & BL::RenderPass::type_ENVIRONMENT) != 0)
+ flag |= PASS_BACKGROUND;
+ if((custom_flag & BL::RenderPass::type_AO) != 0)
+ flag |= PASS_AO;
+ if((custom_flag & BL::RenderPass::type_SHADOW) != 0)
+ flag |= PASS_SHADOW;
+
+ return flag;
+}
+
+void BlenderSession::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 result[])
{
ShaderEvalType shader_type = get_shader_type(pass_type);
size_t object_index = OBJECT_NONE;
int tri_offset = 0;
+ int bake_custom_flag = bake_custom_flag_get(custom_flag);
/* Set baking flag in advance, so kernel loading can check if we need
* any baking capabilities.
@@ -565,7 +606,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_custom_flag)) {
/* force use_light_pass to be true */
Pass::add(PASS_LIGHT, scene->film->passes);
}
@@ -617,7 +658,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_custom_flag, 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 708776d..ed860dd 100644
--- a/intern/cycles/blender/blender_session.h
+++ b/intern/cycles/blender/blender_session.h
@@ -52,7 +52,7 @@ 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_
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list