ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Problem with fromCompToSurface() on shape layer

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Ian Pinder
Problem with fromCompToSurface() on shape layer
on Sep 20, 2017 at 7:00:18 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,]; // 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

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved