diff options
Diffstat (limited to 'source/blender/nodes/shader')
17 files changed, 82 insertions, 34 deletions
diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c index 758f7edfe49..efd0e48f41a 100644 --- a/source/blender/nodes/shader/node_shader_tree.c +++ b/source/blender/nodes/shader/node_shader_tree.c @@ -50,7 +50,7 @@ #include "GPU_material.h" -#include "RE_shader_ext.h" +#include "RE_texture.h" #include "NOD_common.h" @@ -535,7 +535,7 @@ static void ntree_shader_groups_flatten(bNodeTree *localtree) /* Check whether shader has a displacement. * - * Will also return a node and it's socket which is connected to a displacement + * Will also return a node and its socket which is connected to a displacement * output. Additionally, link which is attached to the displacement output is * also returned. */ diff --git a/source/blender/nodes/shader/node_shader_util.h b/source/blender/nodes/shader/node_shader_util.h index c1687e1a349..91454c3c982 100644 --- a/source/blender/nodes/shader/node_shader_util.h +++ b/source/blender/nodes/shader/node_shader_util.h @@ -63,7 +63,7 @@ #include "IMB_colormanagement.h" #include "RE_pipeline.h" -#include "RE_shader_ext.h" +#include "RE_texture.h" #include "GPU_material.h" #include "GPU_texture.h" diff --git a/source/blender/nodes/shader/nodes/node_shader_attribute.c b/source/blender/nodes/shader/nodes/node_shader_attribute.c index 4fd0ce4f1ef..9b3122e38e0 100644 --- a/source/blender/nodes/shader/nodes/node_shader_attribute.c +++ b/source/blender/nodes/shader/nodes/node_shader_attribute.c @@ -25,6 +25,7 @@ static bNodeSocketTemplate sh_node_attribute_out[] = { {SOCK_RGBA, N_("Color")}, {SOCK_VECTOR, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, {SOCK_FLOAT, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_FACTOR}, + {SOCK_FLOAT, N_("Alpha"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, PROP_FACTOR}, {-1, ""}, }; @@ -41,8 +42,9 @@ static int node_shader_gpu_attribute(GPUMaterial *mat, GPUNodeStack *out) { NodeShaderAttribute *attr = node->storage; + bool is_varying = attr->type == SHD_ATTRIBUTE_GEOMETRY; - if (GPU_material_is_volume_shader(mat)) { + if (GPU_material_is_volume_shader(mat) && is_varying) { if (out[0].hasoutput) { out[0].link = GPU_volume_grid(mat, attr->name, GPU_VOLUME_DEFAULT_0); } @@ -52,11 +54,23 @@ static int node_shader_gpu_attribute(GPUMaterial *mat, if (out[2].hasoutput) { out[2].link = GPU_volume_grid(mat, attr->name, GPU_VOLUME_DEFAULT_0); } + if (out[3].hasoutput) { + static const float default_alpha = 1.0f; + out[3].link = GPU_constant(&default_alpha); + } return 1; } - GPUNodeLink *cd_attr = GPU_attribute(mat, CD_AUTO_FROM_NAME, attr->name); + GPUNodeLink *cd_attr; + + if (is_varying) { + cd_attr = GPU_attribute(mat, CD_AUTO_FROM_NAME, attr->name); + } + else { + cd_attr = GPU_uniform_attribute(mat, attr->name, attr->type == SHD_ATTRIBUTE_INSTANCER); + } + GPU_stack_link(mat, node, "node_attribute", in, out, cd_attr); /* for each output. */ diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c index b0e17ed7716..7ce085d2c82 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c @@ -53,7 +53,10 @@ static int node_shader_gpu_bsdf_anisotropic(GPUMaterial *mat, GPU_material_flag_set(mat, GPU_MATFLAG_GLOSSY); - return GPU_stack_link(mat, node, "node_bsdf_anisotropic", in, out); + float use_multi_scatter = (node->custom1 == SHD_GLOSSY_MULTI_GGX) ? 1.0f : 0.0f; + + return GPU_stack_link( + mat, node, "node_bsdf_anisotropic", in, out, GPU_constant(&use_multi_scatter)); } /* node type definition */ diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c index cab25c7ddd0..e0fcce6f617 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c @@ -51,7 +51,15 @@ static int node_shader_gpu_bsdf_glass(GPUMaterial *mat, GPU_material_flag_set(mat, GPU_MATFLAG_GLOSSY | GPU_MATFLAG_REFRACT); - return GPU_stack_link(mat, node, "node_bsdf_glass", in, out, GPU_constant(&node->ssr_id)); + float use_multi_scatter = (node->custom1 == SHD_GLOSSY_MULTI_GGX) ? 1.0f : 0.0f; + + return GPU_stack_link(mat, + node, + "node_bsdf_glass", + in, + out, + GPU_constant(&use_multi_scatter), + GPU_constant(&node->ssr_id)); } /* node type definition */ diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c index 2bbd260fe0e..13b1b21c7fc 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c @@ -54,7 +54,15 @@ static int node_shader_gpu_bsdf_glossy(GPUMaterial *mat, GPU_material_flag_set(mat, GPU_MATFLAG_GLOSSY); - return GPU_stack_link(mat, node, "node_bsdf_glossy", in, out, GPU_constant(&node->ssr_id)); + float use_multi_scatter = (node->custom1 == SHD_GLOSSY_MULTI_GGX) ? 1.0f : 0.0f; + + return GPU_stack_link(mat, + node, + "node_bsdf_glossy", + in, + out, + GPU_constant(&use_multi_scatter), + GPU_constant(&node->ssr_id)); } /* node type definition */ diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c index 2f42b6429c7..e29b2ee1c5c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c @@ -34,7 +34,7 @@ static bNodeSocketTemplate sh_node_bsdf_hair_principled_in[] = { {SOCK_FLOAT, N_("IOR"), 1.55f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, {SOCK_FLOAT, N_("Offset"), - 2.0f * ((float)M_PI) / 180.f, + 2.0f * ((float)M_PI) / 180.0f, 0.0f, 0.0f, 0.0f, diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c index b9784e44053..b9f0e793a61 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c @@ -49,6 +49,7 @@ static bNodeSocketTemplate sh_node_bsdf_principled_in[] = { {SOCK_FLOAT, N_("Transmission"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, {SOCK_FLOAT, N_("Transmission Roughness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, {SOCK_RGBA, N_("Emission"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, + {SOCK_FLOAT, N_("Emission Strength"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000000.0f}, {SOCK_FLOAT, N_("Alpha"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, {SOCK_VECTOR, @@ -89,26 +90,26 @@ static int node_shader_gpu_bsdf_principled(GPUMaterial *mat, GPUNodeLink *sss_scale; /* Normals */ - if (!in[19].link) { - GPU_link(mat, "world_normals_get", &in[19].link); + if (!in[20].link) { + GPU_link(mat, "world_normals_get", &in[20].link); } /* Clearcoat Normals */ - if (!in[20].link) { - GPU_link(mat, "world_normals_get", &in[20].link); + if (!in[21].link) { + GPU_link(mat, "world_normals_get", &in[21].link); } #if 0 /* Not used at the moment. */ /* Tangents */ - if (!in[21].link) { + if (!in[22].link) { GPUNodeLink *orco = GPU_attribute(CD_ORCO, ""); - GPU_link(mat, "tangent_orco_z", orco, &in[21].link); + GPU_link(mat, "tangent_orco_z", orco, &in[22].link); GPU_link(mat, "node_tangent", GPU_builtin(GPU_WORLD_NORMAL), - in[21].link, + in[22].link, GPU_builtin(GPU_OBJECT_MATRIX), - &in[21].link); + &in[22].link); } #endif @@ -171,6 +172,8 @@ static int node_shader_gpu_bsdf_principled(GPUMaterial *mat, flag |= GPU_MATFLAG_SSS; } + float use_multi_scatter = (node->custom1 == SHD_GLOSSY_MULTI_GGX) ? 1.0f : 0.0f; + GPU_material_flag_set(mat, flag); return GPU_stack_link(mat, @@ -179,6 +182,7 @@ static int node_shader_gpu_bsdf_principled(GPUMaterial *mat, in, out, GPU_builtin(GPU_VIEW_POSITION), + GPU_constant(&use_multi_scatter), GPU_constant(&node->ssr_id), GPU_constant(&node->sss_id), sss_scale); diff --git a/source/blender/nodes/shader/nodes/node_shader_normal_map.c b/source/blender/nodes/shader/nodes/node_shader_normal_map.c index 7dd2ee9a4ac..493acb06963 100644 --- a/source/blender/nodes/shader/nodes/node_shader_normal_map.c +++ b/source/blender/nodes/shader/nodes/node_shader_normal_map.c @@ -82,7 +82,7 @@ static int gpu_shader_normal_map(GPUMaterial *mat, } const char *color_to_normal_fnc_name = "color_to_normal_new_shading"; - if (nm->space == SHD_SPACE_BLENDER_OBJECT || nm->space == SHD_SPACE_BLENDER_WORLD) { + if (ELEM(nm->space, SHD_SPACE_BLENDER_OBJECT, SHD_SPACE_BLENDER_WORLD)) { color_to_normal_fnc_name = "color_to_blender_normal_new_shading"; } diff --git a/source/blender/nodes/shader/nodes/node_shader_output_material.c b/source/blender/nodes/shader/nodes/node_shader_output_material.c index 578262e9f17..fb0b6e7b263 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_material.c +++ b/source/blender/nodes/shader/nodes/node_shader_output_material.c @@ -45,18 +45,29 @@ static int node_shader_gpu_output_material(GPUMaterial *mat, GPUNodeStack *in, GPUNodeStack *out) { - GPUNodeLink *outlink, *alpha_threshold_link; - + GPUNodeLink *outlink, *alpha_threshold_link, *shadow_threshold_link; Material *ma = GPU_material_get_material(mat); - if (ma && ma->blend_method == MA_BM_CLIP) { - alpha_threshold_link = GPU_uniform(&ma->alpha_threshold); + + static float no_alpha_threshold = -1.0f; + if (ma) { + alpha_threshold_link = GPU_uniform((ma->blend_method == MA_BM_CLIP) ? &ma->alpha_threshold : + &no_alpha_threshold); + shadow_threshold_link = GPU_uniform((ma->blend_shadow == MA_BS_CLIP) ? &ma->alpha_threshold : + &no_alpha_threshold); } else { - static float no_alpha_threshold = -1.0f; alpha_threshold_link = GPU_uniform(&no_alpha_threshold); + shadow_threshold_link = GPU_uniform(&no_alpha_threshold); } - GPU_stack_link(mat, node, "node_output_material", in, out, alpha_threshold_link, &outlink); + GPU_stack_link(mat, + node, + "node_output_material", + in, + out, + alpha_threshold_link, + shadow_threshold_link, + &outlink); GPU_material_output_link(mat, outlink); return true; diff --git a/source/blender/nodes/shader/nodes/node_shader_particle_info.c b/source/blender/nodes/shader/nodes/node_shader_particle_info.c index b646e806e6e..c6eabc3b2cb 100644 --- a/source/blender/nodes/shader/nodes/node_shader_particle_info.c +++ b/source/blender/nodes/shader/nodes/node_shader_particle_info.c @@ -18,7 +18,7 @@ */ #include "../node_shader_util.h" -#include "RE_shader_ext.h" +#include "RE_texture.h" static bNodeSocketTemplate outputs[] = { {SOCK_FLOAT, "Index"}, diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc index c1543f791f1..59b89c46fc7 100644 --- a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc +++ b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc @@ -101,7 +101,7 @@ void register_node_type_sh_seprgb(void) sh_fn_node_type_base(&ntype, SH_NODE_SEPRGB, "Separate RGB", NODE_CLASS_CONVERTOR, 0); node_type_socket_templates(&ntype, sh_node_seprgb_in, sh_node_seprgb_out); - node_type_exec(&ntype, NULL, NULL, node_shader_exec_seprgb); + node_type_exec(&ntype, nullptr, nullptr, node_shader_exec_seprgb); node_type_gpu(&ntype, gpu_shader_seprgb); ntype.expand_in_mf_network = sh_node_seprgb_expand_in_mf_network; @@ -159,7 +159,7 @@ void register_node_type_sh_combrgb(void) sh_fn_node_type_base(&ntype, SH_NODE_COMBRGB, "Combine RGB", NODE_CLASS_CONVERTOR, 0); node_type_socket_templates(&ntype, sh_node_combrgb_in, sh_node_combrgb_out); - node_type_exec(&ntype, NULL, NULL, node_shader_exec_combrgb); + node_type_exec(&ntype, nullptr, nullptr, node_shader_exec_combrgb); node_type_gpu(&ntype, gpu_shader_combrgb); ntype.expand_in_mf_network = sh_node_combrgb_expand_in_mf_network; diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c index 38e79ebe94d..41c978e75ba 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c @@ -57,7 +57,7 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat, NodeTexImage *tex_original = node_original->storage; ImageUser *iuser = &tex_original->iuser; eGPUSamplerState sampler = GPU_SAMPLER_REPEAT | GPU_SAMPLER_ANISO | GPU_SAMPLER_FILTER; - /* TODO(fclem) For now assume mipmap is always enabled. */ + /* TODO(fclem): For now assume mipmap is always enabled. */ if (true) { sampler |= GPU_SAMPLER_MIPMAP; } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c index 1a78d2f5bf2..09d06c35a5f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c @@ -93,7 +93,7 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, if (tex->interpolation != SHD_INTERP_CLOSEST) { sampler_state |= GPU_SAMPLER_ANISO | GPU_SAMPLER_FILTER; - /* TODO(fclem) For now assume mipmap is always enabled. */ + /* TODO(fclem): For now assume mipmap is always enabled. */ sampler_state |= true ? GPU_SAMPLER_MIPMAP : 0; } const bool use_cubic = ELEM(tex->interpolation, SHD_INTERP_CUBIC, SHD_INTERP_SMART); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c b/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c index fae1fb283ed..14cd1fd4c0c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c @@ -19,7 +19,7 @@ #include "../node_shader_util.h" -#include "RE_render_ext.h" +#include "RE_texture.h" /* **************** OUTPUT ******************** */ diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc b/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc index 7b4e568e923..a86a8bb8935 100644 --- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc +++ b/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc @@ -74,7 +74,7 @@ static int gpu_shader_valtorgb(GPUMaterial *mat, float *array, layer; int size; - /* Common / easy case optimisation. */ + /* Common / easy case optimization. */ if ((coba->tot <= 2) && (coba->color_mode == COLBAND_BLEND_RGB)) { float mul_bias[2]; switch (coba->ipotype) { @@ -172,7 +172,7 @@ void register_node_type_sh_valtorgb(void) node_type_init(&ntype, node_shader_init_valtorgb); node_type_size_preset(&ntype, NODE_SIZE_LARGE); node_type_storage(&ntype, "ColorBand", node_free_standard_storage, node_copy_standard_storage); - node_type_exec(&ntype, NULL, NULL, node_shader_exec_valtorgb); + node_type_exec(&ntype, nullptr, nullptr, node_shader_exec_valtorgb); node_type_gpu(&ntype, gpu_shader_valtorgb); ntype.expand_in_mf_network = sh_node_valtorgb_expand_in_mf_network; @@ -215,7 +215,7 @@ void register_node_type_sh_rgbtobw(void) sh_node_type_base(&ntype, SH_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTOR, 0); node_type_socket_templates(&ntype, sh_node_rgbtobw_in, sh_node_rgbtobw_out); - node_type_exec(&ntype, NULL, NULL, node_shader_exec_rgbtobw); + node_type_exec(&ntype, nullptr, nullptr, node_shader_exec_rgbtobw); node_type_gpu(&ntype, gpu_shader_rgbtobw); nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_value.cc b/source/blender/nodes/shader/nodes/node_shader_value.cc index 1a1382fa8af..5a8a1b847cc 100644 --- a/source/blender/nodes/shader/nodes/node_shader_value.cc +++ b/source/blender/nodes/shader/nodes/node_shader_value.cc @@ -51,7 +51,7 @@ void register_node_type_sh_value(void) static bNodeType ntype; sh_fn_node_type_base(&ntype, SH_NODE_VALUE, "Value", NODE_CLASS_INPUT, 0); - node_type_socket_templates(&ntype, NULL, sh_node_value_out); + node_type_socket_templates(&ntype, nullptr, sh_node_value_out); node_type_gpu(&ntype, gpu_shader_value); ntype.expand_in_mf_network = sh_node_value_expand_in_mf_network; |