diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-05-02 20:25:25 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-05-03 13:08:56 +0300 |
commit | a7404958148f1030483c7d6238ebf48abc26cf24 (patch) | |
tree | cd06f232a263ac3bfc7233e12a6d09a5a0a60d7e /source/blender/nodes | |
parent | 54bde8244578fc2002efa394b482ff3ff47f43fd (diff) |
Eevee: Add "uber" Shader Output Nodes.
Include Metallic and Specular workflow.
Clearcoat and are not implemented yet.
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/CMakeLists.txt | 2 | ||||
-rw-r--r-- | source/blender/nodes/NOD_shader.h | 2 | ||||
-rw-r--r-- | source/blender/nodes/NOD_static_types.h | 2 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_output_metallic.c | 90 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_output_specular.c | 89 |
5 files changed, 185 insertions, 0 deletions
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 3596a2aa12d..697b649a298 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -186,6 +186,8 @@ set(SRC shader/nodes/node_shader_hair_info.c shader/nodes/node_shader_output_lamp.c shader/nodes/node_shader_output_material.c + shader/nodes/node_shader_output_metallic.c + shader/nodes/node_shader_output_specular.c shader/nodes/node_shader_output_world.c shader/nodes/node_shader_output_linestyle.c shader/nodes/node_shader_particle_info.c diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h index 804c1897a27..c05c1a55144 100644 --- a/source/blender/nodes/NOD_shader.h +++ b/source/blender/nodes/NOD_shader.h @@ -120,6 +120,8 @@ void register_node_type_sh_uvalongstroke(void); void register_node_type_sh_output_lamp(void); void register_node_type_sh_output_material(void); +void register_node_type_sh_output_metallic(void); +void register_node_type_sh_output_specular(void); void register_node_type_sh_output_world(void); void register_node_type_sh_output_linestyle(void); diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h index e754d063397..7d9f8149ad0 100644 --- a/source/blender/nodes/NOD_static_types.h +++ b/source/blender/nodes/NOD_static_types.h @@ -67,6 +67,8 @@ DefNode( ShaderNode, SH_NODE_COMBRGB, 0, "COMBR DefNode( ShaderNode, SH_NODE_HUE_SAT, 0, "HUE_SAT", HueSaturation, "Hue/Saturation", "" ) DefNode( ShaderNode, SH_NODE_OUTPUT_MATERIAL, def_sh_output, "OUTPUT_MATERIAL", OutputMaterial, "Material Output", "" ) +DefNode( ShaderNode, SH_NODE_OUTPUT_METALLIC, def_sh_output, "OUTPUT_METALLIC", OutputMetallic, "Material Metallic Output", "") +DefNode( ShaderNode, SH_NODE_OUTPUT_SPECULAR, def_sh_output, "OUTPUT_SPECULAR", OutputSpecular, "Material Specular Output", "") DefNode( ShaderNode, SH_NODE_OUTPUT_LAMP, def_sh_output, "OUTPUT_LAMP", OutputLamp, "Lamp Output", "" ) DefNode( ShaderNode, SH_NODE_OUTPUT_WORLD, def_sh_output, "OUTPUT_WORLD", OutputWorld, "World Output", "" ) DefNode( ShaderNode, SH_NODE_OUTPUT_LINESTYLE, def_sh_output_linestyle,"OUTPUT_LINESTYLE", OutputLineStyle, "Line Style Output", "" ) diff --git a/source/blender/nodes/shader/nodes/node_shader_output_metallic.c b/source/blender/nodes/shader/nodes/node_shader_output_metallic.c new file mode 100644 index 00000000000..b8182acfc7f --- /dev/null +++ b/source/blender/nodes/shader/nodes/node_shader_output_metallic.c @@ -0,0 +1,90 @@ +/* + * ***** 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): Clément Foucault. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "../node_shader_util.h" + +/* **************** OUTPUT ******************** */ + +static bNodeSocketTemplate sh_node_output_metallic_in[] = { + { SOCK_RGBA, 1, N_("Base Color"), 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_FLOAT, 1, N_("Metallic"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, + { SOCK_FLOAT, 1, N_("Specular"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, + { SOCK_FLOAT, 1, N_("Roughness"), 0.2f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, + { SOCK_RGBA, 1, N_("Emissive Color"), 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_FLOAT, 1, N_("Transparency"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, + { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, + { SOCK_FLOAT, 1, N_("Clear Coat"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, + { SOCK_FLOAT, 1, N_("Clear Coat Roughness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, + { SOCK_VECTOR, 1, N_("Clear Coat Normal"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, + { SOCK_FLOAT, 1, N_("Ambient Occlusion"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, + { -1, 0, "" } +}; + +static int node_shader_gpu_output_metallic(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) +{ + GPUNodeLink *outlink; + static float one = 1.0f; + + /* Normals */ + if (!in[6].link) { + GPU_link(mat, "world_normals_get", &in[6].link); + } + + /* Clearcoat Normals */ + if (!in[9].link) { + GPU_link(mat, "world_normals_get", &in[9].link); + } + + /* Occlusion */ + if (!in[10].link) { + GPU_link(mat, "set_value", GPU_uniform(&one), &in[10].link); + } + + GPU_stack_link(mat, "node_output_metallic", in, out, &outlink); + GPU_material_output_link(mat, outlink); + + return true; +} + + +/* node type definition */ +void register_node_type_sh_output_metallic(void) +{ + static bNodeType ntype; + + sh_node_type_base(&ntype, SH_NODE_OUTPUT_METALLIC, "Metallic Material Output", NODE_CLASS_OUTPUT, 0); + node_type_compatibility(&ntype, NODE_NEW_SHADING); + node_type_socket_templates(&ntype, sh_node_output_metallic_in, NULL); + node_type_init(&ntype, NULL); + node_type_storage(&ntype, "", NULL, NULL); + node_type_gpu(&ntype, node_shader_gpu_output_metallic); + + /* Do not allow muting output node. */ + node_type_internal_links(&ntype, NULL); + + nodeRegisterType(&ntype); +} diff --git a/source/blender/nodes/shader/nodes/node_shader_output_specular.c b/source/blender/nodes/shader/nodes/node_shader_output_specular.c new file mode 100644 index 00000000000..25bcf9642f9 --- /dev/null +++ b/source/blender/nodes/shader/nodes/node_shader_output_specular.c @@ -0,0 +1,89 @@ +/* + * ***** 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): Clément Foucault. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "../node_shader_util.h" + +/* **************** OUTPUT ******************** */ + +static bNodeSocketTemplate sh_node_output_specular_in[] = { + { SOCK_RGBA, 1, N_("Base Color"), 0.8f, 0.8f, 0.8f, 1.0f}, + { SOCK_RGBA, 1, N_("Specular"), 0.03f, 0.03f, 0.03f, 1.0f}, + { SOCK_FLOAT, 1, N_("Roughness"), 0.2f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, + { SOCK_RGBA, 1, N_("Emissive Color"), 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_FLOAT, 1, N_("Transparency"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, + { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, + { SOCK_FLOAT, 1, N_("Clear Coat"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, + { SOCK_FLOAT, 1, N_("Clear Coat Roughness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, + { SOCK_VECTOR, 1, N_("Clear Coat Normal"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, + { SOCK_FLOAT, 1, N_("Ambient Occlusion"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, + { -1, 0, "" } +}; + +static int node_shader_gpu_output_specular(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) +{ + GPUNodeLink *outlink; + static float one = 1.0f; + + /* Normals */ + if (!in[5].link) { + GPU_link(mat, "world_normals_get", &in[5].link); + } + + /* Clearcoat Normals */ + if (!in[8].link) { + GPU_link(mat, "world_normals_get", &in[8].link); + } + + /* Occlusion */ + if (!in[9].link) { + GPU_link(mat, "set_value", GPU_uniform(&one), &in[9].link); + } + + GPU_stack_link(mat, "node_output_specular", in, out, &outlink); + GPU_material_output_link(mat, outlink); + + return true; +} + + +/* node type definition */ +void register_node_type_sh_output_specular(void) +{ + static bNodeType ntype; + + sh_node_type_base(&ntype, SH_NODE_OUTPUT_SPECULAR, "Specular Material Output", NODE_CLASS_OUTPUT, 0); + node_type_compatibility(&ntype, NODE_NEW_SHADING); + node_type_socket_templates(&ntype, sh_node_output_specular_in, NULL); + node_type_init(&ntype, NULL); + node_type_storage(&ntype, "", NULL, NULL); + node_type_gpu(&ntype, node_shader_gpu_output_specular); + + /* Do not allow muting output node. */ + node_type_internal_links(&ntype, NULL); + + nodeRegisterType(&ntype); +} |