diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2012-01-24 20:32:31 +0400 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2012-01-24 20:32:31 +0400 |
commit | 335ffb0ff3df6ee52f525448d09ae6448b75e158 (patch) | |
tree | 460fc93c618d05f0585405c61dcc5152ee906798 /source | |
parent | 1f9e25ac1a7851ab2503b88564c0d480b9e125cf (diff) |
Brightness/Contrast Node for Cycles
Contrast helps to adjust IBL (HDR images used for background lighting).
Note: In the UI we are caling it Bright instead of Brightness. This copy what Blender composite is doing.
Note2: the algorithm we are using produces pure black when contrast is 100. I'm not a fan of that, but it's a division by zero. I would like to look at other algorithms (what gimp does for example). But that would be only after 2.62.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_node.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_nodetree_types.h | 1 | ||||
-rw-r--r-- | source/blender/nodes/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/nodes/NOD_shader.h | 1 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_brightness.c | 60 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_gamma.c | 5 |
7 files changed, 65 insertions, 5 deletions
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 67de699c7c4..2fa587e168a 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -523,6 +523,7 @@ struct ShadeResult; #define SH_NODE_VOLUME_ISOTROPIC 162 #define SH_NODE_GAMMA 163 #define SH_NODE_TEX_CHECKER 164 +#define SH_NODE_BRIGHTCONTRAST 165 /* custom defines options for Material node */ #define SH_NODE_MAT_DIFF 1 diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 96ee2bd0349..b72abcd79f4 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1881,6 +1881,7 @@ static void registerShaderNodes(bNodeTreeType *ttype) register_node_type_sh_material(ttype); register_node_type_sh_camera(ttype); register_node_type_sh_gamma(ttype); + register_node_type_sh_brightcontrast(ttype); register_node_type_sh_value(ttype); register_node_type_sh_rgb(ttype); register_node_type_sh_mix_rgb(ttype); diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h index 5ab907c87dc..2284b09e941 100644 --- a/source/blender/makesrna/intern/rna_nodetree_types.h +++ b/source/blender/makesrna/intern/rna_nodetree_types.h @@ -41,6 +41,7 @@ DefNode( ShaderNode, SH_NODE_RGBTOBW, 0, "RGBTO DefNode( ShaderNode, SH_NODE_TEXTURE, def_texture, "TEXTURE", Texture, "Texture", "" ) DefNode( ShaderNode, SH_NODE_NORMAL, 0, "NORMAL", Normal, "Normal", "" ) DefNode( ShaderNode, SH_NODE_GAMMA, 0, "GAMMA", Gamma, "Gamma", "" ) +DefNode( ShaderNode, SH_NODE_BRIGHTCONTRAST, 0, "BRIGHTCONTRAST", BrightContrast, "Bright Contrast", "" ) DefNode( ShaderNode, SH_NODE_GEOMETRY, def_sh_geometry, "GEOMETRY", Geometry, "Geometry", "" ) DefNode( ShaderNode, SH_NODE_MAPPING, def_sh_mapping, "MAPPING", Mapping, "Mapping", "" ) DefNode( ShaderNode, SH_NODE_CURVE_VEC, def_vector_curve, "CURVE_VEC", VectorCurve, "Vector Curve", "" ) diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 6d5c282d308..b458ae3a77d 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -115,6 +115,7 @@ set(SRC shader/nodes/node_shader_curves.c shader/nodes/node_shader_dynamic.c shader/nodes/node_shader_gamma.c + shader/nodes/node_shader_brightness.c shader/nodes/node_shader_geom.c shader/nodes/node_shader_hueSatVal.c shader/nodes/node_shader_invert.c diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h index 907efd76786..63fc0f4232c 100644 --- a/source/blender/nodes/NOD_shader.h +++ b/source/blender/nodes/NOD_shader.h @@ -55,6 +55,7 @@ void register_node_type_sh_rgbtobw(struct bNodeTreeType *ttype); void register_node_type_sh_texture(struct bNodeTreeType *ttype); void register_node_type_sh_normal(struct bNodeTreeType *ttype); void register_node_type_sh_gamma(struct bNodeTreeType *ttype); +void register_node_type_sh_brightcontrast(struct bNodeTreeType *ttype); void register_node_type_sh_geom(struct bNodeTreeType *ttype); void register_node_type_sh_mapping(struct bNodeTreeType *ttype); void register_node_type_sh_curve_vec(struct bNodeTreeType *ttype); diff --git a/source/blender/nodes/shader/nodes/node_shader_brightness.c b/source/blender/nodes/shader/nodes/node_shader_brightness.c new file mode 100644 index 00000000000..7448a0b3bab --- /dev/null +++ b/source/blender/nodes/shader/nodes/node_shader_brightness.c @@ -0,0 +1,60 @@ +/* + * ***** 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) 2006 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + +*/ + +#include "node_shader_util.h" + + +/* **************** Brigh and contrsast ******************** */ + +static bNodeSocketTemplate sh_node_brightcontrast_in[]= { + { SOCK_RGBA, 1, "Color", 1.0f, 1.0f, 1.0f, 1.0f}, + { SOCK_FLOAT, 1, "Bright", 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE}, + { SOCK_FLOAT, 1, "Contrast", 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE}, + { -1, 0, "" } +}; + +static bNodeSocketTemplate sh_node_brightcontrast_out[]= { + { SOCK_RGBA, 0, "Color"}, + { -1, 0, "" } +}; + +void register_node_type_sh_brightcontrast(bNodeTreeType *ttype) +{ + static bNodeType ntype; + + node_type_base(ttype, &ntype, SH_NODE_BRIGHTCONTRAST, "Bright/Contrast", NODE_CLASS_OP_COLOR, NODE_OPTIONS); + node_type_compatibility(&ntype, NODE_NEW_SHADING); + node_type_socket_templates(&ntype, sh_node_brightcontrast_in, sh_node_brightcontrast_out); + node_type_size(&ntype, 140, 100, 320); + node_type_init(&ntype, NULL); + node_type_storage(&ntype, "", NULL, NULL); + node_type_exec(&ntype, NULL); + node_type_gpu(&ntype, NULL); + + nodeRegisterType(ttype, &ntype); +} diff --git a/source/blender/nodes/shader/nodes/node_shader_gamma.c b/source/blender/nodes/shader/nodes/node_shader_gamma.c index 1d525d71698..e2907f5ba91 100644 --- a/source/blender/nodes/shader/nodes/node_shader_gamma.c +++ b/source/blender/nodes/shader/nodes/node_shader_gamma.c @@ -26,11 +26,6 @@ */ -/** \file blender/nodes/composite/nodes/node_composite_gamma.c - * \ingroup cmpnodes - */ - - #include "node_shader_util.h" /* **************** Gamma Tools ******************** */ |