diff options
author | Hans Goudey <h.goudey@me.com> | 2020-08-12 04:59:16 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-08-12 04:59:16 +0300 |
commit | ef11238c743e6985fe325280fb13e05d6ec27378 (patch) | |
tree | 1dd2605a676bee52296535825b99f000a9c255eb /source/blender/nodes/shader/nodes | |
parent | 1f768bbe4145daed111636ca09dd53b25b8d29b5 (diff) | |
parent | ec5f39208785c1bbe723054ffe69e1ac2ab470dd (diff) |
Merge branch 'master' into property-search-uiproperty-search-ui
Diffstat (limited to 'source/blender/nodes/shader/nodes')
18 files changed, 83 insertions, 96 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_attribute.c b/source/blender/nodes/shader/nodes/node_shader_attribute.c index 6b5d46e250b..116bc181997 100644 --- a/source/blender/nodes/shader/nodes/node_shader_attribute.c +++ b/source/blender/nodes/shader/nodes/node_shader_attribute.c @@ -55,17 +55,16 @@ static int node_shader_gpu_attribute(GPUMaterial *mat, return 1; } - else { - GPUNodeLink *cd_attr = GPU_attribute(mat, CD_AUTO_FROM_NAME, attr->name); - GPU_stack_link(mat, node, "node_attribute", in, out, cd_attr); - /* for each output. */ - for (int i = 0; sh_node_attribute_out[i].type != -1; i++) { - node_shader_gpu_bump_tex_coord(mat, node, &out[i].link); - } + GPUNodeLink *cd_attr = GPU_attribute(mat, CD_AUTO_FROM_NAME, attr->name); + GPU_stack_link(mat, node, "node_attribute", in, out, cd_attr); - return 1; + /* for each output. */ + for (int i = 0; sh_node_attribute_out[i].type != -1; i++) { + node_shader_gpu_bump_tex_coord(mat, node, &out[i].link); } + + return 1; } /* node type definition */ diff --git a/source/blender/nodes/shader/nodes/node_shader_clamp.cc b/source/blender/nodes/shader/nodes/node_shader_clamp.cc index 1077f616a62..d3a893e1d76 100644 --- a/source/blender/nodes/shader/nodes/node_shader_clamp.cc +++ b/source/blender/nodes/shader/nodes/node_shader_clamp.cc @@ -60,9 +60,8 @@ static void sh_node_clamp_expand_in_mf_network(blender::nodes::NodeMFNetworkBuil if (a < b) { return clamp_f(value, a, b); } - else { - return clamp_f(value, b, a); - } + + return clamp_f(value, b, a); }}; int clamp_type = builder.bnode().custom1; diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.c b/source/blender/nodes/shader/nodes/node_shader_curves.c index 68f252cb092..42299a193e2 100644 --- a/source/blender/nodes/shader/nodes/node_shader_curves.c +++ b/source/blender/nodes/shader/nodes/node_shader_curves.c @@ -168,7 +168,7 @@ static int gpu_shader_curve_rgb(GPUMaterial *mat, CurveMapping *cumap = node->storage; - BKE_curvemapping_initialize(cumap); + BKE_curvemapping_init(cumap); BKE_curvemapping_table_RGBA(cumap, &array, &size); GPUNodeLink *tex = GPU_color_band(mat, size, array, &layer); @@ -215,20 +215,19 @@ static int gpu_shader_curve_rgb(GPUMaterial *mat, GPU_uniform(range_rgba), GPU_uniform(ext_rgba[3])); } - else { - return GPU_stack_link(mat, - node, - "curves_rgb", - in, - out, - tex, - GPU_constant(&layer), - GPU_uniform(range_rgba), - GPU_uniform(ext_rgba[0]), - GPU_uniform(ext_rgba[1]), - GPU_uniform(ext_rgba[2]), - GPU_uniform(ext_rgba[3])); - } + + return GPU_stack_link(mat, + node, + "curves_rgb", + in, + out, + tex, + GPU_constant(&layer), + GPU_uniform(range_rgba), + GPU_uniform(ext_rgba[0]), + GPU_uniform(ext_rgba[1]), + GPU_uniform(ext_rgba[2]), + GPU_uniform(ext_rgba[3])); } void register_node_type_sh_curve_rgb(void) diff --git a/source/blender/nodes/shader/nodes/node_shader_displacement.c b/source/blender/nodes/shader/nodes/node_shader_displacement.c index 22fbe4e4da6..649aad370c0 100644 --- a/source/blender/nodes/shader/nodes/node_shader_displacement.c +++ b/source/blender/nodes/shader/nodes/node_shader_displacement.c @@ -64,10 +64,9 @@ static int gpu_shader_displacement(GPUMaterial *mat, return GPU_stack_link( mat, node, "node_displacement_object", in, out, GPU_builtin(GPU_OBJECT_MATRIX)); } - else { - return GPU_stack_link( - mat, node, "node_displacement_world", in, out, GPU_builtin(GPU_OBJECT_MATRIX)); - } + + return GPU_stack_link( + mat, node, "node_displacement_world", in, out, GPU_builtin(GPU_OBJECT_MATRIX)); } /* node type definition */ diff --git a/source/blender/nodes/shader/nodes/node_shader_geometry.c b/source/blender/nodes/shader/nodes/node_shader_geometry.c index deb0ee9037c..f66633e64c8 100644 --- a/source/blender/nodes/shader/nodes/node_shader_geometry.c +++ b/source/blender/nodes/shader/nodes/node_shader_geometry.c @@ -42,9 +42,12 @@ static int node_shader_gpu_geometry(GPUMaterial *mat, { /* HACK: Don't request GPU_BARYCENTRIC_TEXCO if not used because it will * trigger the use of geometry shader (and the performance penalty it implies). */ - float val[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float val[4] = {0.0f, 0.0f, 0.0f, 0.0f}; GPUNodeLink *bary_link = (!out[5].hasoutput) ? GPU_constant(val) : GPU_builtin(GPU_BARYCENTRIC_TEXCO); + if (out[5].hasoutput) { + GPU_material_flag_set(mat, GPU_MATFLAG_BARYCENTRIC); + } /* Opti: don't request orco if not needed. */ GPUNodeLink *orco_link = (!out[2].hasoutput) ? GPU_constant(val) : GPU_attribute(mat, CD_ORCO, ""); diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.c b/source/blender/nodes/shader/nodes/node_shader_mapping.c index 6750acf5ee1..774e7fed029 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mapping.c +++ b/source/blender/nodes/shader/nodes/node_shader_mapping.c @@ -53,9 +53,8 @@ static int gpu_shader_mapping(GPUMaterial *mat, if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) { return GPU_stack_link(mat, node, names[node->custom1], in, out); } - else { - return 0; - } + + return 0; } static void node_shader_update_mapping(bNodeTree *UNUSED(ntree), bNode *node) diff --git a/source/blender/nodes/shader/nodes/node_shader_math.cc b/source/blender/nodes/shader/nodes/node_shader_math.cc index c7035da8c70..e7bbadfbcb0 100644 --- a/source/blender/nodes/shader/nodes/node_shader_math.cc +++ b/source/blender/nodes/shader/nodes/node_shader_math.cc @@ -141,9 +141,8 @@ static int gpu_shader_math(GPUMaterial *mat, } return ret; } - else { - return 0; - } + + return 0; } static const blender::fn::MultiFunction &get_base_multi_function( diff --git a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c index 93e88664d1a..8725122b12c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c @@ -91,16 +91,15 @@ static int gpu_shader_mix_rgb(GPUMaterial *mat, if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) { int ret = GPU_stack_link(mat, node, names[node->custom1], in, out); if (ret && node->custom2 & SHD_MIXRGB_CLAMP) { - float min[3] = {0.0f, 0.0f, 0.0f}; - float max[3] = {1.0f, 1.0f, 1.0f}; + const float min[3] = {0.0f, 0.0f, 0.0f}; + const float max[3] = {1.0f, 1.0f, 1.0f}; GPU_link( mat, "clamp_color", out[0].link, GPU_constant(min), GPU_constant(max), &out[0].link); } return ret; } - else { - return 0; - } + + return 0; } void register_node_type_sh_mix_rgb(void) diff --git a/source/blender/nodes/shader/nodes/node_shader_tangent.c b/source/blender/nodes/shader/nodes/node_shader_tangent.c index e8bedde0a62..2c12bf9bc01 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tangent.c +++ b/source/blender/nodes/shader/nodes/node_shader_tangent.c @@ -45,28 +45,27 @@ static int node_shader_gpu_tangent(GPUMaterial *mat, return GPU_stack_link( mat, node, "node_tangentmap", in, out, GPU_attribute(mat, CD_TANGENT, attr->uv_map)); } - else { - GPUNodeLink *orco = GPU_attribute(mat, CD_ORCO, ""); - if (attr->axis == SHD_TANGENT_AXIS_X) { - GPU_link(mat, "tangent_orco_x", orco, &orco); - } - else if (attr->axis == SHD_TANGENT_AXIS_Y) { - GPU_link(mat, "tangent_orco_y", orco, &orco); - } - else { - GPU_link(mat, "tangent_orco_z", orco, &orco); - } + GPUNodeLink *orco = GPU_attribute(mat, CD_ORCO, ""); - return GPU_stack_link(mat, - node, - "node_tangent", - in, - out, - GPU_builtin(GPU_WORLD_NORMAL), - orco, - GPU_builtin(GPU_OBJECT_MATRIX)); + if (attr->axis == SHD_TANGENT_AXIS_X) { + GPU_link(mat, "tangent_orco_x", orco, &orco); + } + else if (attr->axis == SHD_TANGENT_AXIS_Y) { + GPU_link(mat, "tangent_orco_y", orco, &orco); } + else { + GPU_link(mat, "tangent_orco_z", orco, &orco); + } + + return GPU_stack_link(mat, + node, + "node_tangent", + in, + out, + GPU_builtin(GPU_WORLD_NORMAL), + orco, + GPU_builtin(GPU_OBJECT_MATRIX)); } /* node type definition */ 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 0cf4b51f307..38e79ebe94d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c @@ -19,8 +19,6 @@ #include "../node_shader_util.h" -#include "GPU_draw.h" - /* **************** OUTPUT ******************** */ static bNodeSocketTemplate sh_node_tex_environment_in[] = { @@ -59,7 +57,8 @@ 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; - if (GPU_get_mipmap()) { + /* 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 cbda72cd228..1a78d2f5bf2 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c @@ -19,8 +19,6 @@ #include "../node_shader_util.h" -#include "GPU_draw.h" - /* **************** OUTPUT ******************** */ static bNodeSocketTemplate sh_node_tex_image_in[] = { @@ -95,7 +93,8 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, if (tex->interpolation != SHD_INTERP_CLOSEST) { sampler_state |= GPU_SAMPLER_ANISO | GPU_SAMPLER_FILTER; - sampler_state |= GPU_get_mipmap() ? GPU_SAMPLER_MIPMAP : 0; + /* 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_sky.c b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c index 94ffbbe0c55..9ef05d781bd 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c @@ -170,7 +170,7 @@ static int node_shader_gpu_tex_sky(GPUMaterial *mat, GPU_uniform(xyz_to_rgb.g), GPU_uniform(xyz_to_rgb.b)); } - else if (tex->sky_model == 1) { + if (tex->sky_model == 1) { /* Hosek / Wilkie */ sun_angles[0] = fmin(M_PI_2, sun_angles[0]); /* clamp to horizon */ SKY_ArHosekSkyModelState *sky_state = SKY_arhosek_xyz_skymodelstate_alloc_init( @@ -210,9 +210,8 @@ static int node_shader_gpu_tex_sky(GPUMaterial *mat, GPU_uniform(xyz_to_rgb.g), GPU_uniform(xyz_to_rgb.b)); } - else { - return GPU_stack_link(mat, node, "node_tex_sky_nishita", in, out); - } + + return GPU_stack_link(mat, node, "node_tex_sky_nishita", in, out); } static void node_shader_update_sky(bNodeTree *UNUSED(ntree), bNode *node) diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.c b/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.c index 817ccdc8b6a..56ecb6d4476 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.c @@ -54,9 +54,8 @@ static int gpu_shader_tex_white_noise(GPUMaterial *mat, if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) { return GPU_stack_link(mat, node, names[node->custom1], in, out); } - else { - return 0; - } + + return 0; } static void node_shader_update_tex_white_noise(bNodeTree *UNUSED(ntree), bNode *node) diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc b/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc index 7f712b0db40..7b4e568e923 100644 --- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc +++ b/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc @@ -121,9 +121,8 @@ static int gpu_shader_valtorgb(GPUMaterial *mat, if (coba->ipotype == COLBAND_INTERP_CONSTANT) { return GPU_stack_link(mat, node, "valtorgb_nearest", in, out, tex, GPU_constant(&layer)); } - else { - return GPU_stack_link(mat, node, "valtorgb", in, out, tex, GPU_constant(&layer)); - } + + return GPU_stack_link(mat, node, "valtorgb", in, out, tex, GPU_constant(&layer)); } class ColorBandFunction : public blender::fn::MultiFunction { diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c b/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c index c9f79293328..0e82f346529 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c +++ b/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c @@ -55,13 +55,12 @@ static int gpu_shader_vector_displacement(GPUMaterial *mat, GPU_builtin(GPU_OBJECT_MATRIX), GPU_builtin(GPU_VIEW_MATRIX)); } - else if (node->custom1 == SHD_SPACE_OBJECT) { + if (node->custom1 == SHD_SPACE_OBJECT) { return GPU_stack_link( mat, node, "node_vector_displacement_object", in, out, GPU_builtin(GPU_OBJECT_MATRIX)); } - else { - return GPU_stack_link(mat, node, "node_vector_displacement_world", in, out); - } + + return GPU_stack_link(mat, node, "node_vector_displacement_world", in, out); } /* node type definition */ diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc index c18ad8bb244..e8396c7cfc1 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc +++ b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc @@ -103,9 +103,8 @@ static int gpu_shader_vector_math(GPUMaterial *mat, if (name != nullptr) { return GPU_stack_link(mat, node, name, in, out); } - else { - return 0; - } + + return 0; } static void node_shader_update_vector_math(bNodeTree *UNUSED(ntree), bNode *node) diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_rotate.c b/source/blender/nodes/shader/nodes/node_shader_vector_rotate.c index 46a6ff1f353..b2132c59cde 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_rotate.c +++ b/source/blender/nodes/shader/nodes/node_shader_vector_rotate.c @@ -53,9 +53,8 @@ static int gpu_shader_vector_rotate(GPUMaterial *mat, float invert = (node->custom2) ? -1.0 : 1.0; return GPU_stack_link(mat, node, names[node->custom1], in, out, GPU_constant(&invert)); } - else { - return 0; - } + + return 0; } static void node_shader_update_vector_rotate(bNodeTree *UNUSED(ntree), bNode *node) diff --git a/source/blender/nodes/shader/nodes/node_shader_wireframe.c b/source/blender/nodes/shader/nodes/node_shader_wireframe.c index e1da1cd34e4..37e60ddb205 100644 --- a/source/blender/nodes/shader/nodes/node_shader_wireframe.c +++ b/source/blender/nodes/shader/nodes/node_shader_wireframe.c @@ -36,20 +36,20 @@ static int node_shader_gpu_wireframe(GPUMaterial *mat, GPUNodeStack *in, GPUNodeStack *out) { + GPU_material_flag_set(mat, GPU_MATFLAG_BARYCENTRIC); /* node->custom1 is use_pixel_size */ if (node->custom1) { return GPU_stack_link( mat, node, "node_wireframe_screenspace", in, out, GPU_builtin(GPU_BARYCENTRIC_TEXCO)); } - else { - return GPU_stack_link(mat, - node, - "node_wireframe", - in, - out, - GPU_builtin(GPU_BARYCENTRIC_TEXCO), - GPU_builtin(GPU_BARYCENTRIC_DIST)); - } + + return GPU_stack_link(mat, + node, + "node_wireframe", + in, + out, + GPU_builtin(GPU_BARYCENTRIC_TEXCO), + GPU_builtin(GPU_BARYCENTRIC_DIST)); } /* node type definition */ |