Docs Visual

ComplexOp

Treats the image plane as the complex plane and applies a complex function to it: square, root, exp, log, the trigonometric and hyperbolic families, with iteration, a pre and post transform and a choice of edge handling.

◧ Visual

Why use it

Warping an image through a complex function is a GLSL job: the complex arithmetic, a mapping from pixels to the plane, transforms around it, and a rule for what happens past the image edge. ComplexOp has all of it behind a menu.

It reads the UV of every pixel as a complex number, runs it through the function you pick, and samples the input image at the result. A square folds the plane once around the origin; a log turns rings into stripes; the trigonometric functions tile and warp the picture in ways a plain Transform TOP cannot reach. The complex math is taken from Ricky Reusser's Shadertoy implementation, credited in the shader source.

Features

How to use it

  1. Create it from the FNS tab of the OP Create dialog.
  2. Wire an image into it. A photo with clear shapes, or a grid, makes the warp easy to read. With nothing wired in, it works on a built-in UV map at Resolution.
  3. Pick a function from Op: csqr, csqrt, cexp, clog, cinv, csin and the rest of the trigonometric and hyperbolic families, their inverses, cpow and more. None passes the plane through, so only the transforms and Extend act.
  4. Switch on Center UV to put the origin of the plane in the middle of the image. Off, z runs 0 to 1 from the bottom-left corner, so you only see the quarter of the plane above and to the right of the origin. Switch on Aspect as well to keep circles round on a non-square image.
  5. Move the point of interest with the pre transform: Trans, Rot, Scale and Pivot act on the plane before the function, in the order Transform Order sets. Animate them to get motion out of a still image. Post Trans, Post Rot, Post Scale and Post Pivot act on the result.
  6. Fold further with Op Iter, which applies the function again on its own result, up to 64 times. Boundary stops the iteration once the value passes that radius; 0 switches the test off.
  7. Two functions take a value: Power is the exponent for cpow and the base of the logarithm for clog, and Const is what cconst returns.
  8. Choose what fills the frame where the warped coordinates leave the image with Extend: hold the edge, zero, repeat or mirror. The borders output keeps the mapped image only near the edges of each repeated tile, with Borders setting where that soft edge starts.
  9. Fade the effect in and out with Blend: 0 is the unwarped image, 1 the full warp.

Chaining functions

The second output, out2, is the mapped coordinates as a UV field in red and green. Two things use it:

  • A second function after the first. Wire out2 into another ComplexOp and switch its Operand/Map off. It then reads its input's red and green as the complex numbers to work on, so its out2 is both functions in a row. Center UV and Aspect apply in map mode only.
  • Sampling an image. Look up your image through the field with a Remap TOP, or with ComplexMix, which also combines two fields by adding, multiplying, dividing or raising one to the other.

Keep a float Pixel Format wherever the UV output feeds another Complex tool or a Remap TOP, or the coordinates are quantised.

Inputs and outputs

  • in1 (TOP): the image to warp.
  • out1 (TOP): the warped image.
  • out2 (TOP): the mapped UV field, for feeding another sampler.
  • borders (TOP): the border mask, where the mapped UV left the image.

Get it

Tick it on the install page and it installs with the rest of your setup and stays up to date.

Download ComplexOp.tox Version 1.0.4, the tool on its own. It works in any project, and this copy never updates itself.

Parameters

Custom

ControlType / defaultWhat it does
Operand/MapUv on / offoff On: the input is an image, warped through the function over a screen-space complex plane (Center/Aspect apply). Off: the input red/green channels ARE the complex operand, for chaining the UV output of another Complex Op.
OpOp menunone The complex function applied to z. None passes z through, so only the transforms and Extend act.
Options: none, csqr, csqrt, cexp, clog, cinv, cabs2, cconj and 19 more
PowerPower number2 Base of the logarithm for Logarithm, or the exponent n for Power (z^n). Enabled only for those two functions.
ConstConst number0 Real and imaginary part of the constant returned by the Constant function (enabled only for Constant).
Op IterOpiter number1 How many times the function is applied in a row (1-64). Higher values fold the image further; Boundary can stop the iteration early.
Center UVCenter on / offoff Map mode only. Puts the complex origin at the image centre (z runs -1..1) instead of the bottom-left corner (0..1). With Op None the result is the image tiled by the Extend mode.
AspectAspect on / offoff Map mode only. Scales the complex plane by the image aspect so circles stay round on non-square images.
Transform OrderXord menuScale Rotate Translate Order in which the pre transform applies scale, rotate and translate to z before the function.
Options: Scale Rotate Translate, Scale Translate Rotate, Rotate Scale Translate, Rotate Translate Scale, Translate Scale Rotate, Translate Rotate Scale
TransOptrans number0 Pre transform: moves z along x and y before the function.
RotRot number0 Pre transform: rotates z by this many degrees before the function.
ScaleOpscale number1 Pre transform: scales z along x and y before the function.
PivotPivot number0 Pre transform pivot (x, y): the point that rotation and scale happen around.
Post Transform OrderXord2 menuScale Rotate Translate Order in which the post transform applies scale, rotate and translate to the result of the function.
Options: Scale Rotate Translate, Scale Translate Rotate, Rotate Scale Translate, Rotate Translate Scale, Translate Scale Rotate, Translate Rotate Scale
Post TransPosttrans number0 Post transform: moves the result along x and y after the function.
Post RotPostrot number0 Post transform: rotates the result by this many degrees after the function.
Post ScalePostscale number1 Post transform: scales the result along x and y after the function.
Post PivotPostpivot number0 Post transform pivot (x, y): the point that rotation and scale happen around.
BoundaryBoundary number0 Escape radius: iteration stops once |z| exceeds this value, keeping the last value inside. 0 disables the test.
BordersBorders number0 Start of the soft edge for the borders output (third output), which shows the mapped image only near the edges of each repeated tile: 0.5 is the tile centre, 1 the tile edge.
ExtendMode menuMirror How the image is sampled where the warped coordinates leave 0..1: Hold the edge pixels, Zero (transparent black), Repeat the image, or Mirror it.
Options: Hold, Zero, Repeat, Mirror
BlendBlend number1 Mix between the unwarped coordinates (0) and the warped ones (1).

Common

ControlType / defaultWhat it does
ResolutionResolution number1280 Width and height of the built-in UV map used when nothing is wired into the input. Disabled while an input is connected; the output then takes the input resolution.
Input SmoothnessInputfiltertype menuInterpolate Pixels Filtering used when sampling the input image.
Options: Nearest Pixel, Interpolate Pixels, Mipmap Pixels
Viewer SmoothnessFiltertype menuInterpolate Pixels Filtering used when the output is displayed at another resolution.
Options: Use Input, Nearest Pixel, Interpolate Pixels, Mipmap Pixels
Pixel FormatFormat menuUse Input Pixel format of the outputs. Keep a float format when the UV output feeds another Complex Op or a Remap, or the coordinates are quantised.
Options: Use Input, 8-bit fixed (RGBA), 16-bit float (RGBA), 32-bit float (RGBA), 10-bit RGB, 2-bit Alpha fixed (RGBA), 16-bit fixed (RGBA), 11-bit float (RGB), Positive Values Only, 8-bit fixed (Mono) and 15 more