From 1f12244f73395cf1d5f48756304f98e19b87f83f Mon Sep 17 00:00:00 2001 From: Weizhen Huang Date: Wed, 26 Mar 2025 14:36:24 +0100 Subject: [PATCH] Fix: EEVEE bump height connecting to the wrong link after recent change Pull Request: https://projects.blender.org/blender/blender/pulls/136546 --- .../nodes/shader/nodes/node_shader_bump.cc | 20 ++++++++++++------- tests/data | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/source/blender/nodes/shader/nodes/node_shader_bump.cc b/source/blender/nodes/shader/nodes/node_shader_bump.cc index 126be2b80dd..3b37497c426 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bump.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bump.cc @@ -17,6 +17,7 @@ namespace blender::nodes::node_shader_bump_cc { static void node_declare(NodeDeclarationBuilder &b) { +#define SOCK_STRENGTH_ID 0 b.add_input("Strength") .default_value(1.0f) .min(0.0f) @@ -26,12 +27,14 @@ static void node_declare(NodeDeclarationBuilder &b) "Strength of the bump mapping effect, interpolating between " "no bump mapping and full bump mapping") .translation_context(BLT_I18NCONTEXT_AMOUNT); +#define SOCK_DISTANCE_ID 1 b.add_input("Distance") .default_value(1.0f) .min(0.0f) .max(1000.0f) .description( "Multiplier for the height value to control the overall distance for bump mapping"); +#define SOCK_FILTER_WIDTH_ID 2 b.add_input("Filter Width") .default_value(0.1f) .min(0.001) @@ -41,12 +44,14 @@ static void node_declare(NodeDeclarationBuilder &b) "Filter width in pixels, used to compute the bump mapping direction. For most textures " "the default value of 0.1 enables subpixel filtering for stable results. For stepwise " "textures a larger filter width can be used to get a bevel like effect on the edges"); +#define SOCK_HEIGHT_ID 3 b.add_input("Height") .default_value(1.0f) .min(-1000.0f) .max(1000.0f) .hide_value() .description("Height above surface. Connect the height map texture to this input"); +#define SOCK_NORMAL_ID 4 b.add_input("Normal").min(-1.0f).max(1.0f).hide_value(); b.add_output("Normal"); } @@ -63,20 +68,21 @@ static int gpu_shader_bump(GPUMaterial *mat, GPUNodeStack *out) { /* If there is no Height input, the node becomes a no-op. */ - if (!in[2].link) { - if (!in[4].link) { + if (!in[SOCK_HEIGHT_ID].link) { + if (!in[SOCK_NORMAL_ID].link) { return GPU_link(mat, "world_normals_get", &out[0].link); } /* Actually running the bump code would normalize, but Cycles handles it as total no-op. */ - return GPU_link(mat, "vector_copy", in[4].link, &out[0].link); + return GPU_link(mat, "vector_copy", in[SOCK_NORMAL_ID].link, &out[0].link); } - if (!in[4].link) { - GPU_link(mat, "world_normals_get", &in[4].link); + if (!in[SOCK_NORMAL_ID].link) { + GPU_link(mat, "world_normals_get", &in[SOCK_NORMAL_ID].link); } - const float filter_width = in[2].vec[0]; - const char *height_function = GPU_material_split_sub_function(mat, GPU_FLOAT, &in[3].link); + const float filter_width = in[SOCK_FILTER_WIDTH_ID].vec[0]; + const char *height_function = GPU_material_split_sub_function( + mat, GPU_FLOAT, &in[SOCK_HEIGHT_ID].link); /* TODO (Miguel Pozo): * Currently, this doesn't compute the actual differentials, just the height at dX and dY diff --git a/tests/data b/tests/data index eb6e001a38c..6154b71ce0b 160000 --- a/tests/data +++ b/tests/data @@ -1 +1 @@ -Subproject commit eb6e001a38c14da6db784620b87043916c6f5059 +Subproject commit 6154b71ce0b949ef1d5e5f6c7e6c37f4400c6b92