Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
2

Trim Path & Make Layer Above Visible Only When Path is Visible

Engaged ,
Jan 21, 2024 Jan 21, 2024

So to start with, I've got this from way back when:

 

 

L = thisComp.layer("Layer 2/Mouse Cursor.ai");
p = L.transform.position;
sampleImage(p,[.5,.5],true)[3] > 0 ? 100 : 0

 

 

It's from an old project, which emulated the Windows GUI and governed the mouse-hover effects (when the mouse cursor was over something it would become visible just like in Windows).

 

I'm looking to do something similar now but I can't figure out how to do it. Basically, I've got a path that draws a line through a scene courtesy a Trim Paths property, with dots marking vertices in the path (so anytime the path turns, there's a dot to mark it). What I'm looking to do is for the dots to sample the path layer, and when the path becomes visible beneath them, for the dots themselves to become visible.

 

I know SampleImage is the key to making it work, but I can't figure out how to go about it.

 

I feel like this is close (applied to the Opacity property of one of the "dot" layers):

 

target = thisComp.layer("Shape Layer 1");
target.sampleImage([transform.xPosition,transform.yPosition], [5,5], true) > 100 ? 0 : 0

 

As best I understand it, it's telling AE to sample Shape Layer 1, and when it becomes visible at the coordinates of the dot itself, plus or minus 5 pixels, then it becomes visible...but it's not working.

Can anybody help me straighten this out?

EDIT: it's a 3D scene using the Classic 3D renderer if that makes a difference

TOPICS
Expressions , Scripting
716
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 22, 2024 Jan 22, 2024

I haven't been able to crack this. I can get a vanilla 3D setup to work with this expression:

target = thisComp.layer("Shape Layer 1");
p = toComp(anchorPoint);
target.sampleImage([p[0],p[1]], [5,5], true)[3] > 0 ? 100 : 0

But things get wonky when you introduce z separation and camera angles. I'm confident that it all makes sense if you spend the time to work it out, but I don't have a ready answer for you.

 

Translate
Community Expert ,
Jan 21, 2024 Jan 21, 2024

Try it this way. It might work, depending on how you have the anchor points set up:

target = thisComp.layer("Shape Layer 1");
target.sampleImage([transform.xPosition,transform.yPosition], [5,5], true)[3] > 0 ? 100 : 0
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 21, 2024 Jan 21, 2024

Unfortunately no luck...I'm thinking the 3D piece of this may be the reason; even though it's just the Classic 3D renderer, looks like they don't play well together. I tried giving it a third coordinate for the Z axis but it doesn't look like SampleImage will accept the third coordinate.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 21, 2024 Jan 21, 2024

Any chance you could post a trimmed-down version of the project file?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 21, 2024 Jan 21, 2024
quote

Any chance you could post a trimmed-down version of the project file?


By @Dan Ebberts

 

Here you are sir. This is just the one graphic that I'm developing, but if we can solve the problem here then I can apply it elsewhere. This version doesn't include the expression on the opacity properties, I just settled for making them visible by hand; the layers I'm trying to configure to appear automatically are the "Timeline Dot" layers.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 22, 2024 Jan 22, 2024

I haven't been able to crack this. I can get a vanilla 3D setup to work with this expression:

target = thisComp.layer("Shape Layer 1");
p = toComp(anchorPoint);
target.sampleImage([p[0],p[1]], [5,5], true)[3] > 0 ? 100 : 0

But things get wonky when you introduce z separation and camera angles. I'm confident that it all makes sense if you spend the time to work it out, but I don't have a ready answer for you.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 22, 2024 Jan 22, 2024
LATEST

No worries, we tried and that's what counts! I can live with doing it the manual way. Thanks for trying though!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines