Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions AE Z-depth math

  • Posted by Gabriel Valkama on May 7, 2010 at 7:17 am

    Heya!

    I had an idea for a “fake” black & white z-depth creator for after effects. It already works for planes facing the camera, but of course a floor plane creates trouble, as it can’t have one single color. I was thinking I could use a simple radial ‘Ramp’ effect on the floor plane if only I could do this math:

    Imagine a scene with a camera and a floor plane that can have any position and orientation.

    1) Find out the _shortest_ distance between the camera and the floor plane
    2) Find out the xyz-coordinates for the intersection point of this distance vector and the floor plane
    3) Turn this xyz-coordinate information into the plane’s local xy-coordinates. This is for controlling the ‘Ramp’ effects start point.

    I have a hunch that this is no easy task. Any help is deeply appreciated and of course I will publish the final code here.

    – Teemu

    Josh Johnson replied 14 years, 12 months ago 4 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    May 8, 2010 at 7:08 pm

    Try this:

    C = thisComp.activeCamera;
    p1 = C.toWorld([0,0,0]);
    v1 = p1 – toWorld(anchorPoint);
    v2 = toWorldVec([0,0,1]);
    p2 = p1 – v2*dot(v1,v2);
    fromWorld(p2)

    Dan

  • Ben Rollason

    May 10, 2010 at 8:25 pm

    I’d suggest you also need to add….

    tV = anchorPoint + (normalize(p3 – anchorPoint) * length(anchorPoint, [0,0]));

    This effectively clamps the near point to a circle that passes through all four corners…although this assumes that the anchor point is in the middle of each layer. If it isn’t you’ll need some extra code to work out the geometric centre of the layer and use that instead of the anchor point.

    The other part of the job is a nice recursive function that duplicates the comp and links all of the properties up via expressions.

    I’m working on a script to do exactly this at the moment. If you hit a brick wall with the math, drop me a line and I’ll send you a copy when it’s done if you like.

    -Ben.

    vfx.benrollason.com

  • Josh Johnson

    May 20, 2011 at 7:32 pm

    *sob* I really need this black and white fake z-depth maker thing. Real bad!

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