## Moving displacement during cameramove "IDgloop"

### Moving displacement during cameramove "IDgloop"

beginners question!

I trying out Ivan DeWolf wonderful IDgloop shader from renderman.org

I have a moving camera and the displacment change heavily from frame
to frame.
I do not animate parameters. trying to learn shader writing and would
like to have some help where i can change in the code so it will not
animate.

probably something how it handles shaderspace?

Cheers

-Dale

/*  IDGloop.sl written 8/99 by Ivan DeWolf
*  courtesy of Rhythm & Hues  (thanks!)

*
* an example of nonlinear displacements
* generated from the gradient of a noise function.
* Written as an explanation to the talk I gave at
* the "stupid renderman tricks" section of the 1998
* Renderman Users Group meeting at siggraph.
*
* freq - the frequency of the noise. Lower values
*        will cause a larger displacement so you will
*        have to change your displacement bounds to fit
*        rhymes with freak.
*
* magnitude - how far to displace. probably fine set where it is.
*
* displacement bounds can be computed with the following
* wildly complex formula:
*
* 10*magnitude/freq
*
*/

displacement
IDgloop(float freq = 5, magnitude = .2){

vector overdist = .1;
vector stepsize = magnitude/freq;
float numsteps = 20;
point  Psh = transform("object",P)*freq;
float  i;

vector dPduN = normalize(vtransform("object",dPdu));
vector dPdvN = normalize(vtransform("object",dPdv));

point  Pou = Psh + (dPduN*overdist);/*P Over a distance in U*/
point  Pov = Psh + (dPdvN*overdist);

/*noise function at the point, over in u, and over in v*/
float  nz = noise(Psh)-.5;
float  nzou = noise(Pou)-.5;
float  nzov = noise(Pov)-.5;

float  chu = (nz - nzou);/*change in noise value in u*/
float  chv = (nz - nzov);

/*init deflected derivatives*/
vector DdPdu = dPduN;
vector DdPdv = dPdvN;

vector step = DdPdu^DdPdv;

/*where it all happens*/
for(i=1;i<numsteps;i=i+1){
P -= vtransform("object","current",step)*nz*stepsize;
DdPdu = normalize(DdPdu+(step*chu));
DdPdv = normalize(DdPdv+(step*chv));
step = DdPdu^DdPdv;
}

/* wash your hands after displacing P*/
N = normalize(calculatenormal(P));

Quote:}

### Moving displacement during cameramove "IDgloop"

Quote:> I have a moving camera and the displacment change heavily from frame
> to frame.
> I do not animate parameters. trying to learn shader writing and would
> like to have some help where i can change in the code so it will not
> animate.

> probably something how it handles shaderspace?

Didnt you moved the object ?
Or maybe you passed the camera-space coordinates to the shader.
try fixing it with World-Coordinates.

### Moving displacement during cameramove "IDgloop"

Quote:> Didnt you moved the object ?
> Or maybe you passed the camera-space coordinates to the shader.
> try fixing it with World-Coordinates.

I move the object and camera but not animating shader

### Moving displacement during cameramove "IDgloop"

Quote:> I move the object and camera but not animating shader

So you hooked the shader-space to the world-space.
And what you should do is hook the shader-space to the object-space.

Sorry for my missunderstanding last time...

### Moving displacement during cameramove "IDgloop"

Quote:> beginners question!

> I trying out Ivan DeWolf wonderful IDgloop shader from renderman.org

> I have a moving camera and the displacment change heavily from frame
> to frame.
> I do not animate parameters. trying to learn shader writing and would
> like to have some help where i can change in the code so it will not
> animate.

> probably something how it handles shaderspace?

> Cheers

>   /*where it all happens*/
>   for(i=1;i<numsteps;i=i+1){
>     P -= vtransform("object","current",step)*nz*stepsize;

What renderer are you using? This change to "current" space varies for each
renderer - for PRman it is "camera" space and for BMRT it is "world" space.
I am assuming this bit is the bit that is causing trouble - however if you
are moving the camera and the object it won't matter as the point will be
moving in either world or camera space ;o) Maybe changing getting rid of the
transform to current space would do it? Or perhaps changing it to "shader"
space?

Simon

--
http://www.rendermania.com/
UIN 11123737

Does anyone have a problem using PhotoShop 3.  I have alien skin filters
and Kai's Power Tools and yet if I use the spheroid designer in Kai's Power
Tools and then try to add a drop shadow to it using alien skin, PhotoShop
crashes.  Has anyone got a solution to this problem.  It's really bugging
me (pun not intentional).

Yours Pete