Fix: EEVEE bump height connecting to the wrong link after recent change

Pull Request: https://projects.blender.org/blender/blender/pulls/136546
This commit is contained in:
Weizhen Huang
2025-03-26 14:36:24 +01:00
committed by Weizhen Huang
parent eaee5fc658
commit 1f12244f73
2 changed files with 14 additions and 8 deletions

View File

@@ -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<decl::Float>("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<decl::Float>("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<decl::Float>("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<decl::Float>("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<decl::Vector>("Normal").min(-1.0f).max(1.0f).hide_value();
b.add_output<decl::Vector>("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