DDX
DDX, straight out of the Unreal material editor
- imga
- IMAGE
If you've spent any time in a shader or material editor, you've met DDX: the partial derivative of a value with respect to the screen's x-axis. It's how graphics programmers detect edges, build normal perturbations, and measure local change. This node ports that idea to image space - it computes, for each pixel, the difference between the pixel and its neighbor to the right, scaled by the image width.
The default formula reads:
result = (imga[:, Y, X, :] - imga) / 16 * width
which is "the neighbor minus the current pixel," divided by 16 (the author's chosen smoothing factor) and multiplied by width to normalize the derivative across resolutions. The output is bright where the image changes rapidly in x, black where it's flat. It's edge detection, but directional - only horizontal transitions survive.
What DDX is actually for
- One-directional edges. Unlike the pack's Outline (which catches edges in all four directions), DDX only sees horizontal change. That's useful when you want a directional gradient field, not a full edge map - think shading a cylinder so only the curved side gets a highlight.
- Reading a depth map. Feed a depth pass through DDX and you get a slope map - the tilt of every surface. That's raw material for fake-lighting effects.
- A teaching tool. It's the most direct possible illustration of "the derivative of an image," and this pack is explicitly about making image math visible.
Inputs and outputs
formula- the derivative expression, pre-filled and editable. Change they_shiftto 1 (andx_shiftto 0) and you've built a DDY - vertical derivative. The comment structure in the default script basically invites that.imga- the input image; sets output resolution.
One IMAGE output.
Install
ComfyUI Manager → search "FuncAsTexture", or:
cd ComfyUI/custom_nodes
git clone https://github.com/CoiiChan/ComfyUI-FuncAsTexture-CoiiNode
# restart ComfyUI
No models, no requirements.txt. Category: FunctionAsTexture.
Gotchas
- The
/16 * widthscaling is opinionated. On a 512-wide image that's roughly a factor of 32, so a full black-to-white step produces a value around 32 - massively over 1.0. Preview it and it'll look blown out by design. Clamp (the pack's Clamp node) or accept it as a feature, but don't expect display-ready output. - The boundary column. At the right edge there's no neighbor, and the code clamps the sample coordinate to the last column, so the derivative there is zero. Minor, but it means the rightmost pixel column reads as "flat."
- It's a pixel difference, not a convolution. DDX compares a pixel to its immediate neighbor, which is the rawest form of differentiation - sensitive to noise. If your input is noisy, the derivative amplifies it.
DDX is the pack wearing its Unreal-engine heritage on its sleeve, and it's genuinely the node to reach for when you want to measure change rather than detect edges. The formula is short enough to read, which is exactly the point of this pack.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| formula | STRING | x_shift = 1 y_shift = 0 height, width = imga.shape[1:3] new_x = np.clip(np.arange(width) + x_shift, 0, width - 1) new_y = np.clip(np.arange(height) + y_shift, 0, height - 1) X, Y = np.meshgrid(new_x, new_y) result = (imga[:, Y, X, :]-imga)/16 *width | — |
| imgaopt | IMAGE | Optional ,Reference size ,Default =(1,512,512,3) |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |