From a028575c4a613b5d87ec26434f8c846c60861cfe Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 24 Jul 2015 12:56:05 +0200 Subject: 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. --- source/blender/blenkernel/BKE_node.h | 1 + source/blender/compositor/CMakeLists.txt | 4 ++++ source/blender/compositor/SConscript | 3 +++ .../blender/compositor/nodes/COM_RenderLayersNode.cpp | 4 ++++ .../compositor/operations/COM_RenderLayersProg.cpp | 8 ++++++++ .../compositor/operations/COM_RenderLayersProg.h | 5 +++++ source/blender/nodes/CMakeLists.txt | 4 ++++ source/blender/nodes/SConscript | 3 +++ .../nodes/composite/nodes/node_composite_image.c | 17 ++++++++++++++++- 9 files changed, 48 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 0a6c21c2c60..583db20501d 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 7a8c5596a57..972db6b71d2 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 370600a594e..b3fe494a25c 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 02bf1ec8cfb..69d2bf86531 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 af176a766ff..ad0ce3a6fc7 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 2ddbc968c01..8930753d7a3 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 3fd1241f3fa..13dede8877a 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 aed846355c3..9c2cc825f14 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 19e93447608..1985037c5ce 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) -- cgit v1.2.3