[Bf-blender-cvs] [a028575] master: Compositor: Allow using debug pass output in the compositor

Sergey Sharybin noreply at git.blender.org
Fri Jul 24 15:52:38 CEST 2015


Commit: a028575c4a613b5d87ec26434f8c846c60861cfe
Author: Sergey Sharybin
Date:   Fri Jul 24 12:56:05 2015 +0200
Branches: master
https://developer.blender.org/rBa028575c4a613b5d87ec26434f8c846c60861cfe

Compositor: Allow using debug pass output in the compositor

Currently only works correct with single float output, RGBA and vector are not
supported so if one need to use this passes he'll need to wait a bit still.

It is coming, don't worry.

===================================================================

M	source/blender/blenkernel/BKE_node.h
M	source/blender/compositor/CMakeLists.txt
M	source/blender/compositor/SConscript
M	source/blender/compositor/nodes/COM_RenderLayersNode.cpp
M	source/blender/compositor/operations/COM_RenderLayersProg.cpp
M	source/blender/compositor/operations/COM_RenderLayersProg.h
M	source/blender/nodes/CMakeLists.txt
M	source/blender/nodes/SConscript
M	source/blender/nodes/composite/nodes/node_composite_image.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 0a6c21c..583db20 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -849,6 +849,7 @@ void            ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMateria
 #define RRES_OUT_SUBSURFACE_DIRECT		28
 #define RRES_OUT_SUBSURFACE_INDIRECT	29
 #define RRES_OUT_SUBSURFACE_COLOR		30
+#define RRES_OUT_DEBUG				31
 
 /* note: types are needed to restore callbacks, don't change values */
 #define CMP_NODE_VIEWER		201
diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt
index 7a8c559..972db6b 100644
--- a/source/blender/compositor/CMakeLists.txt
+++ b/source/blender/compositor/CMakeLists.txt
@@ -551,4 +551,8 @@ data_to_c(${CMAKE_CURRENT_SOURCE_DIR}/operations/COM_OpenCLKernels.cl
 
 add_definitions(-DCL_USE_DEPRECATED_OPENCL_1_1_APIS)
 
+if(WITH_CYCLES AND WITH_CYCLES_DEBUG)
+	add_definitions(-DWITH_CYCLES_DEBUG)
+endif()
+
 blender_add_lib(bf_compositor "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/compositor/SConscript b/source/blender/compositor/SConscript
index 370600a..b3fe494 100644
--- a/source/blender/compositor/SConscript
+++ b/source/blender/compositor/SConscript
@@ -59,6 +59,9 @@ incs = [
 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
     incs.append(env['BF_PTHREADS_INC'])
 
+if env['WITH_BF_CYCLES'] and env['WITH_BF_CYCLES_DEBUG']:
+    defs.append('WITH_CYCLES_DEBUG')
+
 if False: # gives link errors 'win' in env['OURPLATFORM']:
     # split into 3 modules to work around command length limit on Windows
     env.BlenderLib('bf_composite_intern', sources_intern, incs, defines=defs, libtype=['core'], priority=[166])
diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
index 02bf1ec..69d2bf8 100644
--- a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
+++ b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
@@ -86,4 +86,8 @@ void RenderLayersNode::convertToOperations(NodeConverter &converter, const Compo
 	testSocketLink(converter, context, 28, new RenderLayersCyclesOperation(SCE_PASS_SUBSURFACE_DIRECT));
 	testSocketLink(converter, context, 29, new RenderLayersCyclesOperation(SCE_PASS_SUBSURFACE_INDIRECT));
 	testSocketLink(converter, context, 30, new RenderLayersCyclesOperation(SCE_PASS_SUBSURFACE_COLOR));
+
+#ifdef WITH_CYCLES_DEBUG
+	testSocketLink(converter, context, 31, new RenderLayersCyclesDebugOperation(SCE_PASS_DEBUG));
+#endif
 }
diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.cpp b/source/blender/compositor/operations/COM_RenderLayersProg.cpp
index af176a7..ad0ce3a 100644
--- a/source/blender/compositor/operations/COM_RenderLayersProg.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersProg.cpp
@@ -388,3 +388,11 @@ RenderLayersUVOperation::RenderLayersUVOperation() : RenderLayersBaseProg(SCE_PA
 {
 	this->addOutputSocket(COM_DT_VECTOR);
 }
+
+/* ******** Debug Render Layers Cycles Operation ******** */
+
+RenderLayersCyclesDebugOperation::RenderLayersCyclesDebugOperation(int pass)
+    : RenderLayersBaseProg(pass, 1)
+{
+	this->addOutputSocket(COM_DT_VALUE);
+}
diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.h b/source/blender/compositor/operations/COM_RenderLayersProg.h
index 2ddbc96..8930753 100644
--- a/source/blender/compositor/operations/COM_RenderLayersProg.h
+++ b/source/blender/compositor/operations/COM_RenderLayersProg.h
@@ -213,4 +213,9 @@ public:
 	RenderLayersUVOperation();
 };
 
+class RenderLayersCyclesDebugOperation : public RenderLayersBaseProg {
+public:
+	RenderLayersCyclesDebugOperation(int pass);
+};
+
 #endif
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index 3fd1241..13dede8 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -288,4 +288,8 @@ if(WITH_FREESTYLE)
 	add_definitions(-DWITH_FREESTYLE)
 endif()
 
+if(WITH_CYCLES AND WITH_CYCLES_DEBUG)
+	add_definitions(-DWITH_CYCLES_DEBUG)
+endif()
+
 blender_add_lib(bf_nodes "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/nodes/SConscript b/source/blender/nodes/SConscript
index aed8463..9c2cc82 100644
--- a/source/blender/nodes/SConscript
+++ b/source/blender/nodes/SConscript
@@ -75,6 +75,9 @@ if env['WITH_BF_COMPOSITOR']:
 if env['WITH_BF_FREESTYLE']:
     defs.append('WITH_FREESTYLE')
 
+if env['WITH_BF_CYCLES'] and env['WITH_BF_CYCLES_DEBUG']:
+    defs.append('WITH_CYCLES_DEBUG')
+
 env.BlenderLib ( libname = 'bf_nodes', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [190,105] )
 env.BlenderLib ( libname = 'bf_cmpnodes', sources = cmpsources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [175,101] )
 env.BlenderLib ( libname = 'bf_shdnodes', sources = shdsources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [175,101] )
diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c
index 19e9344..1985037 100644
--- a/source/blender/nodes/composite/nodes/node_composite_image.c
+++ b/source/blender/nodes/composite/nodes/node_composite_image.c
@@ -73,6 +73,9 @@ static bNodeSocketTemplate cmp_node_rlayers_out[] = {
 	{	SOCK_RGBA, 0, N_("Subsurface Direct"),		0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
 	{	SOCK_RGBA, 0, N_("Subsurface Indirect"),	0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
 	{	SOCK_RGBA, 0, N_("Subsurface Color"),		0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+#ifdef WITH_CYCLES_DEBUG
+	{	SOCK_FLOAT, 0, N_("Debug"),		0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+#endif
 	{	-1, 0, ""	}
 };
 
@@ -160,6 +163,10 @@ static void cmp_node_image_add_render_pass_outputs(bNodeTree *ntree, bNode *node
 		cmp_node_image_add_render_pass_output(ntree, node, SCE_PASS_SUBSURFACE_INDIRECT, RRES_OUT_SUBSURFACE_INDIRECT);
 	if (passflag & SCE_PASS_SUBSURFACE_COLOR)
 		cmp_node_image_add_render_pass_output(ntree, node, SCE_PASS_SUBSURFACE_COLOR, RRES_OUT_SUBSURFACE_COLOR);
+
+#ifdef WITH_CYCLES_DEBUG
+	cmp_node_image_add_render_pass_output(ntree, node, SCE_PASS_DEBUG, RRES_OUT_DEBUG);
+#endif
 }
 
 static void cmp_node_image_add_multilayer_outputs(bNodeTree *ntree, bNode *node, RenderLayer *rl)
@@ -380,8 +387,12 @@ void register_node_type_cmp_image(void)
 static void set_output_visible(bNode *node, int passflag, int index, int pass)
 {
 	bNodeSocket *sock = BLI_findlink(&node->outputs, index);
+	bool pass_enabled = ((passflag & pass) != 0);
+#ifdef WITH_CYCLES_DEBUG
+	pass_enabled |= (pass == SCE_PASS_DEBUG);
+#endif
 	/* clear the SOCK_HIDDEN flag as well, in case a socket was hidden before */
-	if (passflag & pass)
+	if (pass_enabled)
 		sock->flag &= ~(SOCK_HIDDEN | SOCK_UNAVAIL);
 	else
 		sock->flag |= SOCK_UNAVAIL;
@@ -440,6 +451,10 @@ void node_cmp_rlayers_force_hidden_passes(bNode *node)
 	set_output_visible(node, passflag, RRES_OUT_SUBSURFACE_DIRECT,      SCE_PASS_SUBSURFACE_DIRECT);
 	set_output_visible(node, passflag, RRES_OUT_SUBSURFACE_INDIRECT,    SCE_PASS_SUBSURFACE_INDIRECT);
 	set_output_visible(node, passflag, RRES_OUT_SUBSURFACE_COLOR,       SCE_PASS_SUBSURFACE_COLOR);
+
+#ifdef WITH_CYCLES_DEBUG
+	set_output_visible(node, passflag, RRES_OUT_DEBUG,                  SCE_PASS_DEBUG);
+#endif
 }
 
 static void node_composit_init_rlayers(const bContext *C, PointerRNA *ptr)




More information about the Bf-blender-cvs mailing list