Tuesday, September 2, 2025

Sunday, August 24, 2025

Procedural Texture Filter System Variables

 Affinity Photo's Procedural Texture Filter System Variables

x, y, rx, ry, w, h, pi, ox, oy, R, G, B, A, C, M, Y, K

x is the horizontal pixel coordinate position beginning with 0 at the left edge of the document and increasing toward the right by 1 for each pixel.

y is the vertical pixel coordinate position beginning with 0 at the top edge of the document and increasing downward by 1 for each pixel.

rx and ry are relative pixel coordinates. These coordinates allow repositioning of the coordinate system in two ways. Double-clicking the mouse on the document moves the origin (ox,oy) to the current position of the mouse. Click and dragging moves the coordinate system from the current position to the position you drag it to.

ox and oy are the origin coordinates that can be repositioned by double-clicking in the image or clicking and dragging.

w is the width of the document in pixels, ie 1024

h is the height of the document in pixels, ie 768

pi is the geometric constant 3.14159265...

RGBA inputs

R contains the pixel information for the red channel in the document. It is not possible to access current image pixels individually from this variable. It is possible to modify the image using the channel outputs.

G contains the pixel information for the green channel.

B contains the pixel information for the blue channel.

A contains the pixel information for the alpha channel.

If the document is in CMYK mode, the letters C, M, Y, and K represent the color pixel information for the document. Note that you won't be able to access your RGB filters if the document is set to CMYK color mode.

p cannot be used as a custom input or as a variable name. p followed by a digit may not be used as a custom input but may be used to define a var variable. This includes p1, p2a, p304, etc.

Variable names must begin with a letter may only consist of numbers and letters, and _ (underscore) characters. Upper and lower case letters are allowed and a1 is not the same variable as A1. Space is not allowed nor are other special characters.

A 1024 x 768 landscape document would have an x value ranging from 0 to 1024, with 0 just to the left of the first pixel and 1024 just to the right of the last pixel. A value of x centered on the first pixel would be .5.

Here are some additional notes on some of the more confusing functions in the PTF that I haven't had a chance to make videos on yet:

rgbtoi(S r, S g, S b) or rgbtoi(V rgb) i is intensity, converts to a grayscale that is better than just taking the RGB average. A weighted average is taken based on color perception according to the following formula: .2989*R+.587*G+.114*B

cerp(T a, T b, T c, T d, T t) Cubic interpolation b and c seem to be the values being interpolated, t is the interpolant, a and d seem to control the slope of the interpolant.

It looks like d may be controlling the slope of the interplant at the endpoint (1) so when d=0 slope=0, d=1 slope=1, d=2 slope=2.

scint(T cui) S Curve interpolant Smooths out the interpolation

sint(T cui) Sine interpolant


Friday, August 22, 2025

Affinity Photo Procedural Texture Filter: Seigaiha

Seigaiha Pattern

  • var v=vec2(x,y)*a/w+vec2(of/2,of/4); // Coordinates with offset
  • var v1=fraction(v)-.5; // Mask 1 Coordinates
  • var m1=smoothstepn(.5-s1/10,.5+s1/10,length(v1))*osci(v.y); // Mask 1 Positive
  • var v2=fraction(v+vec2(0,.5))-.5;  // Mask 2 Coordinates
  • var m2=1-smoothstepn(.5-s1/10,.5+s1/10,length(v2))*osci(v.y-.5); // Mask 2 Negative
  • var v3=fraction(v+vec2(.5,.75))-.5; // Mask 3 Coordinates
  • var m3=1-smoothstepn(.5-s1/10,.5+s1/10,length(v3))*osci(v.y-.25); // Mask 3 Negative
  • m1*m2*m3*smoothosc(b*length(v1),s2) // Mask with lines

Sunday, June 29, 2025

Affinity Photo Procedural Texture Filter

Affinity Photo Procedural Texture Filter Examples

Affinity Help for PTF

List of PTF Functions

This is a list of all of the PTF functions I am aware of. Those used in linked videos are in bold.

stepn no longer works as of v 2.65 for Windows.

Sign Related Functions

abs sign copysign

Rounding Related Functions

ceil floor fraction round roundup rounddown trunc truncate whole fmod irem idiv 

Trig Functions

sin cos tan acos asin atan atan2 pi

Power Related Functions

pow powr sq sqrt 

Statistical Functions

average max mid min

Specialized Math Functions

dim fma rgbtoi

Numeric Range Related Functions

tocui tohcui clamp clampmin clampmax saturate

Geometry and Vector Related Functions

cross dist dist_sq distance dot length length_squared norm normalise normalize

vec2 vec3 vec4 vec5 vec6 tovec3 tovec4 tovec5 tovec6

rev rotl rotr

