diff options
-rw-r--r-- | release/scripts/startup/nodeitems_builtins.py | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_node.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 1 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_280.c | 76 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_edit.c | 2 | ||||
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_material.glsl | 13 | ||||
-rw-r--r-- | source/blender/nodes/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/nodes/NOD_static_types.h | 1 | ||||
-rw-r--r-- | source/blender/nodes/shader/node_shader_tree.c | 1 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_eevee_metallic.c | 88 |
10 files changed, 51 insertions, 134 deletions
diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py index 71caf207134..341efd78f5e 100644 --- a/release/scripts/startup/nodeitems_builtins.py +++ b/release/scripts/startup/nodeitems_builtins.py @@ -278,7 +278,6 @@ shader_node_categories = [ NodeItem("ShaderNodeHoldout", poll=object_cycles_shader_nodes_poll), NodeItem("ShaderNodeVolumeAbsorption", poll=volume_shader_nodes_poll), NodeItem("ShaderNodeVolumeScatter", poll=volume_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=[ diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index fd690a917a0..5e50d37e145 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -796,7 +796,6 @@ struct ShadeResult; #define SH_NODE_UVALONGSTROKE 191 #define SH_NODE_TEX_POINTDENSITY 192 #define SH_NODE_BSDF_PRINCIPLED 193 -#define SH_NODE_EEVEE_METALLIC 194 #define SH_NODE_EEVEE_SPECULAR 195 /* custom defines options for Material node */ diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index d53fe68eb99..ed1e2fe1c19 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -3594,7 +3594,6 @@ 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(); diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index ce452d58565..810bf5a3a46 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -433,37 +433,61 @@ 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. */ - bool error = false; - 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)); - error = true; - } + typedef enum eNTreeDoVersionErrors { + NTREE_DOVERSION_NO_ERROR = 0, + NTREE_DOVERSION_NEED_OUTPUT = (1 << 0), + NTREE_DOVERSION_TRANSPARENCY_EMISSION = (1 << 1), + } eNTreeDoVersionErrors; + + /* 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. + * + * Also, metallic node is now unified into the principled node. */ + eNTreeDoVersionErrors error = NTREE_DOVERSION_NO_ERROR; + + FOREACH_NODETREE(main, ntree, id) { + if (ntree->type == NTREE_SHADER) { + for (bNode *node = ntree->nodes.first; node; node = node->next) { + if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ && + STREQ(node->idname, "ShaderNodeOutputMetallic")) + { + BLI_strncpy(node->idname, "ShaderNodeEeveeMetallic", sizeof(node->idname)); + error |= NTREE_DOVERSION_NEED_OUTPUT; + } - else if (node->type == SH_NODE_EEVEE_SPECULAR && STREQ(node->idname, "ShaderNodeOutputSpecular")) { - BLI_strncpy(node->idname, "ShaderNodeEeveeSpecular", sizeof(node->idname)); - error = true; - } + else if (node->type == SH_NODE_EEVEE_SPECULAR && STREQ(node->idname, "ShaderNodeOutputSpecular")) { + BLI_strncpy(node->idname, "ShaderNodeEeveeSpecular", sizeof(node->idname)); + error |= NTREE_DOVERSION_NEED_OUTPUT; + } - else if (node->type == 196 /* SH_NODE_OUTPUT_EEVEE_MATERIAL */ && - STREQ(node->idname, "ShaderNodeOutputEeveeMaterial")) - { - node->type = SH_NODE_OUTPUT_MATERIAL; - BLI_strncpy(node->idname, "ShaderNodeOutputMaterial", sizeof(node->idname)); - } + else if (node->type == 196 /* SH_NODE_OUTPUT_EEVEE_MATERIAL */ && + STREQ(node->idname, "ShaderNodeOutputEeveeMaterial")) + { + node->type = SH_NODE_OUTPUT_MATERIAL; + BLI_strncpy(node->idname, "ShaderNodeOutputMaterial", sizeof(node->idname)); + } + + else if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ && + STREQ(node->idname, "ShaderNodeEeveeMetallic")) + { + node->type = SH_NODE_BSDF_PRINCIPLED; + BLI_strncpy(node->idname, "ShaderNodeBsdfPrincipled", sizeof(node->idname)); + node->custom1 = SHD_GLOSSY_MULTI_GGX; + error |= NTREE_DOVERSION_TRANSPARENCY_EMISSION; } } - } FOREACH_NODETREE_END - if (error) { - BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console"); - printf("You need to connect Eevee Metallic and Specular shader nodes to new material output nodes.\n"); } + } FOREACH_NODETREE_END + + if (error & NTREE_DOVERSION_NEED_OUTPUT) { + BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console"); + printf("You need to connect Principled and Eevee Specular shader nodes to new material output nodes.\n"); + } + + if (error & NTREE_DOVERSION_TRANSPARENCY_EMISSION) { + BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console"); + printf("You need to combine transparency and emission shaders to the converted Principled shader nodes.\n"); } } } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index b5d6104432f..fa3508ecfd1 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_MATERIAL; - shader_type = SH_NODE_EEVEE_METALLIC; + shader_type = SH_NODE_BSDF_PRINCIPLED; } 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 b8b2b6a4d56..2470b607b07 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -4055,19 +4055,6 @@ void world_normals_get(out vec3 N) N = gl_FrontFacing ? worldNormal : -worldNormal; } -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, float ssr_id, out Closure result) -{ - vec3 diffuse, f0, ssr_spec; - convert_metallic_to_specular(basecol.rgb, metallic, specular, diffuse, f0); - - vec3 L = eevee_surface_lit(normal, diffuse, f0, roughness, occlusion, int(ssr_id), ssr_spec); - vec3 vN = normalize(mat3(ViewMatrix) * normal); - result = Closure(L + emissive.rgb, 1.0 - transp, vec4(ssr_spec, roughness), normal_encode(vN, viewCameraVec), int(ssr_id)); -} - void node_eevee_specular( vec4 diffuse, vec4 specular, float roughness, vec4 emissive, float transp, vec3 normal, float clearcoat, float clearcoat_roughness, vec3 clearcoat_normal, diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 03912c95940..d65b71a35e5 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -184,7 +184,6 @@ 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 diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h index 490ef91f660..783e1a388c1 100644 --- a/source/blender/nodes/NOD_static_types.h +++ b/source/blender/nodes/NOD_static_types.h @@ -67,7 +67,6 @@ 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_EEVEE_METALLIC, 0, "EEVEE_METALLIC", EeveeMetallic, "Metallic", "") DefNode( ShaderNode, SH_NODE_EEVEE_SPECULAR, 0, "EEVEE_SPECULAR", EeveeSpecular, "Specular", "") 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", "" ) diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c index b90297cc631..35a8c712905 100644 --- a/source/blender/nodes/shader/node_shader_tree.c +++ b/source/blender/nodes/shader/node_shader_tree.c @@ -482,7 +482,6 @@ static bool ntree_tag_ssr_bsdf_cb(bNode *fromnode, bNode *UNUSED(tonode), void * { switch (fromnode->type) { case SH_NODE_BSDF_ANISOTROPIC: - case SH_NODE_EEVEE_METALLIC: case SH_NODE_EEVEE_SPECULAR: case SH_NODE_BSDF_PRINCIPLED: case SH_NODE_BSDF_GLOSSY: diff --git a/source/blender/nodes/shader/nodes/node_shader_eevee_metallic.c b/source/blender/nodes/shader/nodes/node_shader_eevee_metallic.c deleted file mode 100644 index 071486493fa..00000000000 --- a/source/blender/nodes/shader/nodes/node_shader_eevee_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_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 *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, "node_eevee_metallic", in, out, GPU_uniform(&node->ssr_id)); -} - - -/* 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); -} |