Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions 3d objects undulating as if floating in the ocean

  • Robert Paynter

    May 6, 2010 at 8:59 pm

    ok I think I got it. so I changed the position expression to move on the z and hooked up the values to sliders. I then used the roatation expression and hooked them up to the same sliders and added a damping slider.. it’s looking pretty good

    position:
    xAmp = thisComp.layer(“Null 10”).effect(“Amp”)(“Slider”); //height of undulations (pixels)
    xFreq = thisComp.layer(“Null 10”).effect(“Freq”)(“Slider”); //undulations per second
    xSpeed = thisComp.layer(“Null 10”).effect(“Speed”)(“Slider”); //speed of wave (pixels per second)

    wl = xSpeed/xFreq; //wavelength (pixels)
    phaseOffset = ((position[0]%wl)/wl)*2*Math.PI;
    z = xAmp*Math.sin(2*Math.PI*xFreq*time + phaseOffset);
    value + [0,1,z]

    rotation:
    xFreq = thisComp.layer(“Null 10”).effect(“Freq”)(“Slider”); //undulations per second
    xSpeed = thisComp.layer(“Null 10”).effect(“Speed”)(“Slider”); //speed of wave (pixels per second)
    damping = thisComp.layer(“Null 10”).effect(“Damp”)(“Slider”); //undulation damping factor

    wl = xSpeed/xFreq; //wavelength (pixels)
    phaseOffset = ((position[0]%wl)/wl)*2*Math.PI;
    theta = Math.atan(Math.cos(2*Math.PI*xFreq*time + phaseOffset));
    radiansToDegrees(theta)/damping;

  • Dan Ebberts

    May 6, 2010 at 10:23 pm

    I think I’d try the noise() function for this. If you have your layers laid out in x and y, this should give you the undulation in z and otation in x and y:

    // position

    xyCompress = 500;
    speedCompress = 1;
    amplitude = 50;
    x = value[0];
    y = value[1];
    z = amplitude*noise([x/xyCompress,y/xyCompress,time/speedCompress]);
    [x,y,z]

    // x rotation

    xyCompress = 500;
    speedCompress = 1;
    amplitude = 50;
    x = transform.position[0];
    y = transform.position[0];
    z0 = amplitude*noise([x/xyCompress,(y-.1)/xyCompress,time/speedCompress]);
    z1 = amplitude*noise([x/xyCompress,(y+.1)/xyCompress,time/speedCompress]);
    radiansToDegrees(Math.atan2(z0-z1,.2))

    // y rotation

    xyCompress = 500;
    speedCompress = 1;
    amplitude = 50;
    x = transform.position[0];
    y = transform.position[0];
    z0 = amplitude*noise([(x-.1)/xyCompress,y/xyCompress,time/speedCompress]);
    z1 = amplitude*noise([(x+.1)/xyCompress,y/xyCompress,time/speedCompress]);
    radiansToDegrees(Math.atan2(z1-z0,.2))

    You’ll want to adjust the first three parameters to suit your needs (actually you should probably tie them to controls).

    Dan

  • Robert Paynter

    May 12, 2010 at 7:58 pm

    I’ll give it a try
    Thanks Dan.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy