Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Ebb <matt@mke3.net>2010-08-25 11:43:38 +0400
committerMatt Ebb <matt@mke3.net>2010-08-25 11:43:38 +0400
commit75c176f56eff800797011c3c805d5669eb758f2b (patch)
tree884283ba16141e44003c62ed37c6d04227776fd1 /source/blender/nodes/intern/CMP_nodes
parent5bd7f0112c8999eb0e076de9f9862e2136d242e4 (diff)
Allow per-pixel inputs into displace node x and y scale
(previously only used constant values)
Diffstat (limited to 'source/blender/nodes/intern/CMP_nodes')
-rw-r--r--source/blender/nodes/intern/CMP_nodes/CMP_displace.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_displace.c b/source/blender/nodes/intern/CMP_nodes/CMP_displace.c
index 6fe6dcd8440..7d64d4e719c 100644
--- a/source/blender/nodes/intern/CMP_nodes/CMP_displace.c
+++ b/source/blender/nodes/intern/CMP_nodes/CMP_displace.c
@@ -48,7 +48,7 @@ static bNodeSocketType cmp_node_displace_out[]= {
* in order to take effect */
#define DISPLACE_EPSILON 0.01
-static void do_displace(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *vecbuf, float *veccol, float *xscale, float *yscale)
+static void do_displace(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *vecbuf, float *veccol, CompBuf *xbuf, CompBuf *ybuf, float *xscale, float *yscale)
{
ImBuf *ibuf;
int x, y;
@@ -56,6 +56,7 @@ static void do_displace(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *vecbuf, float
float d_dx, d_dy;
float dxt, dyt;
float u, v;
+ float xs, ys;
float vec[3], vecdx[3], vecdy[3];
float col[3];
@@ -66,8 +67,20 @@ static void do_displace(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *vecbuf, float
for(x=0; x < stackbuf->x; x++) {
/* calc pixel coordinates */
qd_getPixel(vecbuf, x-vecbuf->xof, y-vecbuf->yof, vec);
- p_dx = vec[0] * xscale[0];
- p_dy = vec[1] * yscale[0];
+
+ if (xbuf)
+ qd_getPixel(xbuf, x-xbuf->xof, y-xbuf->yof, &xs);
+ else
+ xs = xscale[0];
+
+ if (ybuf)
+ qd_getPixel(ybuf, x-ybuf->xof, y-ybuf->yof, &ys);
+ else
+ ys = yscale[0];
+
+
+ p_dx = vec[0] * xs;
+ p_dy = vec[1] * ys;
/* if no displacement, then just copy this pixel */
if (p_dx < DISPLACE_EPSILON && p_dy < DISPLACE_EPSILON) {
@@ -84,8 +97,8 @@ static void do_displace(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *vecbuf, float
/* calc derivatives */
qd_getPixel(vecbuf, x-vecbuf->xof+1, y-vecbuf->yof, vecdx);
qd_getPixel(vecbuf, x-vecbuf->xof, y-vecbuf->yof+1, vecdy);
- d_dx = vecdx[0] * xscale[0];
- d_dy = vecdy[0] * yscale[0];
+ d_dx = vecdx[0] * xs;
+ d_dy = vecdy[0] * ys;
/* clamp derivatives to minimum displacement distance in UV space */
dxt = MAX2(p_dx - d_dx, DISPLACE_EPSILON)/(float)stackbuf->x;
@@ -132,13 +145,18 @@ static void node_composit_exec_displace(void *data, bNode *node, bNodeStack **in
if(in[0]->data && in[1]->data) {
CompBuf *cbuf= in[0]->data;
CompBuf *vecbuf= in[1]->data;
+ CompBuf *xbuf= in[2]->data;
+ CompBuf *ybuf= in[3]->data;
CompBuf *stackbuf;
cbuf= typecheck_compbuf(cbuf, CB_RGBA);
vecbuf= typecheck_compbuf(vecbuf, CB_VEC3);
+ xbuf= typecheck_compbuf(xbuf, CB_VAL);
+ ybuf= typecheck_compbuf(ybuf, CB_VAL);
+
stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* allocs */
- do_displace(stackbuf, cbuf, vecbuf, in[1]->vec, in[2]->vec, in[3]->vec);
+ do_displace(stackbuf, cbuf, vecbuf, in[1]->vec, xbuf, ybuf, in[2]->vec, in[3]->vec);
out[0]->data= stackbuf;