Files
test/intern/cycles/kernel/osl/shaders/node_attribute.osl
Brecht Van Lommel f987ef7b6e Shaders: Add Filter Width input to Bump node
This makes it possible to restore previous Blender 4.3 behavior of bump
mapping, where the large filter width was sometimes (ab)used to get a bevel
like effect on stepwise textures.

For bump from the displacement socket, filter width remains fixed at 0.1.

Ref #133991, #135841

Pull Request: https://projects.blender.org/blender/blender/pulls/136465
2025-03-25 16:29:13 +01:00

35 lines
1.1 KiB
Plaintext

/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
*
* SPDX-License-Identifier: Apache-2.0 */
#include "stdcycles.h"
shader node_attribute(string bump_offset = "center",
float bump_filter_width = BUMP_FILTER_WIDTH,
string name = "",
output point Vector = point(0.0, 0.0, 0.0),
output color Color = 0.0,
output float Fac = 0.0,
output float Alpha = 0.0)
{
float data[4] = {0.0, 0.0, 0.0, 0.0};
getattribute(name, data);
Color = color(data[0], data[1], data[2]);
Vector = point(Color);
getattribute(name, Fac);
Alpha = data[3];
if (bump_offset == "dx") {
Color += Dx(Color) * bump_filter_width;
Vector += Dx(Vector) * bump_filter_width;
Fac += Dx(Fac) * bump_filter_width;
Alpha += Dx(Alpha) * bump_filter_width;
}
else if (bump_offset == "dy") {
Color += Dy(Color) * bump_filter_width;
Vector += Dy(Vector) * bump_filter_width;
Fac += Dy(Fac) * bump_filter_width;
Alpha += Dy(Alpha) * bump_filter_width;
}
}