Eevee: Convert metallic nodes into princinpled nodes

And wipe metallic out of the map.
This commit is contained in:
Dalai Felinto 2017-08-18 16:40:04 +02:00
parent e8f0ee157b
commit 036f43f3cd
10 changed files with 51 additions and 134 deletions

View File

@ -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=[

View File

@ -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 */

View File

@ -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();

View File

@ -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;
else if (node->type == SH_NODE_EEVEE_SPECULAR && STREQ(node->idname, "ShaderNodeOutputSpecular")) {
BLI_strncpy(node->idname, "ShaderNodeEeveeSpecular", sizeof(node->idname));
error = true;
}
/* 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;
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));
}
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 |= 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 == 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");
}
}
}

View File

@ -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;

View File

@ -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,

View File

@ -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

View File

@ -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", "" )

View File

@ -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:

View File

@ -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);
}