达芬奇Fusion常用表达式与命令 Blackmagic Design Fusion

AI-摘要
Tianli GPT
AI初始化中...
介绍自己 🙈
生成本文简介 👋
推荐相关文章 📖
前往主页 🏠
前往爱发电购买
达芬奇Fusion常用表达式与命令 Blackmagic Design Fusion
Dio云玩家2025-07-24
首次更新
本篇文章记录下一些常用的达芬奇Fusion命令与表达式
本文整理了达芬奇Fusion中常用的表达式与命令,采用表格形式,便于VFX从业者、合成师及新手快速查阅和应用。涵盖动画、文本格式化、粒子系统等场景,助你高效完成特效与合成任务。持续更新。
表达式
表达式 | 描述 | 应用场景 | 参数说明 |
---|---|---|---|
Node:GetValue(“Parameter”, time - offset) | 获取指定节点参数的值,结合帧偏移实现延迟效果 | 偏移动画、参数关联 | Node: 目标节点名称(如Transform2)。Parameter: 参数名称(如”Size”)。time: 当前帧数。offset: 延迟的帧数(如30表示延迟30帧,假设30fps为1秒)。用于从指定节点获取参数值并应用时间偏移。 |
0.2126 * r + 0.7152 * g + 0.0722 * b | 计算RGB像素值的加权亮度,基于人眼对红、绿、蓝的感知权重,适用于任何支持像素操作的表达式字段 | 亮度调整、灰度转换、颜色处理 | r: 红色通道值(0到1)。g: 绿色通道值(0到1)。b: 蓝色通道值(0到1)。权重系数(0.2126, 0.7152, 0.0722)基于人眼对RGB的感知,生成亮度值。 |
clamp(value, min, max) | 限制输入值在指定最小值和最大值之间,适用于任何节点的表达式字段,防止参数超出预期范围 | 参数控制、值规范化、动画约束 | value: 要限制的输入值(如亮度、位置)。min: 最小允许值(如0.05)。max: 最大允许值(如1)。返回限制在min和max之间的值。 |
max(r1,g1,b1) | 返回RGB通道中的最大值,适用于自定义节点生成黑底图像的Alpha通道 | Alpha通道提取、遮罩生成 | r1: 红色通道值(0到1)。g1: 绿色通道值(0到1)。b1: 蓝色通道值(0到1)。在pCustom节点的Alpha表达式中输入:max(r1,g1,b1) ,提取RGB最大值作为Alpha通道,用于黑底图像的遮罩。 |
“..” | 在Lua中连接字符串或值,用于组合文本或数字输出 | 文本格式化、动态字符串生成 | ..: Lua字符串连接运算符。将两个值合并为单个字符串,例如”text”..value。用于表达式或脚本中构建动态标签或输出。 |
“$”..(string.format(‘%d’, number)):reverse():gsub(“(%d%d%d)”,”%1” .. “,”):gsub(“,(%-?)$”,”%1”):reverse()..”.” | 格式化数字,添加千位分隔符,前面加”$”,后面加”.” | 数字格式化、界面显示 | number: 输入数字,格式化为带千位分隔符的字符串,添加”$”前缀和”.”后缀。 |
string.format(“%.1f”, time/10) | 将时间值除以10后格式化为一位小数 | 显示时间计数、创建平滑的时间驱动文本 | time: 当前时间轴的帧数或时间值;**%.1f**: 格式化字符串,保留一位小数 |
px*(1-n1)+get2x(disp)*n1 | 在CustomPoly修改器中,基于插值因子n1对X坐标进行线性插值 | 多边形变形、平滑过渡 | px: 第一个输入多边形的X坐标。n1: 插值因子(0到1),控制两个多边形之间的混合比例。get2x(disp): 第二个输入多边形的X坐标。disp: 点索引,用于指定当前处理的点。 |
py*(1-n1)+get2y(disp)*n1 | 在CustomPoly修改器中,基于插值因子n1对Y坐标进行线性插值 | 多边形变形、平滑过渡 | py: 第一个输入多边形的Y坐标。n1: 插值因子(0到1),控制两个多边形之间的混合比例。get2y(disp): 第二个输入多边形的Y坐标。disp: 点索引,用于指定当前处理的点。 |
命令
在控制台页面输入使用
命令 | 描述 | 应用场景 | 参数说明 |
---|---|---|---|
fusion:SetPrefs{[“Global.FileReq.CustomDialogs”] = false} | 切换Fusion的文件选择器,决定是否使用系统原生文件管理器 | 文件导入导出、界面优化 | Global.FileReq.CustomDialogs: 布尔值,设置为false 使用系统原生文件管理器,true 使用Fusion内置文件选择器。在Fusion控制台输入以更改文件选择行为。 |
fu:ToggleUtility(‘SVGImport’) | 调用Fusion的SVG导入功能,打开SVG导入界面 | 导入矢量图形、SVG处理 | 无参数,直接在Fusion控制台输入,触发SVG导入对话框,用于导入SVG文件到合成中。 |
comp:AddTool("ToolName", -32768, -32768) | 创建指定类型的新节点 | 快速添加节点 | ToolName: 节点类型(如”Transform”)。-32768, -32768: 默认节点位置。 使用循环可批量创建节点 |
特殊节点表达式速查
Custom Tool
表达式 | Description | 中文描述 |
---|---|---|
n1..n8 | Numeric Inputs | 数值输入 |
p1x..p4x, p1y..p4y | Position Values (X-axis, Y-axis) | 位置值(X轴,Y轴) |
s1..s4 | Setup Expression Results | 设置表达式结果 |
i1..i4 | Intermediate Expression Results | 中间表达式结果 |
time | Current Frame | 当前帧数 |
x, y | Horizontal/Vertical coordinate of the current pixel, between 0.0 and 1.0 | 当前像素的水平/垂直坐标,范围0.0到1.0 |
w, h (w1..w3, h1..h3) | Width/Height of Image (for image1..image3) | 图像宽度/高度(针对image1..image3) |
ax, ay (ax1..ax3, ay1..ay3) | Image Aspect X/Y (for image1..image3) | 图像X/Y比例(针对image1..image3) |
c1..c3, r1..r3, g1..g3, b1..b3, a1..a3 | Current Channel, Red, Green, Blue, Alpha (for image1..image3) | 当前通道、红、绿、蓝、Alpha(针对image1..image3) |
z1..z3, cv1..cv3 | Z-Buffer, Z Coverage (for image1..image3) | Z缓冲、Z覆盖(针对image1..image3) |
u1..u3, v1..v3 | U/V Coordinate (for image1..image3) | U/V坐标(针对image1..image3) |
nx1..nx3, ny1..ny3, nz1..nz3 | X/Y/Z Normal (for image1..image3) | X/Y/Z法线(针对image1..image3) |
bgr1..bgr3, bgg1..bgg3, bgb1..bgb3, bga1..bga3 | Background Red, Green, Blue, Alpha (for image1..image3) | 背景红、绿、蓝、Alpha(针对image1..image3) |
vx1..vx3, vy1..vy3 | X/Y Vector (for image1..image3) | X/Y向量(针对image1..image3) |
pi | The value of pi | 圆周率π值 |
e | The value of e | 自然对数底e值 |
log(x) | The base-10 log of x | x的以10为底的对数 |
ln(x) | The natural (base-e) log of x | x的自然对数(以e为底) |
sin(x), cos(x), tan(x) | The sine, cosine, tangent of x (x is degrees) | x的正弦、余弦、正切(x为度) |
asin(x), acos(x), atan(x) | The arcsine, arccosine, arctangent of x, in degrees | x的反正弦、反余弦、反正切,以度为单位 |
atan2(x,y) | The arctangent of x,y, in degrees | x,y的反正切,以度为单位 |
abs(x) | The absolute (positive) value of x | x的绝对值(正值) |
int(x) | The integer (whole) value of x | x的整数值 |
frac(x) | The fractional value of x | x的小数值 |
sqrt(x) | The square root of x | x的平方根 |
rand(x,y) | A random value between x and y | x和y之间的随机值 |
rands(x,y,s) | A random value between x and y, based on seed s | 基于种子s的x和y之间的随机值 |
min(x,y) | The minimum (lowest) of x and y | x和y的最小值 |
max(x,y) | The maximum (highest) of x and y | x和y的最大值 |
dist(x1,y1,x2,y2) | The distance between point x1,y1 and x2,y2 | 点x1,y1和x2,y2之间的距离 |
dist3d(x1,y1,z1,x2,y2,z2) | The distance between 3D points x1,y1,z1 and x2,y2,z2 | 3D点x1,y1,z1和x2,y2,z2之间的距离 |
noise(x), noise2(x,y), noise3(x,y,z) | Smoothly varying Perlin noise value based on x, x/y, or x/y/z | 基于x、x/y或x/y/z的平滑Perlin噪声值 |
if(c,x,y) | Returns x if c is not 0, otherwise y | 如果c非0返回x,否则返回y |
!x, -x, +x | Logical NOT, negation, or no-op | 逻辑非、取负或无操作 |
x ^ y | x raised to the power of y | x的y次幂 |
x * y, x / y, x % y | Multiplication, division, modulo | 乘法、除法、模运算 |
x + y, x - y | Addition, subtraction | 加法、减法 |
x < y, x > y, x <= y, x >= y | Comparison operators | 比较运算符 |
x = y, x == y, x <> y, x != y | Equality and inequality operators | 相等和不相等运算符 |
x & y, x && y, x | y, x || y | Logical AND, OR | 逻辑与、或 |
get[ch][#]b(x, y) | Read pixel at x,y, or 0 if out of bounds—e.g., getr1b(0,0) | 读取x,y处像素值,若超出边界返回0,例如getr1b(0,0) |
get[ch][#]d(x, y) | Read pixel at x,y or edge pixel if out of bounds—e.g., getr1d(0,0) | 读取x,y处像素值,若超出边界返回边缘像素值,例如getr1d(0,0) |
get[ch][#]w(x, y) | Read pixel at x,y or wrap if out of bounds—e.g., getr1w(0,0) | 读取x,y处像素值,若超出边界环绕到图像另一侧,例如getr1w(0,0) |
getr1b(x,y) | Output the red value of the pixel at position x, y, if there were a valid pixel present. It would output 0.0 if the position were beyond the boundaries of the image (all channels). | 输出x,y处像素的红色值,若位置有效则返回像素值,若超出图像边界返回0.0(适用于所有通道)。 |
getr1d(x,y) | Output the red value of the pixel at position x, y. If the position specified were outside of the boundaries of the image, the result would be from the outer edge of the image (RGBA only). | 输出x,y处像素的红色值,若位置超出图像边界,返回图像外边缘的像素值(仅限RGBA通道)。 |
getr1w(x,y) | Output the red value of the pixel at position x, y. If the position specified were outside of the boundaries of the image, the x and y coordinates would wrap around to the other side of the image and continue from there (RGBA only). | 输出x,y处像素的红色值,若位置超出图像边界,x,y坐标环绕到图像另一侧继续读取(仅限RGBA通道)。 |
Note: Use w and h and ax and ay without a following number to get the dimensions and aspect of the primary image.
备注: 使用不带后续数字的w、h、ax和ay来获取主图像的尺寸和比例。
pCustom、pCustomForce 节点表达式
表达式 | Description | 中文描述 |
---|---|---|
px, py, pz | Particle position on the x, y, and z axis | 粒子在X、Y、Z轴上的位置 |
vx, vy, vz | Particle velocity on the x, y, and z axis | 粒子在X、Y、Z轴上的速度 |
rx, ry, rz | Particle rotation on the x, y, and z axis | 粒子在X、Y、Z轴上的旋转 |
sx, sy, sz | Particle spin on the x, y, and z axis | 粒子在X、Y、Z轴上的自旋 |
pxi1, pyi1 | The 2D position of a particle, corrected for image 1’s aspect | 粒子在图像1比例校正后的2D位置(X、Y) |
pxi2, pyi2 | The 2D position of a particle, corrected for image 2’s aspect | 粒子在图像2比例校正后的2D位置(X、Y) |
mass | Not currently used by anything | 目前未被使用的粒子质量 |
size | The current size of a particle | 粒子的当前大小 |
id | The particle’s identifier | 粒子的唯一标识符 |
r, g, b, a | The particle’s red, green, blue, and alpha color values | 粒子的红、绿、蓝和Alpha颜色值 |
rgnhit | This value is 1 if the particle hit the pCustom node’s defined region | 粒子是否碰撞pCustom节点定义区域,碰撞为1 |
rgndist | This variable contains the particle’s distance from the region | 粒子到区域的距离 |
condscale | The strength of the region at the particle’s position | 粒子所在区域的强度 |
rgnix, rgniy, rgniz | Values representing where on the region the particle hit | 粒子碰撞区域的位置(X、Y、Z) |
rgnnx, rgnny, rgnnz | Region surface normal of the particle when it hit the region | 粒子碰撞区域时的表面法线(X、Y、Z) |
w1, h1 | Image 1 width and height | 图像1的宽度和高度 |
w2, h2 | Image 2 width and height | 图像2的宽度和高度 |
i1, i2, i3, i4 | The result of the intermediate calculations 1 through 4 | 中间计算1到4的结果 |
s1, s2, s3, s4 | The result of the setup calculations 1 through 4 | 设置计算1到4的结果 |
n1..n8 | The values of numeric inputs 1 through 8 | 数值输入1到8的值 |
p1x, p1y, p1z .. p4x, p4y, p4z | The values of position inputs 1 through 4 | 位置输入1到4的值(X、Y、Z) |
time | The current time or frame of the composition | 合成的当前时间或帧数 |
age | The current age of the particle | 粒子的当前年龄 |
lifespan | The lifespan of the current particle | 粒子的生命周期 |
总结
以上表格总结了Fusion中常用的表达式和命令,涵盖动画、文本格式化、粒子系统和节点管理等场景。建议用户:
- 调试复杂表达式:在表达式编辑器中使用
print()
检查中间结果。 - 命令执行:确保在控制台中正确指向当前合成(
comp
)。 - 性能优化:对于
CustomPoly
或pCustom
等节点,尽量简化表达式以提升渲染效率。
评论
隐私政策
✅ 你无需删除空行,直接评论以获取最佳展示效果