driving opacity based on another layer's pixel value?
by Shirak Agresta (shirak23)
on
Oct 4, 2008 at 5:07:18 am
I was wondering if there was a way to drive the opacity of one layer by a/the value of a pixel or a group of pixels on another layer.
Basically, I've got a grayscale image of a light(really just the color white in the center of, but not taking up, the frame) on "layer 1" flashing on and off. I want the intensity value of one of that image's pixels (or, say, an average of a group of the pixels that make up this flashing "light") to drive the opacity of another layer ("layer 2").
Does this make sense? Is it possible?
Thanks!
Julius Caesar and the Roman Empire couldn't conquer the blue sky.
Re: driving opacity based on another layer's pixel value? by Shirak Agresta on Oct 4, 2008 at 8:42:14 am
Thanks so much! One again, sir, you prove to be an invaluable resource.
Now, just to make sure I understand this:
1) the sample size (in your example 10 by 10) is just that; a sample size of 10 pixels by 10 pixels.
2) the sample position is half the size of the size of the target layer, correct? Would this mean that the image I am referencing for this needs to be in the center of the comp?
3)[Dan Ebberts]"hsl = rgbToHsl(rgb)" :<-- This line means that "hsl" (hue/saturation/levels) represents a conversion from rgb to hsl color space ("rgb" equaling whatever is being sampled)?
4)That some value of "hsl" is being multiplied by 100? What does the "[2]" represent?
5)That this whole shebang is the expression for the opacity of "layer 2" or whichever layer I want the effect to take place on, right (I know, seems obvious, but I want to be sure I get this).
Again, thanks so much for your quick reply, you've helped me out a number of times before and I appreciate it.
Julius Caesar and the Roman Empire couldn't conquer the blue sky.
Re: driving opacity based on another layer's pixel value? by Dan Ebberts on Oct 4, 2008 at 3:37:26 pm
1. Yes
2. The sample position is relative to the target layer. I set it up to be the center of the layer. The target layer can be anywhere in the comp.
3. Yes, sampleImage() retrieves an rgba sample. I converted it to hsla because it sounded like you wanted the overall lightness value.
4. hsla is an array of four values (hue, saturation, lightness, and alpha). You get at the third value using an index of [2]. The value will be in the range between 0.0 and 1.0. Multiplying by 100 gives you a range of 0 to 100 - more suitable for opacity.