From 5c5c09439abdf2f759fbc3c17a4e773b9005d77f Mon Sep 17 00:00:00 2001 From: Luca Rood Date: Tue, 20 Jun 2017 14:33:13 +0200 Subject: Clean node names and organize menus for eevee This makes the node menus aware of the Cycles/Eevee distinction, and only show the relevant nodes for the current engine. Names have also been changed to accomodate for the new output node system. --- release/scripts/startup/nodeitems_builtins.py | 62 +++++++++------ source/blender/blenkernel/BKE_node.h | 4 +- source/blender/blenkernel/intern/node.c | 4 +- source/blender/blenloader/intern/versioning_280.c | 25 ++++++ source/blender/editors/space_node/node_edit.c | 2 +- .../blender/gpu/shaders/gpu_shader_material.glsl | 4 +- source/blender/nodes/CMakeLists.txt | 4 +- source/blender/nodes/NOD_shader.h | 4 +- source/blender/nodes/NOD_static_types.h | 6 +- .../shader/nodes/node_shader_eevee_metallic.c | 88 ++++++++++++++++++++++ .../shader/nodes/node_shader_eevee_specular.c | 87 +++++++++++++++++++++ .../nodes/node_shader_output_eevee_material.c | 2 +- .../shader/nodes/node_shader_output_metallic.c | 88 ---------------------- .../shader/nodes/node_shader_output_specular.c | 87 --------------------- 14 files changed, 253 insertions(+), 214 deletions(-) create mode 100644 source/blender/nodes/shader/nodes/node_shader_eevee_metallic.c create mode 100644 source/blender/nodes/shader/nodes/node_shader_eevee_specular.c delete mode 100644 source/blender/nodes/shader/nodes/node_shader_output_metallic.c delete mode 100644 source/blender/nodes/shader/nodes/node_shader_output_specular.c diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py index 59bf93696bc..f13222140b1 100644 --- a/release/scripts/startup/nodeitems_builtins.py +++ b/release/scripts/startup/nodeitems_builtins.py @@ -141,6 +141,20 @@ def object_shader_nodes_poll(context): snode.shader_type == 'OBJECT') +def cycles_shader_nodes_poll(context): + return context.scene.render.engine == 'CYCLES' + + +def object_cycles_shader_nodes_poll(context): + return (object_shader_nodes_poll(context) and + cycles_shader_nodes_poll(context)) + + +def object_eevee_shader_nodes_poll(context): + return (object_shader_nodes_poll(context) and + context.scene.render.engine == 'BLENDER_EEVEE') + + # All standard node categories currently used in nodes. shader_node_categories = [ @@ -216,36 +230,36 @@ shader_node_categories = [ NodeItem("NodeGroupInput", poll=group_input_output_item_poll), ]), ShaderNewNodeCategory("SH_NEW_OUTPUT", "Output", items=[ - NodeItem("ShaderNodeOutputMetallic", poll=object_shader_nodes_poll), - NodeItem("ShaderNodeOutputSpecular", poll=object_shader_nodes_poll), - NodeItem("ShaderNodeOutputMaterial", poll=object_shader_nodes_poll), - NodeItem("ShaderNodeOutputEeveeMaterial", poll=object_shader_nodes_poll), - NodeItem("ShaderNodeOutputLamp", poll=object_shader_nodes_poll), + NodeItem("ShaderNodeOutputMaterial", poll=object_cycles_shader_nodes_poll), + NodeItem("ShaderNodeOutputEeveeMaterial", poll=object_eevee_shader_nodes_poll), + NodeItem("ShaderNodeOutputLamp", poll=object_cycles_shader_nodes_poll), NodeItem("ShaderNodeOutputWorld", poll=world_shader_nodes_poll), NodeItem("ShaderNodeOutputLineStyle", poll=line_style_shader_nodes_poll), NodeItem("NodeGroupOutput", poll=group_input_output_item_poll), ]), ShaderNewNodeCategory("SH_NEW_SHADER", "Shader", items=[ - NodeItem("ShaderNodeMixShader"), - NodeItem("ShaderNodeAddShader"), - NodeItem("ShaderNodeBsdfDiffuse", poll=object_shader_nodes_poll), - NodeItem("ShaderNodeBsdfPrincipled", poll=object_shader_nodes_poll), - NodeItem("ShaderNodeBsdfGlossy", poll=object_shader_nodes_poll), - NodeItem("ShaderNodeBsdfTransparent", poll=object_shader_nodes_poll), - NodeItem("ShaderNodeBsdfRefraction", poll=object_shader_nodes_poll), - NodeItem("ShaderNodeBsdfGlass", poll=object_shader_nodes_poll), - NodeItem("ShaderNodeBsdfTranslucent", poll=object_shader_nodes_poll), - NodeItem("ShaderNodeBsdfAnisotropic", poll=object_shader_nodes_poll), - NodeItem("ShaderNodeBsdfVelvet", poll=object_shader_nodes_poll), - NodeItem("ShaderNodeBsdfToon", poll=object_shader_nodes_poll), - NodeItem("ShaderNodeSubsurfaceScattering", poll=object_shader_nodes_poll), - NodeItem("ShaderNodeEmission", poll=object_shader_nodes_poll), - NodeItem("ShaderNodeBsdfHair", poll=object_shader_nodes_poll), + NodeItem("ShaderNodeMixShader", poll=cycles_shader_nodes_poll), + NodeItem("ShaderNodeAddShader", poll=cycles_shader_nodes_poll), + NodeItem("ShaderNodeBsdfDiffuse", poll=object_cycles_shader_nodes_poll), + NodeItem("ShaderNodeBsdfPrincipled", poll=object_cycles_shader_nodes_poll), + NodeItem("ShaderNodeBsdfGlossy", poll=object_cycles_shader_nodes_poll), + NodeItem("ShaderNodeBsdfTransparent", poll=object_cycles_shader_nodes_poll), + NodeItem("ShaderNodeBsdfRefraction", poll=object_cycles_shader_nodes_poll), + NodeItem("ShaderNodeBsdfGlass", poll=object_cycles_shader_nodes_poll), + NodeItem("ShaderNodeBsdfTranslucent", poll=object_cycles_shader_nodes_poll), + NodeItem("ShaderNodeBsdfAnisotropic", poll=object_cycles_shader_nodes_poll), + NodeItem("ShaderNodeBsdfVelvet", poll=object_cycles_shader_nodes_poll), + NodeItem("ShaderNodeBsdfToon", poll=object_cycles_shader_nodes_poll), + NodeItem("ShaderNodeSubsurfaceScattering", poll=object_cycles_shader_nodes_poll), + NodeItem("ShaderNodeEmission", poll=object_cycles_shader_nodes_poll), + NodeItem("ShaderNodeBsdfHair", poll=object_cycles_shader_nodes_poll), NodeItem("ShaderNodeBackground", poll=world_shader_nodes_poll), - NodeItem("ShaderNodeAmbientOcclusion", poll=object_shader_nodes_poll), - NodeItem("ShaderNodeHoldout", poll=object_shader_nodes_poll), - NodeItem("ShaderNodeVolumeAbsorption"), - NodeItem("ShaderNodeVolumeScatter"), + NodeItem("ShaderNodeAmbientOcclusion", poll=object_cycles_shader_nodes_poll), + NodeItem("ShaderNodeHoldout", poll=object_cycles_shader_nodes_poll), + NodeItem("ShaderNodeVolumeAbsorption", poll=cycles_shader_nodes_poll), + NodeItem("ShaderNodeVolumeScatter", poll=cycles_shader_nodes_poll), + NodeItem("ShaderNodeEeveeMetallic", poll=object_eevee_shader_nodes_poll), + NodeItem("ShaderNodeEeveeSpecular", poll=object_eevee_shader_nodes_poll), ]), ShaderNewNodeCategory("SH_NEW_TEXTURE", "Texture", items=[ NodeItem("ShaderNodeTexImage"), diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 44846a12961..a668ae9a7af 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -794,8 +794,8 @@ struct ShadeResult; #define SH_NODE_UVALONGSTROKE 191 #define SH_NODE_TEX_POINTDENSITY 192 #define SH_NODE_BSDF_PRINCIPLED 193 -#define SH_NODE_OUTPUT_METALLIC 194 -#define SH_NODE_OUTPUT_SPECULAR 195 +#define SH_NODE_EEVEE_METALLIC 194 +#define SH_NODE_EEVEE_SPECULAR 195 #define SH_NODE_OUTPUT_EEVEE_MATERIAL 196 /* custom defines options for Material node */ diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 8d512f15949..8ccd652edd4 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -3587,11 +3587,11 @@ static void registerShaderNodes(void) register_node_type_sh_add_shader(); register_node_type_sh_uvmap(); register_node_type_sh_uvalongstroke(); + register_node_type_sh_eevee_metallic(); + register_node_type_sh_eevee_specular(); register_node_type_sh_output_lamp(); register_node_type_sh_output_material(); - register_node_type_sh_output_metallic(); - register_node_type_sh_output_specular(); register_node_type_sh_output_eevee_material(); register_node_type_sh_output_world(); register_node_type_sh_output_linestyle(); diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 97df428ee22..9379c605fe8 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -28,6 +28,8 @@ /* allow readfile to use deprecated functionality */ #define DNA_DEPRECATED_ALLOW +#include + #include "DNA_object_types.h" #include "DNA_camera_types.h" #include "DNA_gpu_types.h" @@ -47,12 +49,14 @@ #include "BKE_layer.h" #include "BKE_main.h" #include "BKE_mesh.h" +#include "BKE_node.h" #include "BKE_scene.h" #include "BKE_workspace.h" #include "BLI_listbase.h" #include "BLI_mempool.h" #include "BLI_string.h" +#include "BLI_utildefines.h" #include "BLO_readfile.h" #include "readfile.h" @@ -415,4 +419,25 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main) } } } + + { + { + /* Eevee shader nodes renamed because of the output node system. + * Note that a new output node is not being added here, because it would be overkill + * to handle this case in lib_verify_nodetree. */ + FOREACH_NODETREE(main, ntree, id) { + if (ntree->type == NTREE_SHADER) { + for (bNode *node = ntree->nodes.first; node; node = node->next) { + if (node->type == SH_NODE_EEVEE_METALLIC && STREQ(node->idname, "ShaderNodeOutputMetallic")) { + BLI_strncpy(node->idname, "ShaderNodeEeveeMetallic", sizeof(node->idname)); + } + + if (node->type == SH_NODE_EEVEE_SPECULAR && STREQ(node->idname, "ShaderNodeOutputSpecular")) { + BLI_strncpy(node->idname, "ShaderNodeEeveeSpecular", sizeof(node->idname)); + } + } + } + } FOREACH_NODETREE_END + } + } } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 9ad40ea802e..33382af9087 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -400,7 +400,7 @@ void ED_node_shader_default(const bContext *C, ID *id) if (BKE_scene_uses_blender_eevee(scene)) { output_type = SH_NODE_OUTPUT_EEVEE_MATERIAL; - shader_type = SH_NODE_OUTPUT_METALLIC; + shader_type = SH_NODE_EEVEE_METALLIC; } else if (BKE_scene_use_new_shading_nodes(scene)) { output_type = SH_NODE_OUTPUT_MATERIAL; diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index f423e541dc2..8b2e42a9e65 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -3875,7 +3875,7 @@ void world_normals_get(out vec3 N) N = gl_FrontFacing ? worldNormal : -worldNormal; } -void node_output_metallic( +void node_eevee_metallic( vec4 basecol, float metallic, float specular, float roughness, vec4 emissive, float transp, vec3 normal, float clearcoat, float clearcoat_roughness, vec3 clearcoat_normal, float occlusion, out vec4 result) @@ -3886,7 +3886,7 @@ void node_output_metallic( result = vec4(eevee_surface_lit(normal, diffuse.rgb, f0.rgb, roughness, occlusion) + emissive.rgb, 1.0 - transp); } -void node_output_specular( +void node_eevee_specular( vec4 diffuse, vec4 specular, float roughness, vec4 emissive, float transp, vec3 normal, float clearcoat, float clearcoat_roughness, vec3 clearcoat_normal, float occlusion, out vec4 result) diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 690011ec2aa..2c46791ae18 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -184,10 +184,10 @@ set(SRC shader/nodes/node_shader_normal_map.c shader/nodes/node_shader_object_info.c shader/nodes/node_shader_hair_info.c + shader/nodes/node_shader_eevee_metallic.c + shader/nodes/node_shader_eevee_specular.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_eevee_material.c shader/nodes/node_shader_output_world.c shader/nodes/node_shader_output_linestyle.c diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h index ffa255478ff..08c4924150e 100644 --- a/source/blender/nodes/NOD_shader.h +++ b/source/blender/nodes/NOD_shader.h @@ -117,11 +117,11 @@ void register_node_type_sh_mix_shader(void); void register_node_type_sh_add_shader(void); void register_node_type_sh_uvmap(void); void register_node_type_sh_uvalongstroke(void); +void register_node_type_sh_eevee_metallic(void); +void register_node_type_sh_eevee_specular(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_eevee_material(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 c4c99fdb256..d8944776cbb 100644 --- a/source/blender/nodes/NOD_static_types.h +++ b/source/blender/nodes/NOD_static_types.h @@ -67,9 +67,9 @@ 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, 0, "OUTPUT_METALLIC", OutputMetallic, "Material Metallic Output", "") -DefNode( ShaderNode, SH_NODE_OUTPUT_SPECULAR, 0, "OUTPUT_SPECULAR", OutputSpecular, "Material Specular Output", "") -DefNode( ShaderNode, SH_NODE_OUTPUT_EEVEE_MATERIAL, def_sh_output, "OUTPUT_EEVEE_MATERIAL", OutputEeveeMaterial, "Eevee Material Output", "") +DefNode( ShaderNode, SH_NODE_EEVEE_METALLIC, 0, "EEVEE_METALLIC", EeveeMetallic, "Metallic", "") +DefNode( ShaderNode, SH_NODE_EEVEE_SPECULAR, 0, "EEVEE_SPECULAR", EeveeSpecular, "Specular", "") +DefNode( ShaderNode, SH_NODE_OUTPUT_EEVEE_MATERIAL, def_sh_output, "OUTPUT_EEVEE_MATERIAL", OutputEeveeMaterial, "Material 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_eevee_metallic.c b/source/blender/nodes/shader/nodes/node_shader_eevee_metallic.c new file mode 100644 index 00000000000..23e927fa99b --- /dev/null +++ b/source/blender/nodes/shader/nodes/node_shader_eevee_metallic.c @@ -0,0 +1,88 @@ +/* + * ***** 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_eevee_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 bNodeSocketTemplate sh_node_eevee_metallic_out[] = { + { SOCK_SHADER, 0, N_("BSDF")}, + { -1, 0, "" } +}; + +static int node_shader_gpu_eevee_metallic(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) +{ + 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); + } + + return GPU_stack_link(mat, "node_eevee_metallic", in, out); +} + + +/* node type definition */ +void register_node_type_sh_eevee_metallic(void) +{ + static bNodeType ntype; + + sh_node_type_base(&ntype, SH_NODE_EEVEE_METALLIC, "Metallic", NODE_CLASS_SHADER, 0); + node_type_compatibility(&ntype, NODE_NEW_SHADING); + node_type_socket_templates(&ntype, sh_node_eevee_metallic_in, sh_node_eevee_metallic_out); + node_type_init(&ntype, NULL); + node_type_storage(&ntype, "", NULL, NULL); + node_type_gpu(&ntype, node_shader_gpu_eevee_metallic); + + nodeRegisterType(&ntype); +} diff --git a/source/blender/nodes/shader/nodes/node_shader_eevee_specular.c b/source/blender/nodes/shader/nodes/node_shader_eevee_specular.c new file mode 100644 index 00000000000..b8389814027 --- /dev/null +++ b/source/blender/nodes/shader/nodes/node_shader_eevee_specular.c @@ -0,0 +1,87 @@ +/* + * ***** 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_eevee_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 bNodeSocketTemplate sh_node_eevee_specular_out[] = { + { SOCK_SHADER, 0, N_("BSDF")}, + { -1, 0, "" } +}; + +static int node_shader_gpu_eevee_specular(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) +{ + 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); + } + + return GPU_stack_link(mat, "node_eevee_specular", in, out); +} + + +/* node type definition */ +void register_node_type_sh_eevee_specular(void) +{ + static bNodeType ntype; + + sh_node_type_base(&ntype, SH_NODE_EEVEE_SPECULAR, "Specular", NODE_CLASS_SHADER, 0); + node_type_compatibility(&ntype, NODE_NEW_SHADING); + node_type_socket_templates(&ntype, sh_node_eevee_specular_in, sh_node_eevee_specular_out); + node_type_init(&ntype, NULL); + node_type_storage(&ntype, "", NULL, NULL); + node_type_gpu(&ntype, node_shader_gpu_eevee_specular); + + nodeRegisterType(&ntype); +} diff --git a/source/blender/nodes/shader/nodes/node_shader_output_eevee_material.c b/source/blender/nodes/shader/nodes/node_shader_output_eevee_material.c index dcb7ada5a7a..ef3bf0e28d5 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_eevee_material.c +++ b/source/blender/nodes/shader/nodes/node_shader_output_eevee_material.c @@ -52,7 +52,7 @@ void register_node_type_sh_output_eevee_material(void) { static bNodeType ntype; - sh_node_type_base(&ntype, SH_NODE_OUTPUT_EEVEE_MATERIAL, "Eevee Material Output", NODE_CLASS_OUTPUT, 0); + sh_node_type_base(&ntype, SH_NODE_OUTPUT_EEVEE_MATERIAL, "Material Output", NODE_CLASS_OUTPUT, 0); node_type_compatibility(&ntype, NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_output_eevee_material_in, NULL); node_type_init(&ntype, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_output_metallic.c b/source/blender/nodes/shader/nodes/node_shader_output_metallic.c deleted file mode 100644 index cb2c06268d2..00000000000 --- a/source/blender/nodes/shader/nodes/node_shader_output_metallic.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * ***** 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 bNodeSocketTemplate sh_node_output_metallic_out[] = { - { SOCK_SHADER, 0, N_("BSDF")}, - { -1, 0, "" } -}; - -static int node_shader_gpu_output_metallic(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) -{ - 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); - } - - return GPU_stack_link(mat, "node_output_metallic", in, out); -} - - -/* 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_SHADER, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); - node_type_socket_templates(&ntype, sh_node_output_metallic_in, sh_node_output_metallic_out); - node_type_init(&ntype, NULL); - node_type_storage(&ntype, "", NULL, NULL); - node_type_gpu(&ntype, node_shader_gpu_output_metallic); - - 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 deleted file mode 100644 index 218a4357205..00000000000 --- a/source/blender/nodes/shader/nodes/node_shader_output_specular.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * ***** 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 bNodeSocketTemplate sh_node_output_specular_out[] = { - { SOCK_SHADER, 0, N_("BSDF")}, - { -1, 0, "" } -}; - -static int node_shader_gpu_output_specular(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) -{ - 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); - } - - return GPU_stack_link(mat, "node_output_specular", in, out); -} - - -/* 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_SHADER, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); - node_type_socket_templates(&ntype, sh_node_output_specular_in, sh_node_output_specular_out); - node_type_init(&ntype, NULL); - node_type_storage(&ntype, "", NULL, NULL); - node_type_gpu(&ntype, node_shader_gpu_output_specular); - - nodeRegisterType(&ntype); -} -- cgit v1.2.3