ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

reference whatever layer is at a certain position?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Rebecca Shumway
reference whatever layer is at a certain position?
on Jun 12, 2019 at 9:50:49 pm

is there a way to reference an effect on whichever layer is at a certain point?

i have a stack of tiles that are semi-transparent and behind them a glow. the tiles are parented to a null that scrolls them. the glow changes color based on which tile is centered on the screen. i have it animated by hand, but am trying to script it, so that when i change the scrolling speed i don't need to then reanimate the glow each time. my thinking is that i could put a Color Control on each tile with the color that the glow should be and then reference that for whichever tile is centered. the tiles never overlap, so there is only ever one over the center point at a time. there is also a small gap in between each tile, so the glow color should stay whatever color it last was when there is no tile over the center point. to get really fancy, it would be ideal if the glow color could start changing into the next color when it gets within 25 pixels of the edge of one tile and land at the next color when it is 25 pixels into the next tile. the tiles could potentially scroll in each y-axis direction, but only ever vertically.

i know there's a lot here, but my main question is just whether there's a way to tell the glow which layer is currently over the center point of the comp.


Return to posts index

Kalleheikki Kannisto
Re: reference whatever layer is at a certain position?
on Jun 13, 2019 at 6:47:05 am

I would expect that sampleimage() would work to get the color value of the center point, if you precomped the layers and the null and sampled the precomp. You can make the sampling area 25 pixels wide to get an average of those pixels.

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

Rebecca Shumway
Re: reference whatever layer is at a certain position?
on Jun 13, 2019 at 3:27:21 pm

thanks for responding, Kalleheikki. unfortunately, sampleImage() won’t work in this case because the color i need the glow to be is not the color of the tile. the tiles are multicolored and also semi-opaque. i should have explained that better. that’s why i’d like to use a Color Control to assign the color for each tile and then have the glow reference that effect from whichever tile is front and center. i think i’ve got most of it figured out, but i need to be able to tell the glow which layer is in the middle.

thanks!


Return to posts index


Kalleheikki Kannisto
Re: reference whatever layer is at a certain position?
on Jun 13, 2019 at 6:07:23 pm

I'm sure there's a way to calculate that as well, however, it is too complex an issue for me to tackle here.

I would suggest making a precomp where you have the colors that you want to use in the same shape as the tiles and use that both to pick the color with sampleimage as well as to overlay on the tiles for color (in color mode, for instance).

It's a bit more complex to figure out where in the precomp the point in the middle is (not much, likely you're moving a point up and down negative the same amount as you're moving the layer in the main comp), certainly nowhere near as complex as calculating the bounds of each layer and figuring out which ones to blend by how much.

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

Rebecca Shumway
Re: reference whatever layer is at a certain position?
on Jun 13, 2019 at 11:00:06 pm

what i ended up doing is coding the color to change based on the position of the null layer that is controlling the scrolling of the tiles. it took a series of if/else statements to dictate that the glow color would be certain values between certain positions of the null, and change from color to color in between. not nearly as neat as if the glow layer could sample from the Color Control of whatever layer is centered, but still works and allows me to change the speed of the scrolling at will without needing to keyframe the glow color again and again.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]