From e15cdec2d49ee47a85897db9838578a298146513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20T=C3=B6nne?= Date: Sat, 26 Jul 2014 12:59:29 +0200 Subject: New compositor node "Sun Beams" This allows adding a "fake" sun beam effect, simulating crepuscular rays from light being scattered in a medium like the atmosphere or deep water. Such effects can be created also by renderers using volumetric lighting, but the compositor feature is a lot cheaper and is independent from 3D rendering. This makes it ideally suited for motion graphics. The implementation uses am optimized accumulation method for gathering color values along a line segment. The inner buffer loop uses fixed offset increments to avoid unnecessary multiplications and avoids variables by using compile-time specialization (see inline comments for further details). --- source/blender/nodes/CMakeLists.txt | 1 + source/blender/nodes/NOD_composite.h | 2 +- source/blender/nodes/NOD_static_types.h | 1 + .../composite/nodes/node_composite_sunbeams.c | 63 ++++++++++++++++++++++ 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 source/blender/nodes/composite/nodes/node_composite_sunbeams.c (limited to 'source/blender/nodes') diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 6fed0d16848..e09a0892370 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -105,6 +105,7 @@ set(SRC composite/nodes/node_composite_setalpha.c composite/nodes/node_composite_splitViewer.c composite/nodes/node_composite_stabilize2d.c + composite/nodes/node_composite_sunbeams.c composite/nodes/node_composite_texture.c composite/nodes/node_composite_tonemap.c composite/nodes/node_composite_trackpos.c diff --git a/source/blender/nodes/NOD_composite.h b/source/blender/nodes/NOD_composite.h index ad5f35b8faa..961fdbfc0fb 100644 --- a/source/blender/nodes/NOD_composite.h +++ b/source/blender/nodes/NOD_composite.h @@ -125,7 +125,7 @@ void register_node_type_cmp_mask(void); void register_node_type_cmp_glare(void); void register_node_type_cmp_tonemap(void); void register_node_type_cmp_lensdist(void); - +void register_node_type_cmp_sunbeams(void); void register_node_type_cmp_colorcorrection(void); void register_node_type_cmp_boxmask(void); diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h index 8d6c4abaef6..be87abd7b7e 100644 --- a/source/blender/nodes/NOD_static_types.h +++ b/source/blender/nodes/NOD_static_types.h @@ -208,6 +208,7 @@ DefNode( CompositorNode, CMP_NODE_TRACKPOS, def_cmp_trackpos, "TRACK DefNode( CompositorNode, CMP_NODE_PIXELATE, 0, "PIXELATE", Pixelate, "Pixelate", "" ) DefNode( CompositorNode, CMP_NODE_PLANETRACKDEFORM,def_cmp_planetrackdeform,"PLANETRACKDEFORM",PlaneTrackDeform,"Plane Track Deform","" ) DefNode( CompositorNode, CMP_NODE_CORNERPIN, 0, "CORNERPIN", CornerPin, "Corner Pin", "" ) +DefNode( CompositorNode, CMP_NODE_SUNBEAMS, def_cmp_sunbeams, "SUNBEAMS", SunBeams, "Sun Beams", "" ) DefNode( TextureNode, TEX_NODE_OUTPUT, def_tex_output, "OUTPUT", Output, "Output", "" ) DefNode( TextureNode, TEX_NODE_CHECKER, 0, "CHECKER", Checker, "Checker", "" ) diff --git a/source/blender/nodes/composite/nodes/node_composite_sunbeams.c b/source/blender/nodes/composite/nodes/node_composite_sunbeams.c new file mode 100644 index 00000000000..4d937d63b75 --- /dev/null +++ b/source/blender/nodes/composite/nodes/node_composite_sunbeams.c @@ -0,0 +1,63 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2014 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Lukas Toenne + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/nodes/composite/nodes/node_composite_sunbeams.c + * \ingroup cmpnodes + */ + +#include "node_composite_util.h" + +static bNodeSocketTemplate inputs[] = { + { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, + { -1, 0, "" } +}; +static bNodeSocketTemplate outputs[] = { + { SOCK_RGBA, 0, N_("Image")}, + { -1, 0, "" } +}; + +static void init(bNodeTree *UNUSED(ntree), bNode *node) +{ + NodeSunBeams *data = MEM_callocN(sizeof(NodeSunBeams), "sun beams node"); + + data->source[0] = 0.5f; + data->source[1] = 0.5f; + + node->storage = data; +} + +void register_node_type_cmp_sunbeams(void) +{ + static bNodeType ntype; + + cmp_node_type_base(&ntype, CMP_NODE_SUNBEAMS, "Sun Beams", NODE_CLASS_OP_FILTER, 0); + node_type_socket_templates(&ntype, inputs, outputs); + node_type_init(&ntype, init); + node_type_storage(&ntype, "NodeSunBeams", node_free_standard_storage, node_copy_standard_storage); + + nodeRegisterType(&ntype); +} -- cgit v1.2.3