[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31571] trunk/blender/source/blender/nodes /intern/CMP_nodes/CMP_displace.c: Allow per-pixel inputs into displace node x and y scale
Matt Ebb
matt at mke3.net
Wed Aug 25 09:43:38 CEST 2010
Revision: 31571
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31571
Author: broken
Date: 2010-08-25 09:43:38 +0200 (Wed, 25 Aug 2010)
Log Message:
-----------
Allow per-pixel inputs into displace node x and y scale
(previously only used constant values)
Modified Paths:
--------------
trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_displace.c
Modified: trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_displace.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_displace.c 2010-08-25 07:03:35 UTC (rev 31570)
+++ trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_displace.c 2010-08-25 07:43:38 UTC (rev 31571)
@@ -48,7 +48,7 @@
* 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 @@
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,9 +67,21 @@
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) {
qd_getPixel(cbuf, x-cbuf->xof, y-cbuf->yof, col);
@@ -84,8 +97,8 @@
/* 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 @@
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;
More information about the Bf-blender-cvs
mailing list