swap12 swap13 swap23 swapxy swapxz swapyz swaprg swaprb swapgb

neg1 neg2 neg3 neg12 negx negy negz negxy negr negg negb negrg

debump

Interpolation Functions

lerp mix scurveinterp scerp sininterp serp cubicinterp cerp cubic

scurveinterpolant scint sininterpolant sint

Step Functions

mapcui step smoothstep smoothsteplin smoothstepsc smoothstepsin smoothstepcs smoothstepsq smoothstepsqi smoothstepcb smoothstepcbi smoothstepsin smoothstepsini smoothstepcr smoothstepcri smoothsteprt smoothsteprti 

stepn smoothstepn smoothstepnlin smoothstepnsc smoothstepncs smoothstepnsq smoothstepsqi smoothstepncb smoothstepncbi smoothstepnsini smoothstepncr smoothstepncri smoothstepncrt smoothstepnrti

Quantization

quantize quantizelin quantizesc quantizesin quantizecs

Oscillators

osc osci oscsc oscsin osccs osccubic oscsq oscsqi osccb osccbi oscpsin oscpsini osccr osccri oscrt oscrti

smoothosc smoothosclin smoothoscsin smoothosccs

osch oschi oschsc oschsin oschcs oschcubic oschsq oschsqi oschcb oschcbi oschpsin oschpsini oschcr oschcri oschrt oschrti

smoothosch smoothoschlin smoothoschsin smoothoschcs

Noise

noise noisei noisesc noisesin noisecs noisecubic noisesq noisesqi noisecb noisecbi noisepsin noisepsini noisecr noisecri noisert noiserti

noiseh noisehi noisehsc noisehsin noisehcs noisehcubic noisehsq noisehsqi noisehcb noisehcbi noisehpsin noisehpsini noisehcr noisehcri noisehrt noisehrti

perlin perlinsc perlinsin perlincubic perlincs

perlinh perlinhsc perlinhsin perlinhcubic perlinhcs

cellnoise cellnoise2 cellnoisedist cellnoiseedge

dir diri dirsc dirsin dircs 

udiri udir udirsc udirsin udircs

dir3 dir3i dir3sc dir3sin dir3cs

udir3 udir3i udirsc udir3sin udir3cs

Other functions

var

Reserved/Internal Variable Names

w h x y rx ry R G B pi

Unknown: pc p pt px 

Cannot be used as custom inputs: p p0 p1 p2 p3 p4 p5 (p followed by any number) however, these can be used as variable names.

Operators

+ - * / ^ ( ) . = ; ,

Exponentiation has the same priority as multiplication and division: a*b^c =(a*b)^c not a*(b^c).

I am making a series of video tutorials for Affinity Photo's procedural texture filter. This page provides an index for the functions used in each video.

scurveinterpolant scint sininterpolant sint

var vec2 round noisei smoothstepn length norm sqrt step cos sin vec3

rgbtoi

var vec2 atan2 length abs round cos sin smoothstepn dot cellnoisedist oscrti

var vec2 idiv irem fmod length_squared

var norm vec2 sqrt round step length atan2 smoothoscs oscsc sin cos oscsin smoothoscsin

rounddown, floor, roundup, ceil, round, truncate, trunc, whole, fraction, var vec2, atan2, length, osc

fma noisei var vec2 abs perlinhcubic perlincubic serp noisehi

sin cos tan asin acos atan atan2 pi oscsin oschsin


var vec2 norm cos sin dot abs smoothstepn max


var sqrt vec2 fraction step length smoothstepn max abs dot swapxy


var vec2 fraction smoothstepn length osci smoothosc smoothstep osc


var vec2 abs length max min smoothstepn osci

var vec2 clampmin dot smoothstepn abs oschsin

var vec2 length

var vec2 smoothstep osc

var vec2 perlincubic udirsc smoothstep norm debump dot pow

var vec2 clampmin clampmax osc smoothstep

var vec2 atan2 floor smoothstep length cos

var vec2 floor diri step length fraction

var fraction vec2 atan2 osci pow cos floor length

var fraction vec2 atan2 floor osc length pow cos

var vec2 atan2 floor osc length cos

var vec2 noiseh perlincubic

var vec2 vec3 sqrt fraction step max min smoothstep

var vec2 step perlincubic cellnoisedist

var vec2 fraction smoothstepcs length length max 

var vec2 atan length sin smoothstep

var vec2 atan2 length cellnoise abs dirsc smoothstep

var vec2 cos sin vec3 oscsc osccri oschsc osci dirsc

rev rotl rotr swap12 swap13 swap23 swapxy swapxz swapyz swaprg swaprb swapgb neg1 neg2 neg3 neg12 negx negy negz negxy negr negg negb negrg

var norm vec2 sqrt swapxy fraction  length step atan2 quantize 

