ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Opacity based on RGBA from sampleImage

COW Forums : Adobe After Effects Expressions

FAQ   •   VIEW ALL   •   ADD A NEW POST   •   PRINT
Respond to this post   •   Return to posts index   •   Read entire thread


Royce Jennings
Opacity based on RGBA from sampleImage
on Feb 11, 2019 at 2:27:35 am

So I have a video layer with only 2 rgba states, back and forth at various times.. and I want to use the rgba change to trigger the opacity on and off for another layer. As a test, I made a text layer and put the following on the source text:

videoLayer = thisComp.layer("Video-01");//Layer to read rgba values from.
videoDetect = videoLayer.sampleImage(transform.position, [width, height]/2, true, time);//Reading rgba values.
if(parseInt(videoDetect*100) > 77){100 + "\r" + parseInt(videoDetect*100)}else{0 + "\r" + parseInt(videoDetect*100)}


On the one video layer state I get:
0
74

On the other I get:
100
79

Seems good so far.. I originally was using Math.floor(videoDetect) but it returned as NaN, so I used parseInt() to convert it. I think that's right.... right?
So now on the layer to trigger turning off, I have the following on the Opacity parameter; same as above, but with simply the opacity values for the "if" results:

videoLayer = thisComp.layer("Video-01");//Layer to read rgba values from.
videoDetect = videoLayer.sampleImage(transform.position, [width, height]/2, true, time);//Reading rgba values.
if(parseInt(videoDetect*100) > 77){100}else{0}


But the opacity stays at 0 regardless of the video changing. Why isn't my true state checking out, even though it seems to do so on the text layer? I very much appreciate any input!

- Royce

videoLayer = thisComp.layer("Video-01");//Layer to read rgba values from.
videoDetect = videoLayer.sampleImage(transform.position, [width, height]/2, true, time);//Reading rgba values.
if(parseInt(videoDetect*100) > 77){100}else{0}


Posts IndexRead Thread 


Current Message Thread:





© 2019 CreativeCOW.net All Rights Reserved
[TOP]