After Effects:如何根据颜色或像素改变对象的属性?



在Adobe After Effects中,如何根据(另一个对象)特定位置的像素颜色更改对象的属性(例如不透明度)

应用程序是,如果另一层中的特定像素变成特定颜色,我想覆盖/揭开一个部分(通过改变图层的不透明度)。

您可以使用sampleImage()函数来获取特定的像素颜色。

这个表达式相当慢,所以要知道它会影响渲染时间。这个链接很有用:https://www.motionscript.com/design-guide/sample-image.html

例如,这里有一个表达式,它将根据屏幕中间像素的亮度值改变不透明度:

var target = thisComp.layer("video");
// sampleImage() returns an array with R,G,B,Alpha values
var color = target.sampleImage(transform.position, [width, height]/2, true, time)
// get the luma by averaging the 3 channel values (there are more scientific ways to do this, but this is quick and simple)
var luma = (color[0] + color[1] + color[2]) / 3
// divide the luma by 255 if you work in 8bits project
var luma_value = luma / 255;
// use the 0-1 value as an opacity percentage.
luma_value * 100;

最新更新