Cycles: missed these files in merge commit.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Sat, 17 Sep 2011 14:38:56 +0000 (14:38 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Sat, 17 Sep 2011 14:38:56 +0000 (14:38 +0000)
36 files changed:
source/blender/nodes/shader/nodes/node_shader_add_shader.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_attribute.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_background.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_blend_weight.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_emission.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_fresnel.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_geometry.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_holdout.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_light_path.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_mix_shader.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_noise.h [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_output_lamp.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_output_material.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_output_texture.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_output_world.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_tex_blend.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_tex_clouds.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_tex_coord.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_tex_distnoise.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_tex_environment.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_tex_image.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_tex_magic.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_tex_marble.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_tex_noise.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_tex_sky.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_tex_stucci.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c [new file with mode: 0644]
source/blender/nodes/shader/nodes/node_shader_tex_wood.c [new file with mode: 0644]

diff --git a/source/blender/nodes/shader/nodes/node_shader_add_shader.c b/source/blender/nodes/shader/nodes/node_shader_add_shader.c
new file mode 100644 (file)
index 0000000..cc059d3
--- /dev/null
@@ -0,0 +1,69 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_add_shader_in[]= {
+       {       SOCK_SHADER, 1, "Shader1"},
+       {       SOCK_SHADER, 1, "Shader2"},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_add_shader_out[]= {
+       {       SOCK_SHADER, 0, "Shader"},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_exec_add_shader(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
+{
+}
+
+static int node_shader_gpu_add_shader(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       return GPU_stack_link(mat, "node_add_shader", in, out);
+}
+
+/* node type definition */
+void register_node_type_sh_add_shader(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_ADD_SHADER, "Add Shader", NODE_CLASS_SHADER, 0);
+       node_type_socket_templates(&ntype, sh_node_add_shader_in, sh_node_add_shader_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, NULL);
+       node_type_storage(&ntype, "", NULL, NULL);
+       node_type_exec(&ntype, node_shader_exec_add_shader);
+       node_type_gpu(&ntype, node_shader_gpu_add_shader);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_attribute.c b/source/blender/nodes/shader/nodes/node_shader_attribute.c
new file mode 100644 (file)
index 0000000..569a75e
--- /dev/null
@@ -0,0 +1,59 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_attribute_out[]= {
+       {       SOCK_VECTOR, 0, "Vector",               0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_exec_attribute(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
+{
+}
+
+
+/* node type definition */
+void register_node_type_sh_attribute(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_ATTRIBUTE, "Attribute", NODE_CLASS_INPUT, 0);
+       node_type_socket_templates(&ntype, NULL, sh_node_attribute_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, NULL);
+       node_type_storage(&ntype, "", NULL, NULL);
+       node_type_exec(&ntype, node_shader_exec_attribute);
+       node_type_gpu(&ntype, NULL);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_background.c b/source/blender/nodes/shader/nodes/node_shader_background.c
new file mode 100644 (file)
index 0000000..fab2310
--- /dev/null
@@ -0,0 +1,65 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_background_in[]= {
+       {       SOCK_RGBA, 1, "Color",          0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+       {       SOCK_FLOAT, 1, "Strength",      1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000000.0f},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_background_out[]= {
+       {       SOCK_SHADER, 0, "Background"},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_exec_background(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
+{
+}
+
+
+/* node type definition */
+void register_node_type_sh_background(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_BACKGROUND, "Background", NODE_CLASS_SHADER, 0);
+       node_type_socket_templates(&ntype, sh_node_background_in, sh_node_background_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, NULL);
+       node_type_storage(&ntype, "", NULL, NULL);
+       node_type_exec(&ntype, node_shader_exec_background);
+       node_type_gpu(&ntype, NULL);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_blend_weight.c b/source/blender/nodes/shader/nodes/node_shader_blend_weight.c
new file mode 100644 (file)
index 0000000..1affc27
--- /dev/null
@@ -0,0 +1,68 @@
+/**
+ * $Id: node_shader_blend_weight.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+/* **************** BlendWeight ******************** */
+static bNodeSocketTemplate sh_node_blend_weight_in[]= {
+       {       SOCK_FLOAT, 1, "Blend",         0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_blend_weight_out[]= {
+       {       SOCK_FLOAT, 0, "Fresnel",       0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_FLOAT, 0, "Facing",        0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_exec_blend_weight(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
+{
+}
+
+static int node_shader_gpu_blend_weight(GPUMaterial *UNUSED(mat), bNode *UNUSED(node), GPUNodeStack *UNUSED(in), GPUNodeStack *UNUSED(out))
+{
+       return 0;
+}
+
+/* node type definition */
+void register_node_type_sh_blend_weight(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_BLEND_WEIGHT, "Blend Weight", NODE_CLASS_INPUT, 0);
+       node_type_socket_templates(&ntype, sh_node_blend_weight_in, sh_node_blend_weight_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, NULL);
+       node_type_storage(&ntype, "", NULL, NULL);
+       node_type_exec(&ntype, node_shader_exec_blend_weight);
+       node_type_gpu(&ntype, node_shader_gpu_blend_weight);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c
new file mode 100644 (file)
index 0000000..8ee6be6
--- /dev/null
@@ -0,0 +1,70 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_bsdf_anisotropic_in[]= {
+       {       SOCK_RGBA, 1, "Color",                  0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+       {       SOCK_FLOAT, 1, "Roughness U",   0.2f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_FLOAT, 1, "Roughness V",   0.2f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_bsdf_anisotropic_out[]= {
+       {       SOCK_SHADER, 0, "BSDF"},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_exec_bsdf_anisotropic(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
+{
+}
+
+static int node_shader_gpu_bsdf_anisotropic(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       return GPU_stack_link(mat, "node_bsdf_anisotropic", in, out, GPU_builtin(GPU_VIEW_NORMAL), GPU_builtin(GPU_VIEW_POSITION));
+}
+
+/* node type definition */
+void register_node_type_sh_bsdf_anisotropic(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_BSDF_ANISOTROPIC, "Glossy Anisotropic BSDF", NODE_CLASS_SHADER, 0);
+       node_type_socket_templates(&ntype, sh_node_bsdf_anisotropic_in, sh_node_bsdf_anisotropic_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, NULL);
+       node_type_storage(&ntype, "", NULL, NULL);
+       node_type_exec(&ntype, node_shader_exec_bsdf_anisotropic);
+       node_type_gpu(&ntype, node_shader_gpu_bsdf_anisotropic);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c
new file mode 100644 (file)
index 0000000..33f9ab8
--- /dev/null
@@ -0,0 +1,68 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_bsdf_diffuse_in[]= {
+       {       SOCK_RGBA, 1, "Color",          0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_bsdf_diffuse_out[]= {
+       {       SOCK_SHADER, 0, "BSDF"},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_exec_bsdf_diffuse(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
+{
+}
+
+static int node_shader_gpu_bsdf_diffuse(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       return GPU_stack_link(mat, "node_bsdf_diffuse", in, out, GPU_builtin(GPU_VIEW_NORMAL));
+}
+
+/* node type definition */
+void register_node_type_sh_bsdf_diffuse(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_BSDF_DIFFUSE, "Diffuse BSDF", NODE_CLASS_SHADER, 0);
+       node_type_socket_templates(&ntype, sh_node_bsdf_diffuse_in, sh_node_bsdf_diffuse_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, NULL);
+       node_type_storage(&ntype, "", NULL, NULL);
+       node_type_exec(&ntype, node_shader_exec_bsdf_diffuse);
+       node_type_gpu(&ntype, node_shader_gpu_bsdf_diffuse);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c
new file mode 100644 (file)
index 0000000..c7a3de4
--- /dev/null
@@ -0,0 +1,70 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_bsdf_glass_in[]= {
+       {       SOCK_RGBA, 1, "Color",          0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+       {       SOCK_FLOAT, 1, "Roughness",     0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_FLOAT, 1, "IOR",           1.45f, 0.0f, 0.0f, 0.0f, 1.0f, 1000.0f},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_bsdf_glass_out[]= {
+       {       SOCK_SHADER, 0, "BSDF"},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_exec_bsdf_glass(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
+{
+}
+
+static int node_shader_gpu_bsdf_glass(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       return GPU_stack_link(mat, "node_bsdf_glass", in, out, GPU_builtin(GPU_VIEW_NORMAL), GPU_builtin(GPU_VIEW_POSITION));
+}
+
+/* node type definition */
+void register_node_type_sh_bsdf_glass(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_BSDF_GLASS, "Glass BSDF", NODE_CLASS_SHADER, 0);
+       node_type_socket_templates(&ntype, sh_node_bsdf_glass_in, sh_node_bsdf_glass_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, NULL);
+       node_type_storage(&ntype, "", NULL, NULL);
+       node_type_exec(&ntype, node_shader_exec_bsdf_glass);
+       node_type_gpu(&ntype, node_shader_gpu_bsdf_glass);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
new file mode 100644 (file)
index 0000000..879ef0d
--- /dev/null
@@ -0,0 +1,70 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_bsdf_glossy_in[]= {
+       {       SOCK_RGBA,  1, "Color",         0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+       {       SOCK_FLOAT, 1, "Roughness",     0.2f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_bsdf_glossy_out[]= {
+       {       SOCK_SHADER, 0, "BSDF"},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_exec_bsdf_glossy(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
+{
+}
+
+static int node_shader_gpu_bsdf_glossy(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       /* todo: is incoming vector normalized? */
+       return GPU_stack_link(mat, "node_bsdf_glossy", in, out, GPU_builtin(GPU_VIEW_NORMAL), GPU_builtin(GPU_VIEW_POSITION));
+}
+
+/* node type definition */
+void register_node_type_sh_bsdf_glossy(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_BSDF_GLOSSY, "Glossy BSDF", NODE_CLASS_SHADER, 0);
+       node_type_socket_templates(&ntype, sh_node_bsdf_glossy_in, sh_node_bsdf_glossy_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, NULL);
+       node_type_storage(&ntype, "", NULL, NULL);
+       node_type_exec(&ntype, node_shader_exec_bsdf_glossy);
+       node_type_gpu(&ntype, node_shader_gpu_bsdf_glossy);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c
new file mode 100644 (file)
index 0000000..6f02f28
--- /dev/null
@@ -0,0 +1,68 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_bsdf_translucent_in[]= {
+       {       SOCK_RGBA, 1, "Color",          0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_bsdf_translucent_out[]= {
+       {       SOCK_SHADER, 0, "BSDF"},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_exec_bsdf_translucent(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
+{
+}
+
+static int node_shader_gpu_bsdf_translucent(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       return GPU_stack_link(mat, "node_bsdf_translucent", in, out, GPU_builtin(GPU_VIEW_NORMAL));
+}
+
+/* node type definition */
+void register_node_type_sh_bsdf_translucent(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_BSDF_TRANSLUCENT, "Translucent BSDF", NODE_CLASS_SHADER, 0);
+       node_type_socket_templates(&ntype, sh_node_bsdf_translucent_in, sh_node_bsdf_translucent_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, NULL);
+       node_type_storage(&ntype, "", NULL, NULL);
+       node_type_exec(&ntype, node_shader_exec_bsdf_translucent);
+       node_type_gpu(&ntype, node_shader_gpu_bsdf_translucent);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c
new file mode 100644 (file)
index 0000000..49e131b
--- /dev/null
@@ -0,0 +1,68 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_bsdf_transparent_in[]= {
+       {       SOCK_RGBA, 1, "Color",          1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_bsdf_transparent_out[]= {
+       {       SOCK_SHADER, 0, "BSDF"},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_exec_bsdf_transparent(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
+{
+}
+
+static int node_shader_gpu_bsdf_transparent(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       return GPU_stack_link(mat, "node_bsdf_transparent", in, out);
+}
+
+/* node type definition */
+void register_node_type_sh_bsdf_transparent(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_BSDF_TRANSPARENT, "Transparent BSDF", NODE_CLASS_SHADER, 0);
+       node_type_socket_templates(&ntype, sh_node_bsdf_transparent_in, sh_node_bsdf_transparent_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, NULL);
+       node_type_storage(&ntype, "", NULL, NULL);
+       node_type_exec(&ntype, node_shader_exec_bsdf_transparent);
+       node_type_gpu(&ntype, node_shader_gpu_bsdf_transparent);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c
new file mode 100644 (file)
index 0000000..49c783d
--- /dev/null
@@ -0,0 +1,69 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_bsdf_velvet_in[]= {
+       {       SOCK_RGBA, 1, "Color",          0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+       {       SOCK_FLOAT, 1, "Sigma",         1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_bsdf_velvet_out[]= {
+       {       SOCK_SHADER, 0, "BSDF"},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_exec_bsdf_velvet(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
+{
+}
+
+static int node_shader_gpu_bsdf_velvet(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       return GPU_stack_link(mat, "node_bsdf_velvet", in, out, GPU_builtin(GPU_VIEW_NORMAL));
+}
+
+/* node type definition */
+void register_node_type_sh_bsdf_velvet(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_BSDF_VELVET, "Velvet BSDF", NODE_CLASS_SHADER, 0);
+       node_type_socket_templates(&ntype, sh_node_bsdf_velvet_in, sh_node_bsdf_velvet_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, NULL);
+       node_type_storage(&ntype, "", NULL, NULL);
+       node_type_exec(&ntype, node_shader_exec_bsdf_velvet);
+       node_type_gpu(&ntype, node_shader_gpu_bsdf_velvet);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_emission.c b/source/blender/nodes/shader/nodes/node_shader_emission.c
new file mode 100644 (file)
index 0000000..d57c5b6
--- /dev/null
@@ -0,0 +1,69 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_emission_in[]= {
+       {       SOCK_RGBA, 1, "Color",          0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+       {       SOCK_FLOAT, 1, "Strength",      30.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000000.0f},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_emission_out[]= {
+       {       SOCK_SHADER, 0, "Emission"},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_exec_emission(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
+{
+}
+
+static int node_shader_gpu_emission(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       return GPU_stack_link(mat, "node_emission", in, out, GPU_builtin(GPU_VIEW_NORMAL));
+}
+
+/* node type definition */
+void register_node_type_sh_emission(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_EMISSION, "Emission", NODE_CLASS_SHADER, 0);
+       node_type_socket_templates(&ntype, sh_node_emission_in, sh_node_emission_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, NULL);
+       node_type_storage(&ntype, "", NULL, NULL);
+       node_type_exec(&ntype, node_shader_exec_emission);
+       node_type_gpu(&ntype, node_shader_gpu_emission);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_fresnel.c b/source/blender/nodes/shader/nodes/node_shader_fresnel.c
new file mode 100644 (file)
index 0000000..c918d84
--- /dev/null
@@ -0,0 +1,68 @@
+/**
+ * $Id: node_shader_fresnel.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+/* **************** Fresnel ******************** */
+static bNodeSocketTemplate sh_node_fresnel_in[]= {
+       {       SOCK_FLOAT, 1, "IOR",   1.45f, 0.0f, 0.0f, 0.0f, 1.0f, 1000.0f},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_fresnel_out[]= {
+       {       SOCK_FLOAT, 0, "Fac",   0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_exec_fresnel(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
+{
+}
+
+static int node_shader_gpu_fresnel(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       /* todo: is incoming vector normalized? */
+       return GPU_stack_link(mat, "node_fresnel", in, out, GPU_builtin(GPU_VIEW_NORMAL), GPU_builtin(GPU_VIEW_POSITION));
+}
+
+/* node type definition */
+void register_node_type_sh_fresnel(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_FRESNEL, "Fresnel", NODE_CLASS_INPUT, 0);
+       node_type_socket_templates(&ntype, sh_node_fresnel_in, sh_node_fresnel_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, NULL);
+       node_type_storage(&ntype, "", NULL, NULL);
+       node_type_exec(&ntype, node_shader_exec_fresnel);
+       node_type_gpu(&ntype, node_shader_gpu_fresnel);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_geometry.c b/source/blender/nodes/shader/nodes/node_shader_geometry.c
new file mode 100644 (file)
index 0000000..73ec0b2
--- /dev/null
@@ -0,0 +1,71 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_geometry_out[]= {
+       {       SOCK_VECTOR, 0, "Position",                     0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_VECTOR, 0, "Normal",                       0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_VECTOR, 0, "Tangent",                      0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_VECTOR, 0, "True Normal",          0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_VECTOR, 0, "Incoming",                     0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_VECTOR, 0, "Parametric",           0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_FLOAT,  0, "Backfacing",           0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_exec_geometry(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
+{
+}
+
+static int node_shader_gpu_geometry(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       return GPU_stack_link(mat, "node_geometry", in, out,
+               GPU_builtin(GPU_VIEW_POSITION), GPU_builtin(GPU_VIEW_NORMAL),
+               GPU_builtin(GPU_INVERSE_VIEW_MATRIX));
+}
+
+/* node type definition */
+void register_node_type_sh_geometry(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_GEOMETRY, "Geometry", NODE_CLASS_INPUT, 0);
+       node_type_socket_templates(&ntype, NULL, sh_node_geometry_out);
+       node_type_size(&ntype, 120, 60, 200);
+       node_type_init(&ntype, NULL);
+       node_type_storage(&ntype, "", NULL, NULL);
+       node_type_exec(&ntype, node_shader_exec_geometry);
+       node_type_gpu(&ntype, node_shader_gpu_geometry);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_holdout.c b/source/blender/nodes/shader/nodes/node_shader_holdout.c
new file mode 100644 (file)
index 0000000..1f376c4
--- /dev/null
@@ -0,0 +1,63 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_holdout_in[]= {
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_holdout_out[]= {
+       {       SOCK_SHADER, 0, "Holdout"},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_exec_holdout(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
+{
+}
+
+
+/* node type definition */
+void register_node_type_sh_holdout(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_HOLDOUT, "Holdout", NODE_CLASS_SHADER, 0);
+       node_type_socket_templates(&ntype, sh_node_holdout_in, sh_node_holdout_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, NULL);
+       node_type_storage(&ntype, "", NULL, NULL);
+       node_type_exec(&ntype, node_shader_exec_holdout);
+       node_type_gpu(&ntype, NULL);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_light_path.c b/source/blender/nodes/shader/nodes/node_shader_light_path.c
new file mode 100644 (file)
index 0000000..a811259
--- /dev/null
@@ -0,0 +1,69 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_light_path_out[]= {
+       {       SOCK_FLOAT, 0, "Is Camera Ray",                 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_FLOAT, 0, "Is Shadow Ray",                 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_FLOAT, 0, "Is Diffuse Ray",                0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_FLOAT, 0, "Is Glossy Ray",                 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_FLOAT, 0, "Is Singular Ray",               0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_FLOAT, 0, "Is Reflection Ray",             0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_FLOAT, 0, "Is Transmission Ray",   0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_exec_light_path(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
+{
+}
+
+static int node_shader_gpu_light_path(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       return GPU_stack_link(mat, "node_light_path", in, out);
+}
+
+/* node type definition */
+void register_node_type_sh_light_path(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_LIGHT_PATH, "Light Path", NODE_CLASS_INPUT, 0);
+       node_type_socket_templates(&ntype, NULL, sh_node_light_path_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, NULL);
+       node_type_storage(&ntype, "", NULL, NULL);
+       node_type_exec(&ntype, node_shader_exec_light_path);
+       node_type_gpu(&ntype, node_shader_gpu_light_path);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_mix_shader.c b/source/blender/nodes/shader/nodes/node_shader_mix_shader.c
new file mode 100644 (file)
index 0000000..637f515
--- /dev/null
@@ -0,0 +1,70 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_mix_shader_in[]= {
+       {       SOCK_FLOAT,  1, "Fac",          0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_SHADER, 1, "Shader1"},
+       {       SOCK_SHADER, 1, "Shader2"},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_mix_shader_out[]= {
+       {       SOCK_SHADER, 0, "Shader"},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_exec_mix_shader(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
+{
+}
+
+static int node_shader_gpu_mix_shader(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       return GPU_stack_link(mat, "node_mix_shader", in, out);
+}
+
+/* node type definition */
+void register_node_type_sh_mix_shader(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_MIX_SHADER, "Mix Shader", NODE_CLASS_SHADER, 0);
+       node_type_socket_templates(&ntype, sh_node_mix_shader_in, sh_node_mix_shader_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, NULL);
+       node_type_storage(&ntype, "", NULL, NULL);
+       node_type_exec(&ntype, node_shader_exec_mix_shader);
+       node_type_gpu(&ntype, node_shader_gpu_mix_shader);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_noise.h b/source/blender/nodes/shader/nodes/node_shader_noise.h
new file mode 100644 (file)
index 0000000..44aa8f6
--- /dev/null
@@ -0,0 +1,472 @@
+/*
+ * Adapted from Open Shading Language with this license:
+ *
+ * Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al.
+ * All Rights Reserved.
+ *
+ * Modifications Copyright 2011, Blender Foundation.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of Sony Pictures Imageworks nor the names of its
+ *   contributors may be used to endorse or promote products derived from
+ *   this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef NODE_SHADER_NOISE_H
+#define NODE_SHADER_NOISE_H
+
+MINLINE int quick_floor(float x)
+{
+       return (int)x - ((x < 0) ? 1 : 0);
+}
+
+MINLINE float bits_to_01(unsigned int bits)
+{
+       return bits * (1.0f/(float)0xFFFFFFFF);
+}
+
+MINLINE unsigned int hash(unsigned int kx, unsigned int ky, unsigned int kz)
+{
+       // define some handy macros
+#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
+#define final(a,b,c) \
+{ \
+       c ^= b; c -= rot(b,14); \
+       a ^= c; a -= rot(c,11); \
+       b ^= a; b -= rot(a,25); \
+       c ^= b; c -= rot(b,16); \
+       a ^= c; a -= rot(c,4);  \
+       b ^= a; b -= rot(a,14); \
+       c ^= b; c -= rot(b,24); \
+}
+       // now hash the data!
+       unsigned int a, b, c, len = 3;
+       a = b = c = 0xdeadbeef + (len << 2) + 13;
+
+       c += kz;
+       b += ky;
+       a += kx;
+       final(a, b, c);
+
+       return c;
+       // macros not needed anymore
+#undef rot
+#undef final
+}
+
+MINLINE int imod(int a, int b)
+{
+       a %= b;
+       return a < 0 ? a + b : a;
+}
+
+MINLINE unsigned int phash(int kx, int ky, int kz, int p[3]) 
+{
+       return hash(imod(kx, p[0]), imod(ky, p[1]), imod(kz, p[2]));
+}
+
+MINLINE float floorfrac(float x, int* i)
+{
+    *i = quick_floor(x);
+    return x - *i;
+}
+
+MINLINE float fade(float t)
+{
+       return t * t * t * (t * (t * 6.0f - 15.0f) + 10.0f);
+}
+
+MINLINE float nerp(float t, float a, float b)
+{
+    return (1.0f - t) * a + t * b;
+}
+
+MINLINE float grad(int hash, float x, float y, float z)
+{
+       // use vectors pointing to the edges of the cube
+       int h = hash & 15;
+       float u = h<8 ? x : y;
+       float v = h<4 ? y : h==12||h==14 ? x : z;
+       return ((h&1) ? -u : u) + ((h&2) ? -v : v);
+}
+
+MINLINE float scale3(float result)
+{
+       return 0.9820f * result;
+}
+
+MINLINE float perlin(float x, float y, float z)
+{
+       int X; float fx = floorfrac(x, &X);
+       int Y; float fy = floorfrac(y, &Y);
+       int Z; float fz = floorfrac(z, &Z);
+
+       float u = fade(fx);
+       float v = fade(fy);
+       float w = fade(fz);
+
+       float result;
+
+       result = nerp (w, nerp (v, nerp (u, grad (hash (X  , Y  , Z  ), fx       , fy    , fz     ),
+                                                                               grad (hash (X+1, Y  , Z  ), fx-1.0f, fy  , fz     )),
+                                                          nerp (u, grad (hash (X  , Y+1, Z  ), fx       , fy-1.0f, fz    ),
+                                                                               grad (hash (X+1, Y+1, Z  ), fx-1.0f, fy-1.0f, fz          ))),
+                                         nerp (v, nerp (u, grad (hash (X  , Y  , Z+1), fx       , fy    , fz-1.0f ),
+                                                                               grad (hash (X+1, Y  , Z+1), fx-1.0f, fy  , fz-1.0f )),
+                                                          nerp (u, grad (hash (X  , Y+1, Z+1), fx       , fy-1.0f, fz-1.0f ),
+                                                                               grad (hash (X+1, Y+1, Z+1), fx-1.0f, fy-1.0f, fz-1.0f ))));
+       return scale3(result);
+}
+
+MINLINE float perlin_periodic(float x, float y, float z, float pperiod[3])
+{
+       int X; float fx = floorfrac(x, &X);
+       int Y; float fy = floorfrac(y, &Y);
+       int Z; float fz = floorfrac(z, &Z);
+
+       int p[3] = {
+               MAX2(quick_floor(pperiod[0]), 1),
+               MAX2(quick_floor(pperiod[1]), 1),
+               MAX2(quick_floor(pperiod[2]), 1)};
+
+       float u = fade(fx);
+       float v = fade(fy);
+       float w = fade(fz);
+
+       float result;
+
+       result = nerp (w, nerp (v, nerp (u, grad (phash (X  , Y  , Z  , p), fx   , fy    , fz     ),
+                                                                               grad (phash (X+1, Y  , Z  , p), fx-1.0f, fy      , fz     )),
+                                                          nerp (u, grad (phash (X  , Y+1, Z  , p), fx   , fy-1.0f, fz    ),
+                                                                               grad (phash (X+1, Y+1, Z  , p), fx-1.0f, fy-1.0f, fz      ))),
+                                         nerp (v, nerp (u, grad (phash (X  , Y  , Z+1, p), fx   , fy    , fz-1.0f ),
+                                                                               grad (phash (X+1, Y  , Z+1, p), fx-1.0f, fy      , fz-1.0f )),
+                                                          nerp (u, grad (phash (X  , Y+1, Z+1, p), fx   , fy-1.0f, fz-1.0f ),
+                                                                               grad (phash (X+1, Y+1, Z+1, p), fx-1.0f, fy-1.0f, fz-1.0f ))));
+       return scale3(result);
+}
+
+/* perlin noise in range 0..1 */
+MINLINE float noise(float p[3])
+{
+       float r = perlin(p[0], p[1], p[2]);
+       return 0.5f*r + 0.5f;
+}
+
+/* perlin noise in range -1..1 */
+MINLINE float snoise(float p[3])
+{
+       return perlin(p[0], p[1], p[2]);
+}
+
+/* cell noise */
+MINLINE float cellnoise(float p[3])
+{
+       unsigned int ix = quick_floor(p[0]);
+       unsigned int iy = quick_floor(p[1]);
+       unsigned int iz = quick_floor(p[2]);
+
+       return bits_to_01(hash(ix, iy, iz));
+}
+
+MINLINE void cellnoise_color(float rgb[3], float p[3])
+{
+       float pg[3] = {p[1], p[0], p[2]};
+       float pb[3] = {p[1], p[2], p[0]};
+
+       float r = cellnoise(p);
+       float g = cellnoise(pg);
+       float b = cellnoise(pb);
+
+       rgb[0]= r;
+       rgb[1]= g;
+       rgb[2]= b;
+}
+
+/* periodic perlin noise in range 0..1 */
+MINLINE float pnoise(float p[3], float pperiod[3])
+{
+       float r = perlin_periodic(p[0], p[1], p[2], pperiod);
+       return 0.5f*r + 0.5f;
+}
+
+/* periodic perlin noise in range -1..1 */
+MINLINE float psnoise(float p[3], float pperiod[3])
+{
+       return perlin_periodic(p[0], p[1], p[2], pperiod);
+}
+
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * 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.
+ */
+
+/* turbulence */
+MINLINE float turbulence(float p[3], int oct, int hard)
+{
+       float amp = 1.0f, fscale = 1.0f, sum = 0.0f;
+       int i;
+
+       for(i=0; i<=oct; i++, amp *= 0.5f, fscale *= 2.0f) {
+               float pscale[3] = {fscale*p[0], fscale*p[1], fscale*p[2]};
+               float t = noise(pscale);
+               if(hard) t = fabsf(2.0f*t - 1.0f);
+               sum += t * amp;
+       }
+
+       sum *= ((float)(1<<oct)/(float)((1<<(oct+1))-1));
+
+       return sum;
+}
+
+/* Voronoi Distances */
+
+MINLINE float voronoi_distance(int distance_metric, float d[3], float e)
+{
+       if(distance_metric == SHD_VORONOI_DISTANCE_SQUARED)
+               return dot_v3v3(d, d);
+       if(distance_metric == SHD_VORONOI_ACTUAL_DISTANCE)
+               return len_v3(d);
+       if(distance_metric == SHD_VORONOI_MANHATTAN)
+               return fabsf(d[0]) + fabsf(d[1]) + fabsf(d[2]);
+       if(distance_metric == SHD_VORONOI_CHEBYCHEV)
+               return MAX2(fabsf(d[0]), MAX2(fabsf(d[1]), fabsf(d[2])));
+       if(distance_metric == SHD_VORONOI_MINKOVSKY_H)
+               return sqrtf(fabsf(d[0])) + sqrtf(fabsf(d[1])) + sqrtf(fabsf(d[1]));
+       if(distance_metric == SHD_VORONOI_MINKOVSKY_4) {
+               float dsq[3] = {d[0]*d[0], d[1]*d[1], d[2]*d[2]};
+               return sqrtf(sqrtf(dot_v3v3(dsq, dsq)));
+       }
+       if(distance_metric == SHD_VORONOI_MINKOVSKY)
+               return powf(powf(fabsf(d[0]), e) + powf(fabsf(d[1]), e) + powf(fabsf(d[2]), e), 1.0f/e);
+       
+       return 0.0f;
+}
+
+/* Voronoi / Worley like */
+
+MINLINE void voronoi_generic(float p[3], int distance_metric, float e, float da[4], float pa[4][3])
+{
+       /* returns distances in da and point coords in pa */
+       int xx, yy, zz, xi, yi, zi;
+
+       xi = (int)floorf(p[0]);
+       yi = (int)floorf(p[1]);
+       zi = (int)floorf(p[2]);
+
+       da[0] = 1e10f;
+       da[1] = 1e10f;
+       da[2] = 1e10f;
+       da[3] = 1e10f;
+
+       zero_v3(pa[0]);
+       zero_v3(pa[1]);
+       zero_v3(pa[2]);
+       zero_v3(pa[3]);
+
+       for(xx = xi-1; xx <= xi+1; xx++) {
+               for(yy = yi-1; yy <= yi+1; yy++) {
+                       for(zz = zi-1; zz <= zi+1; zz++) {
+                               float ip[3] = {(float)xx, (float)yy, (float)zz};
+                               float vp[3], pd[3], d;
+
+                               cellnoise_color(vp, ip);
+                               add_v3_v3v3(pd, vp, ip);
+                               sub_v3_v3v3(pd, p, pd);
+
+                               d = voronoi_distance(distance_metric, pd, e);
+
+                               add_v3_v3(vp, ip);
+
+                               if(d < da[0]) {
+                                       da[3] = da[2];
+                                       da[2] = da[1];
+                                       da[1] = da[0];
+                                       da[0] = d;
+
+                                       copy_v3_v3(pa[3], pa[2]);
+                                       copy_v3_v3(pa[2], pa[1]);
+                                       copy_v3_v3(pa[1], pa[0]);
+                                       copy_v3_v3(pa[0], vp);
+                               }
+                               else if(d < da[1]) {
+                                       da[3] = da[2];
+                                       da[2] = da[1];
+                                       da[1] = d;
+
+                                       copy_v3_v3(pa[3], pa[2]);
+                                       copy_v3_v3(pa[2], pa[1]);
+                                       copy_v3_v3(pa[1], vp);
+                               }
+                               else if(d < da[2]) {
+                                       da[3] = da[2];
+                                       da[2] = d;
+
+                                       copy_v3_v3(pa[3], pa[2]);
+                                       copy_v3_v3(pa[2], vp);
+                               }
+                               else if(d < da[3]) {
+                                       da[3] = d;
+                                       copy_v3_v3(pa[3], vp);
+                               }
+                       }
+               }
+       }
+}
+
+MINLINE float voronoi_Fn(float p[3], int n)
+{
+       float da[4];
+       float pa[4][3];
+
+       voronoi_generic(p, SHD_VORONOI_DISTANCE_SQUARED, 0, da, pa);
+
+       return da[n];
+}
+
+MINLINE float voronoi_FnFn(float p[3], int n1, int n2)
+{
+       float da[4];
+       float pa[4][3];
+
+       voronoi_generic(p, SHD_VORONOI_DISTANCE_SQUARED, 0, da, pa);
+
+       return da[n2] - da[n1];
+}
+
+MINLINE float voronoi_F1(float p[3]) { return voronoi_Fn(p, 0); }
+MINLINE float voronoi_F2(float p[3]) { return voronoi_Fn(p, 1); }
+MINLINE float voronoi_F3(float p[3]) { return voronoi_Fn(p, 2); }
+MINLINE float voronoi_F4(float p[3]) { return voronoi_Fn(p, 3); }
+MINLINE float voronoi_F1F2(float p[3]) { return voronoi_FnFn(p, 0, 1); }
+
+MINLINE float voronoi_Cr(float p[3])
+{
+       /* crackle type pattern, just a scale/clamp of F2-F1 */
+       float t = 10.0f*voronoi_F1F2(p);
+       return (t > 1.0f)? 1.0f: t;
+}
+
+MINLINE float voronoi_F1S(float p[3]) { return 2.0f*voronoi_F1(p) - 1.0f; }
+MINLINE float voronoi_F2S(float p[3]) { return 2.0f*voronoi_F2(p) - 1.0f; }
+MINLINE float voronoi_F3S(float p[3]) { return 2.0f*voronoi_F3(p) - 1.0f; }
+MINLINE float voronoi_F4S(float p[3]) { return 2.0f*voronoi_F4(p) - 1.0f; }
+MINLINE float voronoi_F1F2S(float p[3]) { return 2.0f*voronoi_F1F2(p) - 1.0f; }
+MINLINE float voronoi_CrS(float p[3]) { return 2.0f*voronoi_Cr(p) - 1.0f; }
+
+/* Noise Bases */
+
+MINLINE float noise_basis(float p[3], int basis)
+{
+       if(basis == SHD_NOISE_PERLIN)
+               return noise(p);
+       if(basis == SHD_NOISE_VORONOI_F1)
+               return voronoi_F1S(p);
+       if(basis == SHD_NOISE_VORONOI_F2)
+               return voronoi_F2S(p);
+       if(basis == SHD_NOISE_VORONOI_F3)
+               return voronoi_F3S(p);
+       if(basis == SHD_NOISE_VORONOI_F4)
+               return voronoi_F4S(p);
+       if(basis == SHD_NOISE_VORONOI_F2_F1)
+               return voronoi_F1F2S(p);
+       if(basis == SHD_NOISE_VORONOI_CRACKLE)
+               return voronoi_CrS(p);
+       if(basis == SHD_NOISE_CELL_NOISE)
+               return cellnoise(p);
+       
+       return 0.0f;
+}
+
+/* Soft/Hard Noise */
+
+MINLINE float noise_basis_hard(float p[3], int basis, int hard)
+{
+       float t = noise_basis(p, basis);
+       return (hard)? fabsf(2.0f*t - 1.0f): t;
+}
+
+/* Waves */
+
+MINLINE float noise_wave(int wave, float a)
+{
+       if(wave == SHD_WAVE_SINE) {
+       return 0.5f + 0.5f*sin(a);
+       }
+       else if(wave == SHD_WAVE_SAW) {
+               float b = 2*M_PI;
+               int n = (int)(a / b);
+               a -= n*b;
+               if(a < 0) a += b;
+
+               return a / b;
+       }
+       else if(wave == SHD_WAVE_TRI) {
+               float b = 2*M_PI;
+               float rmax = 1.0f;
+
+               return rmax - 2.0f*fabsf(floorf((a*(1.0f/b))+0.5f) - (a*(1.0f/b)));
+       }
+
+       return 0.0f;
+}
+
+/* Turbulence */
+
+MINLINE float noise_turbulence(float p[3], int basis, int octaves, int hard)
+{
+       float fscale = 1.0f;
+       float amp = 1.0f;
+       float sum = 0.0f;
+       int i;
+
+       for(i = 0; i <= octaves; i++) {
+               float pscale[3] = {fscale*p[0], fscale*p[1], fscale*p[2]};
+               float t = noise_basis(pscale, basis);
+
+               if(hard)
+                       t = fabsf(2.0f*t - 1.0f);
+
+               sum += t*amp;
+               amp *= 0.5f;
+               fscale *= 2.0f;
+       }
+
+       sum *= ((float)(1 << octaves)/(float)((1 << (octaves+1)) - 1));
+
+       return sum;
+}
+
+#endif /* NODE_SHADER_NOISE_H */
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_output_lamp.c b/source/blender/nodes/shader/nodes/node_shader_output_lamp.c
new file mode 100644 (file)
index 0000000..0199217
--- /dev/null
@@ -0,0 +1,58 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_output_lamp_in[]= {
+       {       SOCK_SHADER, 1, "Surface",              0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_exec_output_lamp(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
+{
+}
+
+/* node type definition */
+void register_node_type_sh_output_lamp(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_OUTPUT_LAMP, "Lamp Output", NODE_CLASS_OUTPUT, 0);
+       node_type_socket_templates(&ntype, sh_node_output_lamp_in, NULL);
+       node_type_size(&ntype, 120, 60, 200);
+       node_type_init(&ntype, NULL);
+       node_type_storage(&ntype, "", NULL, NULL);
+       node_type_exec(&ntype, node_shader_exec_output_lamp);
+       node_type_gpu(&ntype, NULL);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_output_material.c b/source/blender/nodes/shader/nodes/node_shader_output_material.c
new file mode 100644 (file)
index 0000000..a78d685
--- /dev/null
@@ -0,0 +1,71 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_output_material_in[]= {
+       {       SOCK_SHADER, 1, "Surface"},
+       {       SOCK_SHADER, 1, "Volume"},
+       {       SOCK_FLOAT, 1, "Displacement",  0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_exec_output_material(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
+{
+}
+
+static int node_shader_gpu_output_material(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       GPUNodeLink *outlink;
+
+       GPU_stack_link(mat, "node_output_material", in, out, &outlink);
+       GPU_material_output_link(mat, outlink);
+
+       return 1;
+}
+
+
+/* node type definition */
+void register_node_type_sh_output_material(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_OUTPUT_MATERIAL, "Material Output", NODE_CLASS_OUTPUT, 0);
+       node_type_socket_templates(&ntype, sh_node_output_material_in, NULL);
+       node_type_size(&ntype, 120, 60, 200);
+       node_type_init(&ntype, NULL);
+       node_type_storage(&ntype, "", NULL, NULL);
+       node_type_exec(&ntype, node_shader_exec_output_material);
+       node_type_gpu(&ntype, node_shader_gpu_output_material);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_output_texture.c b/source/blender/nodes/shader/nodes/node_shader_output_texture.c
new file mode 100644 (file)
index 0000000..ad37746
--- /dev/null
@@ -0,0 +1,75 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_output_texture_in[]= {
+       {       SOCK_RGBA, 1, "Color",          0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_exec_output_texture(void *data, bNode *node, bNodeStack **in, bNodeStack **UNUSED(out))
+{
+       if(data && (node->flag & NODE_DO_OUTPUT)) {
+               ShaderCallData *scd= (ShaderCallData*)data;
+               TexResult *texres = scd->texres;
+               float col[4];
+
+               if(!texres)
+                       return;
+               
+               nodestack_get_vec(col, SOCK_RGBA, in[0]);
+
+               texres->tr= col[0];
+               texres->tg= col[1];
+               texres->tb= col[2];
+               texres->ta= 1.0f;
+
+               texres->tin= rgb_to_grayscale(col);
+       }
+}
+
+/* node type definition */
+void register_node_type_sh_output_texture(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_OUTPUT_TEXTURE, "Texture Output", NODE_CLASS_OUTPUT, 0);
+       node_type_socket_templates(&ntype, sh_node_output_texture_in, NULL);
+       node_type_size(&ntype, 120, 60, 200);
+       node_type_init(&ntype, NULL);
+       node_type_storage(&ntype, "", NULL, NULL);
+       node_type_exec(&ntype, node_shader_exec_output_texture);
+       node_type_gpu(&ntype, NULL);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_output_world.c b/source/blender/nodes/shader/nodes/node_shader_output_world.c
new file mode 100644 (file)
index 0000000..ee8c1f8
--- /dev/null
@@ -0,0 +1,59 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_output_world_in[]= {
+       {       SOCK_SHADER, 1, "Surface",              0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_SHADER, 1, "Volume",               0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_exec_output_world(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
+{
+}
+
+/* node type definition */
+void register_node_type_sh_output_world(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_OUTPUT_WORLD, "World Output", NODE_CLASS_OUTPUT, 0);
+       node_type_socket_templates(&ntype, sh_node_output_world_in, NULL);
+       node_type_size(&ntype, 120, 60, 200);
+       node_type_init(&ntype, NULL);
+       node_type_storage(&ntype, "", NULL, NULL);
+       node_type_exec(&ntype, node_shader_exec_output_world);
+       node_type_gpu(&ntype, NULL);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_blend.c b/source/blender/nodes/shader/nodes/node_shader_tex_blend.c
new file mode 100644 (file)
index 0000000..a42da33
--- /dev/null
@@ -0,0 +1,135 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+static float blend(float p[3], int type, int axis)
+{
+       float x, y;
+
+       if(axis == SHD_BLEND_VERTICAL) {
+               x= p[1];
+               y= p[0];
+       }
+       else {
+               x= p[0];
+               y= p[1];
+       }
+
+       if(type == SHD_BLEND_LINEAR) {
+               return (1.0f + x)/2.0f;
+       }
+       else if(type == SHD_BLEND_QUADRATIC) {
+               float r = MAX2((1.0f + x)/2.0f, 0.0f);
+               return r*r;
+       }
+       else if(type == SHD_BLEND_EASING) {
+               float r = MIN2(MAX2((1.0f + x)/2.0f, 0.0f), 1.0f);
+               float t = r*r;
+               
+               return (3.0f*t - 2.0f*t*r);
+       }
+       else if(type == SHD_BLEND_DIAGONAL) {
+               return (2.0f + x + y)/4.0f;
+       }
+       else if(type == SHD_BLEND_RADIAL) {
+               return atan2(y, x)/(2.0f*(float)M_PI) + 0.5f;
+       }
+       else {
+               float r = MAX2(1.0f - sqrtf(x*x + y*y + p[2]*p[2]), 0.0f);
+
+               if(type == SHD_BLEND_QUADRATIC_SPHERE)
+                       return r*r;
+               else if(type == SHD_BLEND_SPHERICAL)
+                       return r;
+       }
+
+       return 0.0f;
+}
+
+/* **************** BLEND ******************** */
+
+static bNodeSocketTemplate sh_node_tex_blend_in[]= {
+       {       SOCK_VECTOR, 1, "Vector",               0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_tex_blend_out[]= {
+       {       SOCK_FLOAT, 0, "Fac",           0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_init_tex_blend(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+{
+       NodeTexBlend *tex = MEM_callocN(sizeof(NodeTexBlend), "NodeTexBlend");
+       tex->progression = SHD_BLEND_LINEAR;
+       tex->axis = SHD_BLEND_HORIZONTAL;
+
+       node->storage = tex;
+}
+
+static void node_shader_exec_tex_blend(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       ShaderCallData *scd= (ShaderCallData*)data;
+       NodeTexBlend *tex= (NodeTexBlend*)node->storage;
+       bNodeSocket *vecsock = node->inputs.first;
+       float vec[3];
+       
+       if(vecsock->link)
+               nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
+       else
+               copy_v3_v3(vec, scd->co);
+       
+       out[0]->vec[0]= blend(vec, tex->progression, tex->axis);
+}
+
+static int node_shader_gpu_tex_blend(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       if(!in[0].link)
+               in[0].link = GPU_attribute(CD_ORCO, "");
+
+       return GPU_stack_link(mat, "node_tex_blend", in, out);
+}
+
+/* node type definition */
+void register_node_type_sh_tex_blend(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_TEX_BLEND, "Blend Texture", NODE_CLASS_TEXTURE, 0);
+       node_type_socket_templates(&ntype, sh_node_tex_blend_in, sh_node_tex_blend_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, node_shader_init_tex_blend);
+       node_type_storage(&ntype, "NodeTexBlend", node_free_standard_storage, node_copy_standard_storage);
+       node_type_exec(&ntype, node_shader_exec_tex_blend);
+       node_type_gpu(&ntype, node_shader_gpu_tex_blend);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_clouds.c b/source/blender/nodes/shader/nodes/node_shader_tex_clouds.c
new file mode 100644 (file)
index 0000000..e140a58
--- /dev/null
@@ -0,0 +1,118 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+#include "node_shader_noise.h"
+
+static float clouds(int basis, int hard, int depth, float size, float vec[3], float color[3])
+{
+       float p[3], pg[3], pb[3];
+
+       mul_v3_v3fl(p, vec, 1.0f/size);
+
+       pg[0]= p[1];
+       pg[1]= p[0];
+       pg[2]= p[2];
+
+       pb[0]= p[1];
+       pb[1]= p[2];
+       pb[2]= p[0];
+
+       color[0]= noise_turbulence(p, basis, depth, hard);
+       color[1]= noise_turbulence(pg, basis, depth, hard);
+       color[2]= noise_turbulence(pb, basis, depth, hard);
+
+       return color[0];
+}
+
+/* **************** CLOUDS ******************** */
+
+static bNodeSocketTemplate sh_node_tex_clouds_in[]= {
+       {       SOCK_VECTOR, 1, "Vector",               0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
+       {       SOCK_FLOAT, 1, "Size",                  0.25f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_tex_clouds_out[]= {
+       {       SOCK_RGBA, 0, "Color",          0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_FLOAT, 0, "Fac",           0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_init_tex_clouds(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+{
+       NodeTexClouds *tex = MEM_callocN(sizeof(NodeTexClouds), "NodeTexClouds");
+       tex->basis = SHD_NOISE_PERLIN;
+       tex->hard = 0;
+       tex->depth = 2;
+
+       node->storage = tex;
+}
+
+static void node_shader_exec_tex_clouds(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       ShaderCallData *scd= (ShaderCallData*)data;
+       NodeTexClouds *tex= (NodeTexClouds*)node->storage;
+       bNodeSocket *vecsock = node->inputs.first;
+       float vec[3], size;
+       
+       if(vecsock->link)
+               nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
+       else
+               copy_v3_v3(vec, scd->co);
+
+       nodestack_get_vec(&size, SOCK_FLOAT, in[1]);
+
+       out[1]->vec[0]= clouds(tex->basis, tex->hard, tex->depth, size, vec, out[0]->vec);
+}
+
+static int node_shader_gpu_tex_clouds(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       if(!in[0].link)
+               in[0].link = GPU_attribute(CD_ORCO, "");
+
+       return GPU_stack_link(mat, "node_tex_clouds", in, out);
+}
+
+/* node type definition */
+void register_node_type_sh_tex_clouds(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_TEX_CLOUDS, "Clouds Texture", NODE_CLASS_TEXTURE, 0);
+       node_type_socket_templates(&ntype, sh_node_tex_clouds_in, sh_node_tex_clouds_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, node_shader_init_tex_clouds);
+       node_type_storage(&ntype, "NodeTexClouds", node_free_standard_storage, node_copy_standard_storage);
+       node_type_exec(&ntype, node_shader_exec_tex_clouds);
+       node_type_gpu(&ntype, node_shader_gpu_tex_clouds);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_coord.c b/source/blender/nodes/shader/nodes/node_shader_tex_coord.c
new file mode 100644 (file)
index 0000000..5fdde7e
--- /dev/null
@@ -0,0 +1,75 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+#include "DNA_customdata_types.h"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_tex_coord_out[]= {
+       {       SOCK_VECTOR, 0, "Generated",            0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_VECTOR, 0, "UV",                           0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_VECTOR, 0, "Object",                       0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_VECTOR, 0, "Camera",                       0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_VECTOR, 0, "Window",                       0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_VECTOR, 0, "Reflection",           0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_exec_tex_coord(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
+{
+}
+
+static int node_shader_gpu_tex_coord(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       GPUNodeLink *orco = GPU_attribute(CD_ORCO, "");
+       GPUNodeLink *mtface = GPU_attribute(CD_MTFACE, "");
+
+       return GPU_stack_link(mat, "node_tex_coord", in, out,
+               GPU_builtin(GPU_VIEW_POSITION), GPU_builtin(GPU_VIEW_NORMAL),
+               GPU_builtin(GPU_INVERSE_VIEW_MATRIX), orco, mtface);
+}
+
+/* node type definition */
+void register_node_type_sh_tex_coord(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_TEX_COORD, "Texture Coordinate", NODE_CLASS_INPUT, 0);
+       node_type_socket_templates(&ntype, NULL, sh_node_tex_coord_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, NULL);
+       node_type_storage(&ntype, "", NULL, NULL);
+       node_type_exec(&ntype, node_shader_exec_tex_coord);
+       node_type_gpu(&ntype, node_shader_gpu_tex_coord);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_distnoise.c b/source/blender/nodes/shader/nodes/node_shader_tex_distnoise.c
new file mode 100644 (file)
index 0000000..f91e6ee
--- /dev/null
@@ -0,0 +1,115 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+#include "node_shader_noise.h"
+
+static float distorted_noise(float vec[3], float size, int basis, int distortion_basis, float distortion)
+{
+       float p[3], r[3], p_offset[3], p_noffset[3];
+       float offset[3] = {13.5f, 13.5f, 13.5f};
+
+       mul_v3_v3fl(p, vec, 1.0f/size);
+       add_v3_v3v3(p_offset, p, offset);
+       sub_v3_v3v3(p_noffset, p, offset);
+
+       r[0] = noise_basis(p_offset, basis) * distortion;
+       r[1] = noise_basis(p, basis) * distortion;
+       r[2] = noise_basis(p_noffset, basis) * distortion;
+
+       add_v3_v3(p, r);
+
+       return noise_basis(p, distortion_basis); /* distorted-domain noise */
+}
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_tex_distnoise_in[]= {
+       {       SOCK_VECTOR, 1, "Vector",               0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
+       {       SOCK_FLOAT, 1, "Size",                  1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
+       {       SOCK_FLOAT, 1, "Distortion",    1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_tex_distnoise_out[]= {
+       {       SOCK_FLOAT, 0, "Fac",           0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_init_tex_distorted_noise(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+{
+       NodeTexDistortedNoise *tex = MEM_callocN(sizeof(NodeTexDistortedNoise), "NodeTexDistortedNoise");
+       tex->basis = SHD_NOISE_PERLIN;
+       tex->distortion_basis = SHD_NOISE_PERLIN;
+
+       node->storage = tex;
+}
+
+static void node_shader_exec_tex_distnoise(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       ShaderCallData *scd= (ShaderCallData*)data;
+       NodeTexDistortedNoise *tex= (NodeTexDistortedNoise*)node->storage;
+       bNodeSocket *vecsock = node->inputs.first;
+       float vec[3], size, distortion;
+       
+       if(vecsock->link)
+               nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
+       else
+               copy_v3_v3(vec, scd->co);
+
+       nodestack_get_vec(&size, SOCK_FLOAT, in[1]);
+       nodestack_get_vec(&distortion, SOCK_FLOAT, in[2]);
+
+       out[0]->vec[0]= distorted_noise(vec, size, tex->basis, tex->distortion_basis, distortion);
+}
+
+static int node_shader_gpu_tex_distnoise(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       if(!in[0].link)
+               in[0].link = GPU_attribute(CD_ORCO, "");
+
+       return GPU_stack_link(mat, "node_tex_distnoise", in, out);
+}
+
+/* node type definition */
+void register_node_type_sh_tex_distnoise(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_TEX_DISTNOISE, "Distorted Noise Texture", NODE_CLASS_TEXTURE, 0);
+       node_type_socket_templates(&ntype, sh_node_tex_distnoise_in, sh_node_tex_distnoise_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, node_shader_init_tex_distorted_noise);
+       node_type_storage(&ntype, "NodeTexDistortedNoise", node_free_standard_storage, node_copy_standard_storage);
+       node_type_exec(&ntype, node_shader_exec_tex_distnoise);
+       node_type_gpu(&ntype, node_shader_gpu_tex_distnoise);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
new file mode 100644 (file)
index 0000000..19271e0
--- /dev/null
@@ -0,0 +1,115 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_tex_environment_in[]= {
+       {       SOCK_VECTOR, 1, "Vector",               0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_tex_environment_out[]= {
+       {       SOCK_RGBA, 0, "Color",          0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_init_tex_environment(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+{
+       NodeTexEnvironment *tex = MEM_callocN(sizeof(NodeTexEnvironment), "NodeTexEnvironment");
+       tex->color_space = SHD_COLORSPACE_SRGB;
+
+       node->storage = tex;
+}
+
+static void node_shader_exec_tex_environment(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       Image *ima= (Image*)node->id;
+       ShaderCallData *scd= (ShaderCallData*)data;
+       NodeTexEnvironment *tex= (NodeTexEnvironment*)node->storage;
+       bNodeSocket *vecsock = node->inputs.first;
+       float vec[3];
+       
+       if(vecsock->link)
+               nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
+       else
+               copy_v3_v3(vec, scd->co);
+
+       if(ima) {
+               ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
+
+               if(ibuf) {
+                       float u= (atan2f(vec[1], vec[0]) + (float)M_PI)/(2*M_PI);
+                       float v= atan2f(vec[2], hypotf(vec[0], vec[1]))/M_PI + 0.5f;
+                       float rgb[4];
+
+                       ibuf_sample(ibuf, u, v, 0.0f, 0.0f, rgb);
+
+                       if(tex->color_space == SHD_COLORSPACE_SRGB)
+                               srgb_to_linearrgb_v3_v3(out[0]->vec, rgb);
+                       else
+                               copy_v3_v3(out[0]->vec, rgb);
+               }
+       }
+}
+
+static int node_shader_gpu_tex_environment(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
+{
+       Image *ima= (Image*)node->id;
+       ImageUser *iuser= NULL;
+
+       if(!ima) {
+               float black[4] = {0.0f, 0.0f, 0.0f, 1.0f};
+               GPUNodeLink *vec = GPU_uniform(black);
+               return GPU_stack_link(mat, "set_rgba", out, out, vec);
+       }
+
+       if(!in[0].link)
+               in[0].link = GPU_builtin(GPU_VIEW_POSITION);
+
+       return GPU_stack_link(mat, "node_tex_environment", in, out, GPU_image(ima, iuser));
+}
+
+/* node type definition */
+void register_node_type_sh_tex_environment(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_TEX_ENVIRONMENT, "Environment Texture", NODE_CLASS_TEXTURE, 0);
+       node_type_socket_templates(&ntype, sh_node_tex_environment_in, sh_node_tex_environment_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, node_shader_init_tex_environment);
+       node_type_storage(&ntype, "NodeTexEnvironment", node_free_standard_storage, node_copy_standard_storage);
+       node_type_exec(&ntype, node_shader_exec_tex_environment);
+       node_type_gpu(&ntype, node_shader_gpu_tex_environment);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
new file mode 100644 (file)
index 0000000..4ad6f38
--- /dev/null
@@ -0,0 +1,113 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_tex_image_in[]= {
+       {       SOCK_VECTOR, 1, "Vector",               0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_tex_image_out[]= {
+       {       SOCK_RGBA, 0, "Color",          0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_init_tex_image(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+{
+       NodeTexImage *tex = MEM_callocN(sizeof(NodeTexImage), "NodeTexImage");
+       tex->color_space = SHD_COLORSPACE_SRGB;
+
+       node->storage = tex;
+}
+
+static void node_shader_exec_tex_image(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       Image *ima= (Image*)node->id;
+       ShaderCallData *scd= (ShaderCallData*)data;
+       NodeTexImage *tex= (NodeTexImage*)node->storage;
+       bNodeSocket *vecsock = node->inputs.first;
+       float vec[3];
+       
+       if(vecsock->link)
+               nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
+       else
+               copy_v3_v3(vec, scd->co);
+
+       if(ima) {
+               ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
+
+               if(ibuf) {
+                       float rgb[4];
+
+                       ibuf_sample(ibuf, vec[0], vec[1], 0.0f, 0.0f, rgb);
+
+                       if(tex->color_space == SHD_COLORSPACE_SRGB)
+                               srgb_to_linearrgb_v3_v3(out[0]->vec, rgb);
+                       else
+                               copy_v3_v3(out[0]->vec, rgb);
+               }
+       }
+}
+
+static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
+{
+       Image *ima= (Image*)node->id;
+       ImageUser *iuser= NULL;
+
+       if(!ima) {
+               float black[4] = {0.0f, 0.0f, 0.0f, 1.0f};
+               GPUNodeLink *vec = GPU_uniform(black);
+               return GPU_stack_link(mat, "set_rgba", out, out, vec);
+       }
+       
+       if(!in[0].link)
+               in[0].link = GPU_attribute(CD_MTFACE, "");
+
+       return GPU_stack_link(mat, "node_tex_image", in, out, GPU_image(ima, iuser));
+}
+
+/* node type definition */
+void register_node_type_sh_tex_image(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_TEX_IMAGE, "Image Texture", NODE_CLASS_TEXTURE, 0);
+       node_type_socket_templates(&ntype, sh_node_tex_image_in, sh_node_tex_image_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, node_shader_init_tex_image);
+       node_type_storage(&ntype, "NodeTexImage", node_free_standard_storage, node_copy_standard_storage);
+       node_type_exec(&ntype, node_shader_exec_tex_image);
+       node_type_gpu(&ntype, node_shader_gpu_tex_image);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_magic.c b/source/blender/nodes/shader/nodes/node_shader_tex_magic.c
new file mode 100644 (file)
index 0000000..d15fff4
--- /dev/null
@@ -0,0 +1,169 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+static void magic(float rgb[3], float p[3], int n, float turbulence)
+{
+       float turb = turbulence/5.0f;
+
+       float x = sinf((p[0] + p[1] + p[2])*5.0f);
+       float y = cosf((-p[0] + p[1] - p[2])*5.0f);
+       float z = -cosf((-p[0] - p[1] + p[2])*5.0f);
+
+       if(n > 0) {
+               x *= turb;
+               y *= turb;
+               z *= turb;
+               y = -cosf(x-y+z);
+               y *= turb;
+
+               if(n > 1) {
+                       x= cosf(x-y-z);
+                       x *= turb;
+
+                       if(n > 2) {
+                               z= sinf(-x-y-z);
+                               z *= turb;
+
+                               if(n > 3) {
+                                       x= -cosf(-x+y-z);
+                                       x *= turb;
+
+                                       if(n > 4) {
+                                               y= -sinf(-x+y+z);
+                                               y *= turb;
+
+                                               if(n > 5) {
+                                                       y= -cosf(-x+y+z);
+                                                       y *= turb;
+
+                                                       if(n > 6) {
+                                                               x= cosf(x+y+z);
+                                                               x *= turb;
+
+                                                               if(n > 7) {
+                                                                       z= sinf(x+y-z);
+                                                                       z *= turb;
+
+                                                                       if(n > 8) {
+                                                                               x= -cosf(-x-y+z);
+                                                                               x *= turb;
+
+                                                                               if(n > 9) {
+                                                                                       y= -sinf(x-y+z);
+                                                                                       y *= turb;
+                                                                               }
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
+       if(turb != 0.0f) {
+               turb *= 2.0f;
+               x /= turb;
+               y /= turb;
+               z /= turb;
+       }
+
+       rgb[0]= 0.5f - x;
+       rgb[1]= 0.5f - y;
+       rgb[2]= 0.5f - z;
+}
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_tex_magic_in[]= {
+       {       SOCK_VECTOR, 1, "Vector",               0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
+       {       SOCK_FLOAT, 1, "Turbulence",    5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_tex_magic_out[]= {
+       {       SOCK_RGBA, 0, "Color",          0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_init_tex_magic(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+{
+       NodeTexMagic *tex = MEM_callocN(sizeof(NodeTexMagic), "NodeTexMagic");
+       tex->depth = 2;
+
+       node->storage = tex;
+}
+
+static void node_shader_exec_tex_magic(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       ShaderCallData *scd= (ShaderCallData*)data;
+       NodeTexMagic *tex= (NodeTexMagic*)node->storage;
+       bNodeSocket *vecsock = node->inputs.first;
+       float vec[3], turbulence;
+       
+       if(vecsock->link)
+               nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
+       else
+               copy_v3_v3(vec, scd->co);
+
+       nodestack_get_vec(&turbulence, SOCK_FLOAT, in[1]);
+
+       magic(out[0]->vec, vec, tex->depth, turbulence);
+}
+
+static int node_shader_gpu_tex_magic(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
+{
+       NodeTexMagic *tex = (NodeTexMagic*)node->storage;
+       float depth = tex->depth;
+
+       if(!in[0].link)
+               in[0].link = GPU_attribute(CD_ORCO, "");
+
+       return GPU_stack_link(mat, "node_tex_magic", in, out, GPU_uniform(&depth));
+}
+
+/* node type definition */
+void register_node_type_sh_tex_magic(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_TEX_MAGIC, "Magic Texture", NODE_CLASS_TEXTURE, 0);
+       node_type_socket_templates(&ntype, sh_node_tex_magic_in, sh_node_tex_magic_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, node_shader_init_tex_magic);
+       node_type_storage(&ntype, "NodeTexMagic", node_free_standard_storage, node_copy_standard_storage);
+       node_type_exec(&ntype, node_shader_exec_tex_magic);
+       node_type_gpu(&ntype, node_shader_gpu_tex_magic);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_marble.c b/source/blender/nodes/shader/nodes/node_shader_tex_marble.c
new file mode 100644 (file)
index 0000000..fe707ee
--- /dev/null
@@ -0,0 +1,123 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+#include "node_shader_noise.h"
+
+static float marble(float vec[3], float size, int type, int wave, int basis, int hard, float turb, int depth)
+{
+       float p[3];
+       float x = vec[0];
+       float y = vec[1];
+       float z = vec[2];
+       float n = 5.0f * (x + y + z);
+       float mi;
+
+       mul_v3_v3fl(p, vec, 1.0f/size);
+
+       mi = n + turb * noise_turbulence(p, basis, depth, hard);
+
+       mi = noise_wave(wave, mi);
+
+       if(type == SHD_MARBLE_SHARP)
+               mi = sqrt(mi);
+       else if(type == SHD_MARBLE_SHARPER)
+               mi = sqrt(sqrt(mi));
+
+       return mi;
+}
+
+/* **************** MARBLE ******************** */
+
+static bNodeSocketTemplate sh_node_tex_marble_in[]= {
+       {       SOCK_VECTOR, 1, "Vector",               0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
+       {       SOCK_FLOAT, 1, "Size",                  0.25f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
+       {       SOCK_FLOAT, 1, "Turbulence",    5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_tex_marble_out[]= {
+       {       SOCK_FLOAT, 0, "Fac",           0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_init_tex_marble(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+{
+       NodeTexMarble *tex = MEM_callocN(sizeof(NodeTexMarble), "NodeTexMarble");
+       tex->type = SHD_MARBLE_SOFT;
+       tex->wave = SHD_WAVE_SINE;
+       tex->basis = SHD_NOISE_PERLIN;
+       tex->hard = 0;
+       tex->depth = 2;
+
+       node->storage = tex;
+}
+
+static void node_shader_exec_tex_marble(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       ShaderCallData *scd= (ShaderCallData*)data;
+       NodeTexMarble *tex= (NodeTexMarble*)node->storage;
+       bNodeSocket *vecsock = node->inputs.first;
+       float vec[3], size, turbulence;
+       
+       if(vecsock->link)
+               nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
+       else
+               copy_v3_v3(vec, scd->co);
+
+       nodestack_get_vec(&size, SOCK_FLOAT, in[1]);
+       nodestack_get_vec(&turbulence, SOCK_FLOAT, in[2]);
+
+       out[0]->vec[0]= marble(vec, size, tex->type, tex->wave, tex->basis, tex->hard, turbulence, tex->depth);
+}
+
+static int node_shader_gpu_tex_marble(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       if(!in[0].link)
+               in[0].link = GPU_attribute(CD_ORCO, "");
+
+       return GPU_stack_link(mat, "node_tex_marble", in, out);
+}
+
+/* node type definition */
+void register_node_type_sh_tex_marble(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_TEX_MARBLE, "Marble Texture", NODE_CLASS_TEXTURE, 0);
+       node_type_socket_templates(&ntype, sh_node_tex_marble_in, sh_node_tex_marble_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, node_shader_init_tex_marble);
+       node_type_storage(&ntype, "NodeTexMarble", node_free_standard_storage, node_copy_standard_storage);
+       node_type_exec(&ntype, node_shader_exec_tex_marble);
+       node_type_gpu(&ntype, node_shader_gpu_tex_marble);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c
new file mode 100644 (file)
index 0000000..a0a2455
--- /dev/null
@@ -0,0 +1,288 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+#include "node_shader_noise.h"
+
+/* Musgrave fBm
+ *
+ * H: fractal increment parameter
+ * lacunarity: gap between successive frequencies
+ * octaves: number of frequencies in the fBm
+ *
+ * from "Texturing and Modelling: A procedural approach"
+ */
+
+static float noise_musgrave_fBm(float p[3], int basis, float H, float lacunarity, float octaves)
+{
+       float rmd;
+       float value = 0.0f;
+       float pwr = 1.0f;
+       float pwHL = pow(lacunarity, -H);
+       int i;
+
+       for(i = 0; i < (int)octaves; i++) {
+               value += noise_basis(p, basis) * pwr;
+               pwr *= pwHL;
+               mul_v3_fl(p, lacunarity);
+       }
+
+       rmd = octaves - floor(octaves);
+       if(rmd != 0.0f)
+               value += rmd * noise_basis(p, basis) * pwr;
+
+       return value;
+}
+
+/* Musgrave Multifractal
+ *
+ * H: highest fractal dimension
+ * lacunarity: gap between successive frequencies
+ * octaves: number of frequencies in the fBm
+ */
+
+static float noise_musgrave_multi_fractal(float p[3], int basis, float H, float lacunarity, float octaves)
+{
+       float rmd;
+       float value = 1.0f;
+       float pwr = 1.0f;
+       float pwHL = pow(lacunarity, -H);
+       int i;
+
+       for(i = 0; i < (int)octaves; i++) {
+               value *= (pwr * noise_basis(p, basis) + 1.0f);
+               pwr *= pwHL;
+               mul_v3_fl(p, lacunarity);
+       }
+
+       rmd = octaves - floor(octaves);
+       if(rmd != 0.0f)
+               value *= (rmd * pwr * noise_basis(p, basis) + 1.0f); /* correct? */
+
+       return value;
+}
+
+/* Musgrave Heterogeneous Terrain
+ *
+ * H: fractal dimension of the roughest area
+ * lacunarity: gap between successive frequencies
+ * octaves: number of frequencies in the fBm
+ * offset: raises the terrain from `sea level'
+ */
+
+static float noise_musgrave_hetero_terrain(float p[3], int basis, float H, float lacunarity, float octaves, float offset)
+{
+       float value, increment, rmd;
+       float pwHL = pow(lacunarity, -H);
+       float pwr = pwHL;
+       int i;
+
+       /* first unscaled octave of function; later octaves are scaled */
+       value = offset + noise_basis(p, basis);
+       mul_v3_fl(p, lacunarity);
+
+       for(i = 1; i < (int)octaves; i++) {
+               increment = (noise_basis(p, basis) + offset) * pwr * value;
+               value += increment;
+               pwr *= pwHL;
+               mul_v3_fl(p, lacunarity);
+       }
+
+       rmd = octaves - floor(octaves);
+       if(rmd != 0.0f) {
+               increment = (noise_basis(p, basis) + offset) * pwr * value;
+               value += rmd * increment;
+       }
+
+       return value;
+}
+
+/* Hybrid Additive/Multiplicative Multifractal Terrain
+ *
+ * H: fractal dimension of the roughest area
+ * lacunarity: gap between successive frequencies
+ * octaves: number of frequencies in the fBm
+ * offset: raises the terrain from `sea level'
+ */
+
+static float noise_musgrave_hybrid_multi_fractal(float p[3], int basis, float H, float lacunarity, float octaves, float offset, float gain)
+{
+       float result, signal, weight, rmd;
+       float pwHL = pow(lacunarity, -H);
+       float pwr = pwHL;
+       int i;
+
+       result = noise_basis(p, basis) + offset;
+       weight = gain * result;
+       mul_v3_fl(p, lacunarity);
+
+       for(i = 1; (weight > 0.001f) && (i < (int)octaves); i++) {
+               if(weight > 1.0f)
+                       weight = 1.0f;
+
+               signal = (noise_basis(p, basis) + offset) * pwr;
+               pwr *= pwHL;
+               result += weight * signal;
+               weight *= gain * signal;
+               mul_v3_fl(p, lacunarity);
+       }
+
+       rmd = octaves - floor(octaves);
+       if(rmd != 0.0f)
+               result += rmd * ((noise_basis(p, basis) + offset) * pwr);
+
+       return result;
+}
+
+/* Ridged Multifractal Terrain
+ *
+ * H: fractal dimension of the roughest area
+ * lacunarity: gap between successive frequencies
+ * octaves: number of frequencies in the fBm
+ * offset: raises the terrain from `sea level'
+ */
+
+static float noise_musgrave_ridged_multi_fractal(float p[3], int basis, float H, float lacunarity, float octaves, float offset, float gain)
+{
+       float result, signal, weight;
+       float pwHL = pow(lacunarity, -H);
+       float pwr = pwHL;
+       int i;
+
+       signal = offset - fabsf(noise_basis(p, basis));
+       signal *= signal;
+       result = signal;
+       weight = 1.0f;
+
+       for(i = 1; i < (int)octaves; i++) {
+               mul_v3_fl(p, lacunarity);
+               weight = CLAMPIS(signal * gain, 0.0f, 1.0f);
+               signal = offset - fabsf(noise_basis(p, basis));
+               signal *= signal;
+               signal *= weight;
+               result += signal * pwr;
+               pwr *= pwHL;
+       }
+
+       return result;
+}
+
+static float musgrave(int type, int basis, float dimension, float lacunarity, float octaves, float offset, float intensity, float gain, float size, float vec[3])
+{
+       float p[3];
+
+       mul_v3_v3fl(p, vec, 1.0f/size);
+
+       if(type == SHD_MUSGRAVE_MULTIFRACTAL)
+               return intensity*noise_musgrave_multi_fractal(p, basis, dimension, lacunarity, octaves);
+       else if(type == SHD_MUSGRAVE_FBM)
+               return intensity*noise_musgrave_fBm(p, basis, dimension, lacunarity, octaves);
+       else if(type == SHD_MUSGRAVE_HYBRID_MULTIFRACTAL)
+               return intensity*noise_musgrave_hybrid_multi_fractal(p, basis, dimension, lacunarity, octaves, offset, gain);
+       else if(type == SHD_MUSGRAVE_RIDGED_MULTIFRACTAL)
+               return intensity*noise_musgrave_ridged_multi_fractal(p, basis, dimension, lacunarity, octaves, offset, gain);
+       else if(type == SHD_MUSGRAVE_HETERO_TERRAIN)
+               return intensity*noise_musgrave_hetero_terrain(p, basis, dimension, lacunarity, octaves, offset);
+       
+       return 0.0f;
+}
+
+/* **************** MUSGRAVE ******************** */
+
+static bNodeSocketTemplate sh_node_tex_musgrave_in[]= {
+       {       SOCK_VECTOR, 1, "Vector",               0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
+       {       SOCK_FLOAT, 1, "Size",                  0.25f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
+       {       SOCK_FLOAT, 1, "Dimension",             2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
+       {       SOCK_FLOAT, 1, "Lacunarity",    1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
+       {       SOCK_FLOAT, 1, "Octaves",               2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
+       {       SOCK_FLOAT, 1, "Offset",                0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
+       {       SOCK_FLOAT, 1, "Gain",                  1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_tex_musgrave_out[]= {
+       {       SOCK_FLOAT, 0, "Fac",           0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_init_tex_musgrave(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+{
+       NodeTexMusgrave *tex = MEM_callocN(sizeof(NodeTexMusgrave), "NodeTexMusgrave");
+       tex->type = SHD_MUSGRAVE_FBM;
+       tex->basis = SHD_NOISE_PERLIN;
+
+       node->storage = tex;
+}
+
+static void node_shader_exec_tex_musgrave(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       ShaderCallData *scd= (ShaderCallData*)data;
+       NodeTexMusgrave *tex= (NodeTexMusgrave*)node->storage;
+       bNodeSocket *vecsock = node->inputs.first;
+       float vec[3], size, dimension, lacunarity, octaves, offset, gain;
+       
+       if(vecsock->link)
+               nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
+       else
+               copy_v3_v3(vec, scd->co);
+
+       nodestack_get_vec(&size, SOCK_FLOAT, in[1]);
+       nodestack_get_vec(&dimension, SOCK_FLOAT, in[2]);
+       nodestack_get_vec(&lacunarity, SOCK_FLOAT, in[3]);
+       nodestack_get_vec(&octaves, SOCK_FLOAT, in[4]);
+       nodestack_get_vec(&offset, SOCK_FLOAT, in[5]);
+       nodestack_get_vec(&gain, SOCK_FLOAT, in[6]);
+
+       out[0]->vec[0]= musgrave(tex->type, tex->basis, dimension, lacunarity, octaves, offset, 1.0f, gain, size, vec);
+}
+
+static int node_shader_gpu_tex_musgrave(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       if(!in[0].link)
+               in[0].link = GPU_attribute(CD_ORCO, "");
+
+       return GPU_stack_link(mat, "node_tex_musgrave", in, out);
+}
+
+/* node type definition */
+void register_node_type_sh_tex_musgrave(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_TEX_MUSGRAVE, "Musgrave Texture", NODE_CLASS_TEXTURE, 0);
+       node_type_socket_templates(&ntype, sh_node_tex_musgrave_in, sh_node_tex_musgrave_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, node_shader_init_tex_musgrave);
+       node_type_storage(&ntype, "NodeTexMusgrave", node_free_standard_storage, node_copy_standard_storage);
+       node_type_exec(&ntype, node_shader_exec_tex_musgrave);
+       node_type_gpu(&ntype, node_shader_gpu_tex_musgrave);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_noise.c b/source/blender/nodes/shader/nodes/node_shader_tex_noise.c
new file mode 100644 (file)
index 0000000..9785c44
--- /dev/null
@@ -0,0 +1,100 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+#include "node_shader_noise.h"
+
+static float noise_texture_value(float vec[3])
+{
+       float p[3];
+
+       mul_v3_v3fl(p, vec, 1e8f);
+       return cellnoise(p);
+}
+
+static void noise_texture_color(float rgb[3], float vec[3])
+{
+       float p[3];
+
+       mul_v3_v3fl(p, vec, 1e8f);
+       cellnoise_color(rgb, p);
+}
+
+/* **************** NOISE ******************** */
+
+static bNodeSocketTemplate sh_node_tex_noise_in[]= {
+       {       SOCK_VECTOR, 1, "Vector",               0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_tex_noise_out[]= {
+       {       SOCK_RGBA, 0, "Color",          0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_FLOAT, 0, "Fac",           0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_exec_tex_noise(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       ShaderCallData *scd= (ShaderCallData*)data;
+       bNodeSocket *vecsock = node->inputs.first;
+       float vec[3];
+       
+       if(vecsock->link)
+               nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
+       else
+               copy_v3_v3(vec, scd->co);
+
+       noise_texture_color(out[0]->vec, vec);
+       out[1]->vec[0]= noise_texture_value(vec);
+}
+
+static int node_shader_gpu_tex_noise(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       if(!in[0].link)
+               in[0].link = GPU_attribute(CD_ORCO, "");
+
+       return GPU_stack_link(mat, "node_tex_noise", in, out);
+}
+
+/* node type definition */
+void register_node_type_sh_tex_noise(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_TEX_NOISE, "Noise Texture", NODE_CLASS_TEXTURE, 0);
+       node_type_socket_templates(&ntype, sh_node_tex_noise_in, sh_node_tex_noise_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, NULL);
+       node_type_storage(&ntype, "", NULL, NULL);
+       node_type_exec(&ntype, node_shader_exec_tex_noise);
+       node_type_gpu(&ntype, node_shader_gpu_tex_noise);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
new file mode 100644 (file)
index 0000000..6c15545
--- /dev/null
@@ -0,0 +1,82 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+
+/* **************** OUTPUT ******************** */
+
+static bNodeSocketTemplate sh_node_tex_sky_in[]= {
+       {       SOCK_VECTOR, 1, "Vector",               0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_tex_sky_out[]= {
+       {       SOCK_RGBA, 0, "Color",          0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_init_tex_sky(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+{
+       NodeTexSky *tex = MEM_callocN(sizeof(NodeTexSky), "NodeTexSky");
+       tex->sun_direction[0] = 0.0f;
+       tex->sun_direction[1] = 0.0f;
+       tex->sun_direction[2] = 1.0f;
+       tex->turbidity = 2.2f;
+
+       node->storage = tex;
+}
+
+static void node_shader_exec_tex_sky(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
+{
+}
+
+static int node_shader_gpu_tex_sky(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       if(!in[0].link)
+               in[0].link = GPU_attribute(CD_ORCO, "");
+
+       return GPU_stack_link(mat, "node_tex_sky", in, out);
+}
+
+/* node type definition */
+void register_node_type_sh_tex_sky(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_TEX_SKY, "Sky Texture", NODE_CLASS_TEXTURE, 0);
+       node_type_socket_templates(&ntype, sh_node_tex_sky_in, sh_node_tex_sky_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, node_shader_init_tex_sky);
+       node_type_storage(&ntype, "NodeTexSky", node_free_standard_storage, node_copy_standard_storage);
+       node_type_exec(&ntype, node_shader_exec_tex_sky);
+       node_type_gpu(&ntype, node_shader_gpu_tex_sky);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_stucci.c b/source/blender/nodes/shader/nodes/node_shader_tex_stucci.c
new file mode 100644 (file)
index 0000000..22ea8d3
--- /dev/null
@@ -0,0 +1,118 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+#include "node_shader_noise.h"
+
+static float stucci(int type, int basis, int hard, float turbulence, float size, float vec[3])
+{
+       float p[3], b2, ofs, r;
+
+       mul_v3_v3fl(p, vec, 1.0f/size);
+       b2 = noise_basis_hard(p, basis, hard);
+       ofs = turbulence/200.0f;
+
+       if(type != SHD_STUCCI_PLASTIC)
+               ofs *= b2*b2;
+
+       p[2] += ofs;
+       r = noise_basis_hard(p, basis, hard);
+
+       if(type == SHD_STUCCI_WALL_OUT)
+               r = 1.0f - r;
+
+       return MAX2(r, 0.0f);
+}
+
+/* **************** STUCCI ******************** */
+
+static bNodeSocketTemplate sh_node_tex_stucci_in[]= {
+       {       SOCK_VECTOR, 1, "Vector",               0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
+       {       SOCK_FLOAT, 1, "Size",                  1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
+       {       SOCK_FLOAT, 1, "Turbulence",    1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_tex_stucci_out[]= {
+       {       SOCK_FLOAT, 0, "Fac",           0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_init_tex_stucci(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+{
+       NodeTexStucci *tex = MEM_callocN(sizeof(NodeTexStucci), "NodeTexStucci");
+       tex->type = SHD_STUCCI_PLASTIC;
+       tex->basis = SHD_NOISE_PERLIN;
+       tex->hard = 0;
+
+       node->storage = tex;
+}
+
+static void node_shader_exec_tex_stucci(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       ShaderCallData *scd= (ShaderCallData*)data;
+       NodeTexStucci *tex= (NodeTexStucci*)node->storage;
+       bNodeSocket *vecsock = node->inputs.first;
+       float vec[3], size, turbulence;
+       
+       if(vecsock->link)
+               nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
+       else
+               copy_v3_v3(vec, scd->co);
+
+       nodestack_get_vec(&size, SOCK_FLOAT, in[1]);
+       nodestack_get_vec(&turbulence, SOCK_FLOAT, in[2]);
+
+       out[0]->vec[0]= stucci(tex->type, tex->basis, tex->hard, turbulence, size, vec);
+}
+
+static int node_shader_gpu_tex_stucci(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       if(!in[0].link)
+               in[0].link = GPU_attribute(CD_ORCO, "");
+
+       return GPU_stack_link(mat, "node_tex_stucci", in, out);
+}
+
+/* node type definition */
+void register_node_type_sh_tex_stucci(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_TEX_STUCCI, "Stucci Texture", NODE_CLASS_TEXTURE, 0);
+       node_type_socket_templates(&ntype, sh_node_tex_stucci_in, sh_node_tex_stucci_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, node_shader_init_tex_stucci);
+       node_type_storage(&ntype, "NodeTexStucci", node_free_standard_storage, node_copy_standard_storage);
+       node_type_exec(&ntype, node_shader_exec_tex_stucci);
+       node_type_gpu(&ntype, node_shader_gpu_tex_stucci);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c
new file mode 100644 (file)
index 0000000..16c6945
--- /dev/null
@@ -0,0 +1,164 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+#include "node_shader_noise.h"
+
+static float voronoi_tex(int distance_metric, int coloring,
+       float weight1, float weight2, float weight3, float weight4,
+       float exponent, float intensity, float size, float vec[3], float color[3])
+{
+       float aw1 = fabsf(weight1);
+       float aw2 = fabsf(weight2);
+       float aw3 = fabsf(weight3);
+       float aw4 = fabsf(weight4);
+       float sc = (aw1 + aw2 + aw3 + aw4);
+       float da[4];
+       float pa[4][3];
+       float fac;
+       float p[3];
+
+       if(sc != 0.0f)
+               sc = intensity/sc;
+       
+       /* compute distance and point coordinate of 4 nearest neighbours */
+       mul_v3_v3fl(p, vec, 1.0f/size);
+       voronoi_generic(p, distance_metric, exponent, da, pa);
+
+       /* Scalar output */
+       fac = sc * fabsf(weight1*da[0] + weight2*da[1] + weight3*da[2] + weight4*da[3]);
+
+       /* colored output */
+       if(coloring == SHD_VORONOI_INTENSITY) {
+               color[0]= color[1]= color[2]= fac;
+       }
+       else {
+               float rgb1[3], rgb2[3], rgb3[3], rgb4[3];
+
+               cellnoise_color(rgb1, pa[0]);
+               cellnoise_color(rgb2, pa[1]);
+               cellnoise_color(rgb3, pa[2]);
+               cellnoise_color(rgb4, pa[3]);
+
+               mul_v3_v3fl(color, rgb1, aw1);
+               madd_v3_v3fl(color, rgb2, aw2);
+               madd_v3_v3fl(color, rgb3, aw3);
+               madd_v3_v3fl(color, rgb4, aw4);
+
+               if(coloring != SHD_VORONOI_POSITION) {
+                       float t1 = MIN2((da[1] - da[0])*10.0f, 1.0f);
+
+                       if(coloring == SHD_VORONOI_POSITION_OUTLINE_INTENSITY)
+                               mul_v3_fl(color, t1*fac);
+                       else if(coloring == SHD_VORONOI_POSITION_OUTLINE)
+                               mul_v3_fl(color, t1*sc);
+               }
+               else {
+                       mul_v3_fl(color, sc);
+               }
+       }
+
+       return fac;
+}
+
+/* **************** VORONOI ******************** */
+
+static bNodeSocketTemplate sh_node_tex_voronoi_in[]= {
+       {       SOCK_VECTOR, 1, "Vector",               0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
+       {       SOCK_FLOAT, 1, "Size",                  0.25f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
+       {       SOCK_FLOAT, 1, "Weight1",               1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f},
+       {       SOCK_FLOAT, 1, "Weight2",               0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f},
+       {       SOCK_FLOAT, 1, "Weight3",               0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f},
+       {       SOCK_FLOAT, 1, "Weight4",               0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f},
+       {       SOCK_FLOAT, 1, "Exponent",              2.5f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_tex_voronoi_out[]= {
+       {       SOCK_RGBA, 0, "Color",          0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       SOCK_FLOAT, 0, "Fac",           0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_init_tex_voronoi(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+{
+       NodeTexVoronoi *tex = MEM_callocN(sizeof(NodeTexVoronoi), "NodeTexVoronoi");
+       tex->distance_metric = SHD_VORONOI_ACTUAL_DISTANCE;
+       tex->coloring = SHD_VORONOI_INTENSITY;
+
+       node->storage = tex;
+}
+
+static void node_shader_exec_tex_voronoi(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       ShaderCallData *scd= (ShaderCallData*)data;
+       NodeTexVoronoi *tex= (NodeTexVoronoi*)node->storage;
+       bNodeSocket *vecsock = node->inputs.first;
+       float vec[3], size, w1, w2, w3, w4, exponent;
+       
+       if(vecsock->link)
+               nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
+       else
+               copy_v3_v3(vec, scd->co);
+
+       nodestack_get_vec(&size, SOCK_FLOAT, in[1]);
+       nodestack_get_vec(&w1, SOCK_FLOAT, in[2]);
+       nodestack_get_vec(&w2, SOCK_FLOAT, in[3]);
+       nodestack_get_vec(&w3, SOCK_FLOAT, in[4]);
+       nodestack_get_vec(&w4, SOCK_FLOAT, in[5]);
+       nodestack_get_vec(&exponent, SOCK_FLOAT, in[6]);
+
+       out[1]->vec[0]= voronoi_tex(tex->distance_metric, tex->coloring, w1, w2, w3, w4,
+               exponent, 1.0f, size, vec, out[0]->vec);
+}
+
+static int node_shader_gpu_tex_voronoi(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       if(!in[0].link)
+               in[0].link = GPU_attribute(CD_ORCO, "");
+
+       return GPU_stack_link(mat, "node_tex_voronoi", in, out);
+}
+
+/* node type definition */
+void register_node_type_sh_tex_voronoi(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_TEX_VORONOI, "Voronoi Texture", NODE_CLASS_TEXTURE, 0);
+       node_type_socket_templates(&ntype, sh_node_tex_voronoi_in, sh_node_tex_voronoi_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, node_shader_init_tex_voronoi);
+       node_type_storage(&ntype, "NodeTexVoronoi", node_free_standard_storage, node_copy_standard_storage);
+       node_type_exec(&ntype, node_shader_exec_tex_voronoi);
+       node_type_gpu(&ntype, node_shader_gpu_tex_voronoi);
+
+       nodeRegisterType(lb, &ntype);
+};
+
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_wood.c b/source/blender/nodes/shader/nodes/node_shader_tex_wood.c
new file mode 100644 (file)
index 0000000..5ae6952
--- /dev/null
@@ -0,0 +1,125 @@
+/**
+ * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
+ *
+ * ***** 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"
+#include "node_shader_noise.h"
+
+static float wood(float p[3], float size, int type, int wave, int basis, unsigned int hard, float turb)
+{
+       float x = p[0];
+       float y = p[1];
+       float z = p[2];
+
+       if(type == SHD_WOOD_BANDS) {
+               return noise_wave(wave, (x + y + z)*10.0f);
+       }
+       else if(type == SHD_WOOD_RINGS) {
+               return noise_wave(wave, sqrt(x*x + y*y + z*z)*20.0f);
+       }
+       else if (type == SHD_WOOD_BAND_NOISE) {
+               float psize[3] = {p[0]/size, p[1]/size, p[2]/size};
+               float wi = turb*noise_basis_hard(psize, basis, hard);
+               return noise_wave(wave, (x + y + z)*10.0f + wi);
+       }
+       else if (type == SHD_WOOD_RING_NOISE) {
+               float psize[3] = {p[0]/size, p[1]/size, p[2]/size};
+               float wi = turb*noise_basis_hard(psize, basis, hard);
+               return noise_wave(wave, sqrt(x*x + y*y + z*z)*20.0f + wi);
+       }
+
+       return 0.0f;
+}
+
+/* **************** WOOD ******************** */
+
+static bNodeSocketTemplate sh_node_tex_wood_in[]= {
+       {       SOCK_VECTOR, 1, "Vector",               0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
+       {       SOCK_FLOAT, 1, "Size",                  0.25f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
+       {       SOCK_FLOAT, 1, "Turbulence",    5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
+       {       -1, 0, ""       }
+};
+
+static bNodeSocketTemplate sh_node_tex_wood_out[]= {
+       {       SOCK_FLOAT, 0, "Fac",           0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void node_shader_init_tex_wood(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+{
+       NodeTexWood *tex = MEM_callocN(sizeof(NodeTexWood), "NodeTexWood");
+       tex->type = SHD_WOOD_BANDS;
+       tex->wave = SHD_WAVE_SINE;
+       tex->basis = SHD_NOISE_PERLIN;
+       tex->hard = 0;
+
+       node->storage = tex;
+}
+
+static void node_shader_exec_tex_wood(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       ShaderCallData *scd= (ShaderCallData*)data;
+       NodeTexWood *tex= (NodeTexWood*)node->storage;
+       bNodeSocket *vecsock = node->inputs.first;
+       float vec[3], size, turbulence;
+       
+       if(vecsock->link)
+               nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
+       else
+               copy_v3_v3(vec, scd->co);
+
+       nodestack_get_vec(&size, SOCK_FLOAT, in[1]);
+       nodestack_get_vec(&turbulence, SOCK_FLOAT, in[2]);
+
+       out[0]->vec[0]= wood(vec, size, tex->type, tex->wave, tex->basis, tex->hard, turbulence);
+}
+
+static int node_shader_gpu_tex_wood(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
+{
+       if(!in[0].link)
+               in[0].link = GPU_attribute(CD_ORCO, "");
+
+       return GPU_stack_link(mat, "node_tex_wood", in, out);
+}
+
+/* node type definition */
+void register_node_type_sh_tex_wood(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, SH_NODE_TEX_WOOD, "Wood Texture", NODE_CLASS_TEXTURE, 0);
+       node_type_socket_templates(&ntype, sh_node_tex_wood_in, sh_node_tex_wood_out);
+       node_type_size(&ntype, 150, 60, 200);
+       node_type_init(&ntype, node_shader_init_tex_wood);
+       node_type_storage(&ntype, "NodeTexWood", node_free_standard_storage, node_copy_standard_storage);
+       node_type_exec(&ntype, node_shader_exec_tex_wood);
+       node_type_gpu(&ntype, node_shader_gpu_tex_wood);
+
+       nodeRegisterType(lb, &ntype);
+};
+