var vec2 pow noisei smoothstep osccr osci

fraction oscsq

var vec2 noisei cos sin smoothstep osc quantize perlinhcubic osc average

var normalize vec2 sqrt fraction step length smoothstep cos sin

var vec2 cos sin step osc smoothstep  

var vec2 cellnoise cellnoise2 perlincubic perlinhcubic norm cos sin noisehcubic

var norm vec2 vec3 max oscsqi  perlincubic noisehsc noiseh

var vec2 fraction length atan2 oscsc step

var  norm vec2 cos sin perlincubic perlinhcubic noisehcubic 

var vec2 cos sin normalize perlincubic noisehi

var vec2 cos sin oscsc

osc oscsc  

var norm vec2 cellnoisedist dir noisehcubic perlinhcubic debump dot pow

var vec2 vec3 normalize floor fraction smoothstep noisei lerp cellnoise2 oscsc perlin perlincubic

var vec2 length

var vec2 noisei diri length atan udiri dir3i udir3i dirsc 

var vec3 vec2 smoothstep perlincubic

var normalize vec2 fraction floor step

var normalize vec2 sqrt fraction step length smoothsteplin max abs dot swap12

var vec2oscsc osci max

var vec2 fraction oscrt osc fraction  osch noisehsc max norm debump dot pow

var vec2 abs cellnoisedist perlinhcubic serp norm debump dot pow

var vec2 cellnoisedist quantize

var vec2 pow noisei smoothsteplin average cos sin osccr dirsc osc perlinhcubic

var vec2 vec3 perlinhcubic mapcui osccr step osc

var vec2 cellnoise saturate average

var vec2 perlinhcubic osch clamp

var vec2 mapcui max osccr perlinhcubic


var vec2 oscsin perlinhcubic serp


var vec2 pow cellnoise2 norm debump dot


var vec2 vec3 pow perlincubic dir dot


var vec2 perlincubic norm debump dot pow


var vec2 fraction length vec3 cos abs sin pi 


var vec2 oschsin dir perlinh fraction length


var vec2 fraction atan2 floor noisei smoothstep abs cos length sin step oscsin


var vec2 fraction atan2 length abs cos smoothstep


var vec2 smoothsoclin


var vec2 smoothosclin noisehi


var vec2 fraction atan2 smoothstep abs cos floor length


var vec2 fraction smoothstep abs length


var vec2 cos sin perlincubic floor oscsin scerp osc


var vec2 oscsin


var fraction sign rounddown 


var vec2 length osci cellnoise2


var vec2 perlincubic scerp cellnoise2 dir  cos sin osc dot debump dirsc


var vec2 perlincubic scerp cellnoise2 dir vec3 dot debump mapcui perlin


var vec2cellnoise2 dir scerp cellnoise2  perlincubic dot debump dirsc


var vec3 vec2 mapcui smoothosclin


var vec2 dot debump perlincubic dirsc


var mapcui cellnoise cellnoise2 cellnoisedist cellnoiseedge osci


var  mapcui oscsin vec3 dot cellnoise  debump perlin


var vec3 length vec2 atan oscsc sin smoothstep


var vec3 atan2 length vec oscsc oscsq oscrt smoothosclin mapcui


var vec3 atan2 length vec2 oscsc


quantize quantizelin quantizesc quantizesin quantizecs


var oscsc quantize quantizelin quantizesc quantizesin quantizecs


var vec3 oscsin smoothosclin mapcui


var vec3 osci oscsin osccs oscsq oscrt smoothosclin smoothosclin


var vec2 sin cos perlincubic udirsc


var vec3 osci oscsc oscsin(sx) osccs(sx) osccubic oscsq oscsqi osccr osccri oscrt oscrti


osci oscsc osccs oscsq osccb oscpsin osccr oscrt smoothosclin


var osci oscsc oscsin osccs osccubic oscsq oscsqi osccb osccbi oscpsin oscpsini osccr osccri oscrt oscrti smoothosclin smoothosc smoothoscsc smoothoscsin smoothosccs


var vec3 osci cos sin cellnoise


var vec3 osci sin


var osci


osci


var vec3 step oscsc


var vec2 noisei noise noisesc noisesin noisecs noisecubic noisesq noisesqi noisecb noisecbi noisepsin noisepsini noisecr noisecri noisert noiserti


var vec3 vec2 smoothstepsc oscsin udirsin perlincubic


var vec3 vec2 perlincubic udirsin cellnoise noisehcubic


var vec3 vec2 smoothstepsc noiserti


mapcui smoothsteplin smoothstepsc step stepn (stepn no longer works)


var vec2 noisei noise noisesc noisesin noisecs noisecubic


var vec3 vec2 perlinsc smoothstepsc


var vec3 vec2 perlincubic


cellnoise