一键RGB分离

效果展示

一键RGB分离

功能

选择一个图层,使用脚本。会基于当前图层,分离RGB,变成3个图层

知识点

  • 撤销组
  • 图层选择
  • 图层复制
  • 图层重命名
  • 混合模式
  • 图层添加属性
  • 更改属性

源代码

/*
AR_AddChromaticAberration
Author: Arttu Rautio (aturtur)
Website: http://aturtur.com/
Name-US: AR_AddChromaticAberration
Description-US: Creates Chromatic aberration setup from selected comp item. Selected item should be a pre-comp or a layer that does not have any effects.
github: https://github.com/aturtur/after-effects-scripts/blob/master/
Written for Adobe After Effects CC 2019 (Version 16.0.1 Build 48)
*/
//@target aftereffects

// 这个函数没用到 不知道干嘛的
function rangeMap(value, minInput, maxInput, minOutput, maxOutput) {
    var remapped = (value - minInput) * (maxOutput - minOutput) / (maxInput - minInput) + minOutput
    return remapped
}

function ChromaticAberration() {
    // 创建撤销组
    app.beginUndoGroup("AR_AddChromaticAberration"); 
    // 选择一个图层
    var comp = app.project.activeItem;
    var selectedLayer = comp.selectedLayers[0];
    // 复制2个图层
    var red = selectedLayer;
    var blue = selectedLayer.duplicate();
    var green = selectedLayer.duplicate();
    // 重命名为红绿蓝
    red.name = "Red";
    green.name = "Green";
    blue.name = "Blue";
    // 设置后2层的混合模式
    green.blendingMode = BlendingMode.ADD;
    blue.blendingMode = BlendingMode.ADD;
    // 分别为R/G/B图层添加属性 
    var rchan = red.Effects.addProperty("Set Channels"); 
    rchan.property("Set Red To Source 1’s").setValue(1); // 设置 red channel 为'Red'
    rchan.property("Set Green To Source 2’s").setValue(10); // 设置 green channel 为 'Off'
    rchan.property("Set Blue To Source 3’s").setValue(10); // 设置 blue channel 为 'Off'
    var gchan = green.Effects.addProperty("Set Channels");
    gchan.property("Set Red To Source 1’s").setValue(10); // 设置 red channel 为 'Off'
    gchan.property("Set Green To Source 2’s").setValue(2); // 设置 green channel 为 'Green'
    gchan.property("Set Blue To Source 3’s").setValue(10); // 设置 blue channel 为 'Off'
    var bchan = blue.Effects.addProperty("Set Channels");
    bchan.property("Set Red To Source 1’s").setValue(10); // 设置 red channel 为 'Off'
    bchan.property("Set Green To Source 2’s").setValue(10); // 设置 green channel 为 'Off'
    bchan.property("Set Blue To Source 3’s").setValue(3); // 设置 blue channel 为 'Blue'
    // 获取图层原始缩放
    var baseScale = selectedLayer.property("Transform").property("Scale").value;
    blue.property("Transform").property("Scale").setValue([baseScale[0]*0.997,baseScale[1]*0.997]); // 降低蓝色图层缩放
    red.property("Transform").property("Scale").setValue([baseScale[0]*1.002,baseScale[1]*1.002]); // 提高红色色图层缩放
    app.endUndoGroup(); // End undo group
}
ChromaticAberration(); // Run the function

 

给TA充电
共{{data.count}}人
人已充电
AE开发脚本开发

“向下”复制图层

2021-9-10 14:07:51

AE开发扩展 CEP

Adobe CEP 扩展开发教程 「 0 」

2021-9-13 4:45:01

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
今日签到
搜索