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.
This commit is contained in:
Dalai Felinto
2012-01-24 16:32:31 +00:00
parent 1f9e25ac1a
commit 335ffb0ff3
17 changed files with 224 additions and 6 deletions

View File

@@ -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

View File

@@ -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);

View File

@@ -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", "" )

View File

@@ -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

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -26,11 +26,6 @@
*/
/** \file blender/nodes/composite/nodes/node_composite_gamma.c
* \ingroup cmpnodes
*/
#include "node_shader_util.h"
/* **************** Gamma Tools ******************** */