Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Problem with fromCompToSurface() on shape layer

  • Problem with fromCompToSurface() on shape layer

    Posted by Ian Pinder on September 20, 2017 at 7:00 am

    Hi, I have an issue with something that I can solve when using a 3D solid, whose layer space makes sense to me, but when using shape layers in 3D, something gets lost. This is probably hidden somewhere in sourceRectAtTime() or similar, but I can’t quite get there at the moment.

    I am trying to sample the alpha of one 3D shape layer, at the intersection with the 3D point of another (non-shape) layer, as seen in comp space.

    I know this is a bit abstract when written down, but I have added the code that works when the shape layer is replaced with a 3D solid in the comp.

    Any help would be greatly appreciated, and save me from going mad 😉

    sam = effect("Sample Source")("Layer"); // layer whose alpha will be sampled
    pos = effect("Position Source")("Layer"); // layer whose position will be used for sample

    // rect = sam.sourceRectAtTime(time,true); // left this in from testing ideas on shape layer space
    // rect2 = [rect.left,rect.top]; // left this in from testing ideas on shape layer space

    thisCompPos = pos.toComp(pos.anchorPoint); // get comp position of non shape layer
    thisCompPos = [thisCompPos[0],thisCompPos[1]]; // I was just removing the [2] part of the array to clarify to myself
    shapePos = sam.fromCompToSurface(thisCompPos); // this is the part that works on a solid layer
    a = sam.sampleImage(shapePos,[0.5,0.5],true,time)[3]; // sample alpha at projected point on layer
    if (a > 0) 100 else 0; // return value based on result

    Ian Pinder replied 8 years, 11 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

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