Back to Node List

Pixel Expression

expression_pixel

Computes each pixel with expressions — coordinates, input colors, and time are available as variables

Reviewed
Guide available
The node name and summary are available in English. Port, parameter, and article details are currently shown in Japanese.

Input Ports

NameTypeDescription
画像A
a
Image
任意の画像です。各ピクセルの色を r, g, b, a で参照できます
画像B
b
Image
任意の2枚目の画像です。r2, g2, b2, a2 で参照できます。画像Aより小さい場合は右端または下端のピクセルを反復します

Output Ports

NameTypeDescription
画像
output
Image
式で計算した画像です

Parameters

NameTypeDefaultRangeDescription / Options
R
expr_r
Text
r

Rチャンネルの式です(0〜1)

G
expr_g
Text
g

Gチャンネルの式です(0〜1)

B
expr_b
Text
b

Bチャンネルの式です(0〜1)

A
expr_a
Text
a

Aチャンネルの式です(0〜1)

width
Int
641–1024

画像A未接続時のキャンバス幅です

高さ
height
Int
641–1024

画像A未接続時のキャンバス高さです

Overview

A free-form node that calculates R/G/B/A with an expression for every pixel (equivalent to Pixel Processor in Substance Designer). Build image processing that has no dedicated node—custom blends, mathematical patterns, or channel operations— with four expressions. It evaluates the same expression syntax as Expression Float, once per image pixel.

Usage tips

  • When the filter you need does not exist, start here. You can reference two images through values such as r2, so expressions can implement composites not covered by existing blend modes.
  • Coordinates u / v (0–1) and time can produce animated procedural patterns (for example, sin((u + time) * pi * 8) > 0 creates moving stripes).
  • First confirm the coordinate system with a debug gradient such as expr_r: u, expr_g: v; then write the actual expression.
  • When a dedicated node can do the job (brightness adjustment, thresholding, and so on), it is faster and easier to read.

Related nodes

  • expression_float — numeric version with the same syntax (useful for practicing expressions)
  • blend — use this for standard composites
  • coordinates — when you only need a coordinate map
  • channel_split / channel_merge — dedicated channel-operation nodes

Available variables

Variable Meaning
x, y Pixel coordinates (0 to width−1 / 0 to height−1)
u, v Normalized coordinates (0–1)
w, h Image width and height
r, g, b, a Color of the current pixel in image A (0 when unconnected)
r2, g2, b2, a2 Color of the current pixel in image B
time, frame, total_frames Animation timing information

Functions and operators are shared by all Expression nodes (arithmetic, comparisons, && / ||, sin / cos / abs / min / max / floor, and so on).

Examples

  1. UV gradient with no image input: expr_r: u, expr_g: v, expr_b: 0, expr_a: 1 → an opaque debug gradient
  2. Swap channels: expr_r: b, expr_b: r → swap red and blue
  3. Compare and composite two images: build a custom blend with expressions such as expr_r: max(r, r2)
  4. Procedural pattern: expr_r: sin(x * 0.5) * 0.5 + 0.5 → stripes
  5. Threshold mask: expr_a: (r + g + b) / 3 > 0.5 → only bright areas remain opaque

Notes

  • When image B is smaller than image A, sampling beyond B repeats B's last column and last row for r2 / g2 / b2 / a2.
  • && / || skip the right side once the result is known, and if(condition, A, B) evaluates only the selected branch.
  • Reversed clamp bounds are swapped, sign(0) = 0, and % is a non-negative Euclidean remainder. Division or modulo by zero and sqrt of a negative value produce an error.
  • Expressions run for every pixel, so large images take time to process (pixel-art dimensions are recommended).
  • An invalid expression produces an error. Start by testing a simple expression.
Back to Node List
Pixel Expression — PixPipeline Node Reference