Fix #23901: displace node not working with negative values.
This commit is contained in:
@@ -155,6 +155,8 @@ MINLINE float interpf(float a, float b, float t);
|
|||||||
MINLINE float minf(float a, float b);
|
MINLINE float minf(float a, float b);
|
||||||
MINLINE float maxf(float a, float b);
|
MINLINE float maxf(float a, float b);
|
||||||
|
|
||||||
|
MINLINE float signf(float f);
|
||||||
|
|
||||||
MINLINE float power_of_2(float f);
|
MINLINE float power_of_2(float f);
|
||||||
|
|
||||||
MINLINE float shell_angle_to_dist(float angle);
|
MINLINE float shell_angle_to_dist(float angle);
|
||||||
|
@@ -122,5 +122,10 @@ MINLINE float maxf(float a, float b)
|
|||||||
return (a > b)? a: b;
|
return (a > b)? a: b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MINLINE float signf(float f)
|
||||||
|
{
|
||||||
|
return (f < 0.f)? -1.f: 1.f;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* BLI_MATH_BASE_INLINE */
|
#endif /* BLI_MATH_BASE_INLINE */
|
||||||
|
|
||||||
|
@@ -83,7 +83,7 @@ static void do_displace(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *vecbuf, float
|
|||||||
p_dy = vec[1] * ys;
|
p_dy = vec[1] * ys;
|
||||||
|
|
||||||
/* if no displacement, then just copy this pixel */
|
/* if no displacement, then just copy this pixel */
|
||||||
if (p_dx < DISPLACE_EPSILON && p_dy < DISPLACE_EPSILON) {
|
if (fabsf(p_dx) < DISPLACE_EPSILON && fabsf(p_dy) < DISPLACE_EPSILON) {
|
||||||
qd_getPixel(cbuf, x-cbuf->xof, y-cbuf->yof, col);
|
qd_getPixel(cbuf, x-cbuf->xof, y-cbuf->yof, col);
|
||||||
qd_setPixel(stackbuf, x, y, col);
|
qd_setPixel(stackbuf, x, y, col);
|
||||||
continue;
|
continue;
|
||||||
@@ -101,8 +101,11 @@ static void do_displace(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *vecbuf, float
|
|||||||
d_dy = vecdy[0] * ys;
|
d_dy = vecdy[0] * ys;
|
||||||
|
|
||||||
/* clamp derivatives to minimum displacement distance in UV space */
|
/* clamp derivatives to minimum displacement distance in UV space */
|
||||||
dxt = MAX2(p_dx - d_dx, DISPLACE_EPSILON)/(float)stackbuf->x;
|
dxt = p_dx - d_dx;
|
||||||
dyt = MAX2(p_dy - d_dy, DISPLACE_EPSILON)/(float)stackbuf->y;
|
dyt = p_dy - d_dy;
|
||||||
|
|
||||||
|
dxt = signf(dxt)*maxf(fabsf(dxt), DISPLACE_EPSILON)/(float)stackbuf->x;
|
||||||
|
dyt = signf(dyt)*maxf(fabsf(dyt), DISPLACE_EPSILON)/(float)stackbuf->y;
|
||||||
|
|
||||||
ibuf_sample(ibuf, u, v, dxt, dyt, col);
|
ibuf_sample(ibuf, u, v, dxt, dyt, col);
|
||||||
qd_setPixel(stackbuf, x, y, col);
|
qd_setPixel(stackbuf, x, y, col);
|
||||||
|
Reference in New Issue
Block a user