From d523d27e621f92c2fd9cb53f9dbbb62750bacc2c Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Thu, 13 Jun 2013 08:55:51 +0000 Subject: Cycles / Blackbody node: * First step towards a Blackbody to RGB converter. You can specify a color in Kelvin inside the node. * Only implemented for OSL atm, SVM will follow. --- source/blender/nodes/CMakeLists.txt | 1 + source/blender/nodes/NOD_shader.h | 1 + source/blender/nodes/NOD_static_types.h | 1 + .../nodes/shader/nodes/node_shader_blackbody.c | 54 ++++++++++++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 source/blender/nodes/shader/nodes/node_shader_blackbody.c (limited to 'source/blender/nodes') diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index cc1a5f8cee9..4b7ee2aed51 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -146,6 +146,7 @@ set(SRC shader/nodes/node_shader_value.c shader/nodes/node_shader_wireframe.c shader/nodes/node_shader_wavelength.c + shader/nodes/node_shader_blackbody.c shader/nodes/node_shader_vectMath.c shader/nodes/node_shader_add_shader.c shader/nodes/node_shader_ambient_occlusion.c diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h index edb0ba6f475..a56d78af309 100644 --- a/source/blender/nodes/NOD_shader.h +++ b/source/blender/nodes/NOD_shader.h @@ -81,6 +81,7 @@ void register_node_type_sh_object_info(void); void register_node_type_sh_fresnel(void); void register_node_type_sh_wireframe(void); void register_node_type_sh_wavelength(void); +void register_node_type_sh_blackbody(void); void register_node_type_sh_layer_weight(void); void register_node_type_sh_tex_coord(void); void register_node_type_sh_particle_info(void); diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h index 8e3896f40f7..6d950d2a469 100644 --- a/source/blender/nodes/NOD_static_types.h +++ b/source/blender/nodes/NOD_static_types.h @@ -97,6 +97,7 @@ DefNode( ShaderNode, SH_NODE_PARTICLE_INFO, 0, "PA DefNode( ShaderNode, SH_NODE_HAIR_INFO, 0, "HAIR_INFO", HairInfo, "Hair Info", "" ) DefNode( ShaderNode, SH_NODE_WIREFRAME, def_sh_tex_wireframe, "WIREFRAME", Wireframe, "Wireframe", "" ) DefNode( ShaderNode, SH_NODE_WAVELENGTH, 0, "WAVELENGTH", Wavelength, "Wavelength", "" ) +DefNode( ShaderNode, SH_NODE_BLACKBODY, 0, "BLACKBODY", Blackbody, "Blackbody", "" ) DefNode( ShaderNode, SH_NODE_BUMP, def_sh_bump, "BUMP", Bump, "Bump", "" ) DefNode( ShaderNode, SH_NODE_NORMAL_MAP, def_sh_normal_map, "NORMAL_MAP", NormalMap, "Normal Map", "" ) DefNode( ShaderNode, SH_NODE_TANGENT, def_sh_tangent, "TANGENT", Tangent, "Tangent", "" ) diff --git a/source/blender/nodes/shader/nodes/node_shader_blackbody.c b/source/blender/nodes/shader/nodes/node_shader_blackbody.c new file mode 100644 index 00000000000..0a59032778a --- /dev/null +++ b/source/blender/nodes/shader/nodes/node_shader_blackbody.c @@ -0,0 +1,54 @@ +/* + * ***** 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) 2005 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" + +/* **************** Blackbody ******************** */ +static bNodeSocketTemplate sh_node_blackbody_in[] = { + { SOCK_FLOAT, 1, N_("Temperature"), 1200.0f, 0.0f, 0.0f, 0.0f, 1.0f, 10000.0f}, + { -1, 0, "" } +}; + +static bNodeSocketTemplate sh_node_blackbody_out[] = { + { SOCK_RGBA, 0, N_("Color")}, + { -1, 0, "" } +}; + +/* node type definition */ +void register_node_type_sh_blackbody(void) +{ + static bNodeType ntype; + + sh_node_type_base(&ntype, SH_NODE_BLACKBODY, "Blackbody", NODE_CLASS_CONVERTOR, 0); + node_type_compatibility(&ntype, NODE_NEW_SHADING); + node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + node_type_socket_templates(&ntype, sh_node_blackbody_in, sh_node_blackbody_out); + node_type_init(&ntype, NULL); + node_type_storage(&ntype, "", NULL, NULL); + + nodeRegisterType(&ntype); +} -- cgit v1.2.3 From 9e16c5a9e429e0d00801a4dd6ee71a8fbf6691f0 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sat, 15 Jun 2013 23:47:09 +0000 Subject: Cycles / Blackbody node: * First (brute force) implementation for SVM. This works and delivers the same result as OSL, but it's slow. * Code inside svm_blackbody.h inspired by a patch by Philipp Oeser (#35698), thanks. Ideas: * Use a lookup table to perform the calculations on render/ level. * Implement it as a RNA property only, and do the calculation like Sun/Sky precompute. --- source/blender/nodes/shader/nodes/node_shader_blackbody.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/nodes') diff --git a/source/blender/nodes/shader/nodes/node_shader_blackbody.c b/source/blender/nodes/shader/nodes/node_shader_blackbody.c index 0a59032778a..af89a959554 100644 --- a/source/blender/nodes/shader/nodes/node_shader_blackbody.c +++ b/source/blender/nodes/shader/nodes/node_shader_blackbody.c @@ -29,7 +29,7 @@ /* **************** Blackbody ******************** */ static bNodeSocketTemplate sh_node_blackbody_in[] = { - { SOCK_FLOAT, 1, N_("Temperature"), 1200.0f, 0.0f, 0.0f, 0.0f, 1.0f, 10000.0f}, + { SOCK_FLOAT, 1, N_("Temperature"), 1500.0f, 0.0f, 0.0f, 0.0f, 800.0f, 12000.0f}, { -1, 0, "" } }; -- cgit v1.2.3 From 370ebad2f9d0b0d01dc989dac6dca9ba63bc5bf2 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Thu, 20 Jun 2013 08:20:30 +0000 Subject: Cycles / Vector Transform Node: * First step towards a new vector transform node, to convert Points/Vectors between World/Object/Camera space. This only contains the Blender UI, RNA... code, no Cycles integration yet. --- source/blender/nodes/CMakeLists.txt | 1 + source/blender/nodes/NOD_shader.h | 1 + source/blender/nodes/NOD_static_types.h | 1 + .../nodes/shader/nodes/node_shader_vectTransform.c | 66 ++++++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 source/blender/nodes/shader/nodes/node_shader_vectTransform.c (limited to 'source/blender/nodes') diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 4b7ee2aed51..3241f98ad1e 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -148,6 +148,7 @@ set(SRC shader/nodes/node_shader_wavelength.c shader/nodes/node_shader_blackbody.c shader/nodes/node_shader_vectMath.c + shader/nodes/node_shader_vectTransform.c shader/nodes/node_shader_add_shader.c shader/nodes/node_shader_ambient_occlusion.c shader/nodes/node_shader_attribute.c diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h index a56d78af309..a8c77a9baed 100644 --- a/source/blender/nodes/NOD_shader.h +++ b/source/blender/nodes/NOD_shader.h @@ -89,6 +89,7 @@ void register_node_type_sh_hair_info(void); void register_node_type_sh_script(void); void register_node_type_sh_normal_map(void); void register_node_type_sh_tangent(void); +void register_node_type_sh_vect_transform(void); void register_node_type_sh_ambient_occlusion(void); void register_node_type_sh_background(void); diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h index 6d950d2a469..f94e6fc9f52 100644 --- a/source/blender/nodes/NOD_static_types.h +++ b/source/blender/nodes/NOD_static_types.h @@ -114,6 +114,7 @@ DefNode( ShaderNode, SH_NODE_TEX_VORONOI, def_sh_tex_voronoi, "TE DefNode( ShaderNode, SH_NODE_TEX_CHECKER, def_sh_tex_checker, "TEX_CHECKER", TexChecker, "Checker Texture", "" ) DefNode( ShaderNode, SH_NODE_TEX_BRICK, def_sh_tex_brick, "TEX_BRICK", TexBrick, "Brick Texture", "" ) DefNode( ShaderNode, SH_NODE_TEX_COORD, def_sh_tex_coord, "TEX_COORD", TexCoord, "Texture Coordinate","" ) +DefNode( ShaderNode, SH_NODE_VECT_TRANSFORM, def_sh_vect_transform, "VECT_TRANSFORM", VectorTransform, "Vector Transform", "" ) DefNode( CompositorNode, CMP_NODE_VIEWER, def_cmp_viewer, "VIEWER", Viewer, "Viewer", "" ) DefNode( CompositorNode, CMP_NODE_RGB, 0, "RGB", RGB, "RGB", "" ) diff --git a/source/blender/nodes/shader/nodes/node_shader_vectTransform.c b/source/blender/nodes/shader/nodes/node_shader_vectTransform.c new file mode 100644 index 00000000000..40c70b9e23d --- /dev/null +++ b/source/blender/nodes/shader/nodes/node_shader_vectTransform.c @@ -0,0 +1,66 @@ +/* + * ***** 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) 2013 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/nodes/shader/nodes/node_shader_vectTransform.c + * \ingroup shdnodes + */ + + #include "../node_shader_util.h" + +/* **************** Vector Transform ******************** */ +static bNodeSocketTemplate sh_node_vect_transform_in[] = { + { SOCK_VECTOR, 1, N_("Vector"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, + { -1, 0, "" } +}; + +static bNodeSocketTemplate sh_node_vect_transform_out[] = { + { SOCK_VECTOR, 0, N_("Vector")}, + { -1, 0, "" } +}; + +static void node_shader_init_vect_transform(bNodeTree *UNUSED(ntree), bNode *node) +{ + NodeShaderVectTransform *vect = MEM_callocN(sizeof(NodeShaderVectTransform), "NodeShaderVectTransform"); + + /* Convert World into Object Space per default */ + vect->convert_to = 1; + + node->storage = vect; +} + +void register_node_type_sh_vect_transform(void) +{ + static bNodeType ntype; + + sh_node_type_base(&ntype, SH_NODE_VECT_TRANSFORM, "Vector Transform", NODE_CLASS_CONVERTOR, 0); + node_type_compatibility(&ntype, NODE_NEW_SHADING); + node_type_init(&ntype, node_shader_init_vect_transform); + node_type_socket_templates(&ntype, sh_node_vect_transform_in, sh_node_vect_transform_out); + node_type_storage(&ntype, "NodeShaderVectTransform", node_free_standard_storage, node_copy_standard_storage); + + nodeRegisterType(&ntype); +} -- cgit v1.2.3 From 285ef99931447646b20ec968ec87f7c68939a104 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Wed, 3 Jul 2013 23:46:56 +0000 Subject: Cycles: * Added 2 new nodes to combine and separate HSV colors. Screenshot: http://www.pasteall.org/pic/show.php?id=54828 --- source/blender/nodes/CMakeLists.txt | 1 + source/blender/nodes/NOD_shader.h | 2 + source/blender/nodes/NOD_static_types.h | 2 + .../nodes/shader/nodes/node_shader_sepcombHSV.c | 80 ++++++++++++++++++++++ 4 files changed, 85 insertions(+) create mode 100644 source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c (limited to 'source/blender/nodes') diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 3241f98ad1e..64261246e3d 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -140,6 +140,7 @@ set(SRC shader/nodes/node_shader_output.c shader/nodes/node_shader_rgb.c shader/nodes/node_shader_sepcombRGB.c + shader/nodes/node_shader_sepcombHSV.c shader/nodes/node_shader_squeeze.c shader/nodes/node_shader_texture.c shader/nodes/node_shader_valToRgb.c diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h index a8c77a9baed..ec39d81618d 100644 --- a/source/blender/nodes/NOD_shader.h +++ b/source/blender/nodes/NOD_shader.h @@ -70,6 +70,8 @@ void register_node_type_sh_material_ext(void); void register_node_type_sh_invert(void); void register_node_type_sh_seprgb(void); void register_node_type_sh_combrgb(void); +void register_node_type_sh_sephsv(void); +void register_node_type_sh_combhsv(void); void register_node_type_sh_hue_sat(void); void register_node_type_sh_tex_brick(void); diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h index f94e6fc9f52..05c1330ee85 100644 --- a/source/blender/nodes/NOD_static_types.h +++ b/source/blender/nodes/NOD_static_types.h @@ -115,6 +115,8 @@ DefNode( ShaderNode, SH_NODE_TEX_CHECKER, def_sh_tex_checker, "TE DefNode( ShaderNode, SH_NODE_TEX_BRICK, def_sh_tex_brick, "TEX_BRICK", TexBrick, "Brick Texture", "" ) DefNode( ShaderNode, SH_NODE_TEX_COORD, def_sh_tex_coord, "TEX_COORD", TexCoord, "Texture Coordinate","" ) DefNode( ShaderNode, SH_NODE_VECT_TRANSFORM, def_sh_vect_transform, "VECT_TRANSFORM", VectorTransform, "Vector Transform", "" ) +DefNode( ShaderNode, SH_NODE_SEPHSV, 0, "SEPHSV", SeparateHSV, "Separate HSV", "" ) +DefNode( ShaderNode, SH_NODE_COMBHSV, 0, "COMBHSV", CombineHSV, "Combine HSV", "" ) DefNode( CompositorNode, CMP_NODE_VIEWER, def_cmp_viewer, "VIEWER", Viewer, "Viewer", "" ) DefNode( CompositorNode, CMP_NODE_RGB, 0, "RGB", RGB, "RGB", "" ) diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c b/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c new file mode 100644 index 00000000000..707e295241a --- /dev/null +++ b/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c @@ -0,0 +1,80 @@ +/* + * ***** 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) 2013 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/nodes/shader/nodes/node_shader_sepcombHSV.c + * \ingroup shdnodes + */ + + +#include "node_shader_util.h" + +/* **************** SEPARATE HSV ******************** */ +static bNodeSocketTemplate sh_node_sephsv_in[] = { + { SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f}, + { -1, 0, "" } +}; +static bNodeSocketTemplate sh_node_sephsv_out[] = { + { SOCK_FLOAT, 0, N_("H")}, + { SOCK_FLOAT, 0, N_("S")}, + { SOCK_FLOAT, 0, N_("V")}, + { -1, 0, "" } +}; + +void register_node_type_sh_sephsv(void) +{ + static bNodeType ntype; + + sh_node_type_base(&ntype, SH_NODE_SEPHSV, "Separate HSV", NODE_CLASS_CONVERTOR, 0); + node_type_compatibility(&ntype, NODE_NEW_SHADING); + node_type_socket_templates(&ntype, sh_node_sephsv_in, sh_node_sephsv_out); + + nodeRegisterType(&ntype); +} + + +/* **************** COMBINE HSV ******************** */ +static bNodeSocketTemplate sh_node_combhsv_in[] = { + { SOCK_FLOAT, 1, N_("H"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_UNSIGNED}, + { SOCK_FLOAT, 1, N_("S"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_UNSIGNED}, + { SOCK_FLOAT, 1, N_("V"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_UNSIGNED}, + { -1, 0, "" } +}; +static bNodeSocketTemplate sh_node_combhsv_out[] = { + { SOCK_RGBA, 0, N_("Color")}, + { -1, 0, "" } +}; + +void register_node_type_sh_combhsv(void) +{ + static bNodeType ntype; + + sh_node_type_base(&ntype, SH_NODE_COMBHSV, "Combine HSV", NODE_CLASS_CONVERTOR, 0); + node_type_compatibility(&ntype, NODE_NEW_SHADING); + node_type_socket_templates(&ntype, sh_node_combhsv_in, sh_node_combhsv_out); + + nodeRegisterType(&ntype); +} -- cgit v1.2.3