Fix #103903: Bump Node performance regression
Avoid computing the non-derivative height twice. The height is now computed as part of the main function, while the height at x and y offsets are still computed on a separate function. The differentials are now computed directly at node_bump. Co-authored-by: Miguel Pozo <pragma37@gmail.com> Pull Request #104595
This commit is contained in:
@@ -263,9 +263,7 @@ vec3 dF_impl(vec3 v)
|
||||
g_derivative_flag = -1; \
|
||||
result.y = (fn); \
|
||||
g_derivative_flag = 0; \
|
||||
result -= vec2((fn)); \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* TODO(fclem): Remove. */
|
||||
|
||||
@@ -12,8 +12,13 @@ void differentiate_texco(vec4 v, out vec3 df)
|
||||
df = v.xyz + dF_impl(v.xyz);
|
||||
}
|
||||
|
||||
void node_bump(
|
||||
float strength, float dist, float height, vec3 N, vec2 dHd, float invert, out vec3 result)
|
||||
void node_bump(float strength,
|
||||
float dist,
|
||||
float height,
|
||||
vec3 N,
|
||||
vec2 height_xy,
|
||||
float invert,
|
||||
out vec3 result)
|
||||
{
|
||||
N = normalize(N);
|
||||
dist *= FrontFacing ? invert : -invert;
|
||||
@@ -29,6 +34,7 @@ void node_bump(
|
||||
/* Compute surface gradient and determinant. */
|
||||
float det = dot(dPdx, Rx);
|
||||
|
||||
vec2 dHd = height_xy - vec2(height);
|
||||
vec3 surfgrad = dHd.x * Rx + dHd.y * Ry;
|
||||
|
||||
strength = max(strength, 0.0);
|
||||
|
||||
Reference in New Issue
Block a user