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.
This commit is contained in:
Luca Rood 2017-06-20 14:33:13 +02:00
parent aaf37e1216
commit 5c5c09439a
12 changed files with 94 additions and 55 deletions

View File

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

View File

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

View File

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

View File

@ -28,6 +28,8 @@
/* allow readfile to use deprecated functionality */
#define DNA_DEPRECATED_ALLOW
#include <string.h>
#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
}
}
}

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

View File

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

View File

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

View File

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

View File

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

View File

@ -29,7 +29,7 @@
/* **************** OUTPUT ******************** */
static bNodeSocketTemplate sh_node_output_metallic_in[] = {
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},
@ -44,12 +44,12 @@ static bNodeSocketTemplate sh_node_output_metallic_in[] = {
{ -1, 0, "" }
};
static bNodeSocketTemplate sh_node_output_metallic_out[] = {
static bNodeSocketTemplate sh_node_eevee_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 int node_shader_gpu_eevee_metallic(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
static float one = 1.0f;
@ -68,21 +68,21 @@ static int node_shader_gpu_output_metallic(GPUMaterial *mat, bNode *UNUSED(node)
GPU_link(mat, "set_value", GPU_uniform(&one), &in[10].link);
}
return GPU_stack_link(mat, "node_output_metallic", in, out);
return GPU_stack_link(mat, "node_eevee_metallic", in, out);
}
/* node type definition */
void register_node_type_sh_output_metallic(void)
void register_node_type_sh_eevee_metallic(void)
{
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_OUTPUT_METALLIC, "Metallic Material Output", NODE_CLASS_SHADER, 0);
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_output_metallic_in, sh_node_output_metallic_out);
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_output_metallic);
node_type_gpu(&ntype, node_shader_gpu_eevee_metallic);
nodeRegisterType(&ntype);
}

View File

@ -29,7 +29,7 @@
/* **************** OUTPUT ******************** */
static bNodeSocketTemplate sh_node_output_specular_in[] = {
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},
@ -43,12 +43,12 @@ static bNodeSocketTemplate sh_node_output_specular_in[] = {
{ -1, 0, "" }
};
static bNodeSocketTemplate sh_node_output_specular_out[] = {
static bNodeSocketTemplate sh_node_eevee_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 int node_shader_gpu_eevee_specular(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
static float one = 1.0f;
@ -67,21 +67,21 @@ static int node_shader_gpu_output_specular(GPUMaterial *mat, bNode *UNUSED(node)
GPU_link(mat, "set_value", GPU_uniform(&one), &in[9].link);
}
return GPU_stack_link(mat, "node_output_specular", in, out);
return GPU_stack_link(mat, "node_eevee_specular", in, out);
}
/* node type definition */
void register_node_type_sh_output_specular(void)
void register_node_type_sh_eevee_specular(void)
{
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_OUTPUT_SPECULAR, "Specular Material Output", NODE_CLASS_SHADER, 0);
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_output_specular_in, sh_node_output_specular_out);
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_output_specular);
node_type_gpu(&ntype, node_shader_gpu_eevee_specular);
nodeRegisterType(&ntype);
}

View File

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