# [Affinity Photo] Procedural Texture beginner formula info

## Recommended Posts

Hi Everyone,

I have been on a mission to fill the void in the Macro environment by the lack of gradient support.  To this end I was introduced to Procedural Texture and saw some possibilities and started tinkering.  The manifestation of this can be found in several working groupings of R,G,B Vignettes and Linear gradient macros uploaded in the Resource section that I will update as interesting developments occur.

In this, I will attempt to break down some of the math and show you how I am attempting to work around my limited knowledge of geometry(has been a while since trig) to make this accessible to the beginner who wants to implement some control over the basic examples and give some direction over how to navigate this powerful tool.  If you would like some immediate video immersion of outstanding examples, that I may start from or point to, see Graphicxtras.com on youtube.

If anyone has anything to add/correct/questions, comments, etc. please jump in...this is only meant as a supplement to the Affinity Photo Procedural Texture help section that can leave the beginner a little overwhelmed.

So, here is the first installment of my experiences.  And certainly, if anyone wants to use these explanations in video format please feel free...just post a link for everyone to see it.

Procedural Texture 101

These are some common definitions of elements of an equation

w = width of document
h = height of document
x = horizontal axis
y = vertical axis

rx = relative x(position) to upper left hand corner expressed as (0,0) horizontal axis (rx,0)
ry = relative y(position) to upper left hand corner expressed as (0,0) vertical axis (0,ry)

R = red channel
G = green channel
B = blue channel
A = alpha channel

Relative x and y  (rx,ry)

x and y coordinates can also be specified as values relative to any starting point on the screen or any subset of the screen such as an image. On the Web, each clickable area of an image map is specified as a pair of x and y coordinates relative to the upper left-hand corner of the image.

osc(input, parameter)

The following syntax follows the typical convention of function(input, parameter) where the function( = osc )

osci(input, parameter)

This function example represents the oscillation over the set (in this case an interval) of the function( = osci )

This example is formula from the Checkered preset

osci(rx*c/w,ry*c/w)    variable   c(Z)   produces squares

+ addition of variable a(Z) to control vertical axis

osci(rx*c/w,ry*a/w)    c(Z)  produces horizontal rows  a(Z) produces vertical rows

example.  c=0 (no horizontal rows)
c=1 (1 horizontal row)
c=25 (25 horizontal rows)
c=5, a=5  (square with the size of 5 rows horiz and 5 rows vert)(effectively enlarging 5x larger than (1x1)
c=5, a=1  (rectangle with the size of 5 rows horiz and 1 row vert)
etc.

See video example of procedural texture squares at Graphicxtras.com

I will update with macros of these examples as I go along, or if you want to get started go to procedural texture and find the checkered preset and start experimenting.

orig               softlight 50    checkered R,G,B     enhanced*

* enhanced with Dave's Shifter Macros(slight tweeks with all 3) looks like candy.  (These are free macros available thru his InAffinity channel on youtube.  This one came out today...)

Enjoy and Experiment - T V

##### Share on other sites

smoothosc

smoothosc(rx*a1/w,ry*b1/h,c1)
smoothosc(rx*a2/w,ry*b2/h,c2)
smoothosc(rx*a3/w,ry*b3/h,c3)

controllers

a1,a2,a3(R)  r,g,b horizontal shift creates divisions of document width (w)
b1,b2,b3(R) r,g,b vertical shift creates divisions of document height (h)
c1,c2,c3(0,1) r,g,b hard edge shift creates gradation

- notes on controllers

(R)  Real numbers whole and decimal.  Both positive and negative numbers work.  The preset formula was originally set up for (Z)*.

*While searching for hot keys to control the numbers while scrolling over them I found two.  1)  while hovering over (R) number box with mouse, scroll mouse wheel to change the numbers.  2) holding down shift key will shift the whole numbers by increments of 10.  3) holding down control key will shift the decimal by .1.  This is incredibly helpful for fractional increments.  (I can verify this only for Windows).

(0,1) All number between and including 0 to 1.  Represented as a slider.

- notes on formula

This function is a variation of osc and has 3 factors/parameters ( rx, ry, c1 ) separated by commas.

rx  (relative x)  multiplied by a1 (number of horizontal divisions)  divided by w (document width)

ry  (relative y)  multiplied by  b1 (number of  vertical divisions)  divided by  h (document height)  (many times, this will also be divided by document width (w))

c1  this is the smooth portion of the osc formula that creates the gradient (Note that gradient spread shifts equally (+, -) from division edge.)

default                                  r,g,b10x10                              r,g,b10x15                    r10x15,g10x10,b10x10

r10x15,g10x13,b10x10      r10x15,g10x14,b10x13         r15x15,g10x14,b10x13         r20x15,g18x14,b10x13

h r,g,b 10                                h r12,g4,b2                          h r30,g15,b10                         h r79,g61,b21

Here is an example of this in a macro...

EXPERIMENT AND ENJOY  -  T V

##### Share on other sites

Thanks, @T V. This has gone some way to improve my understanding of procedural functions. I might even have another go at using them. Keep up the good work, but I may come back to you for further clarification.

However, I think that this thread really belongs in the Tutorials forum.   I would suggest that a moderator move it.

John

Windows 10, Affinity Photo 1.9.2 Designer 1.9.2 and Publisher 1.9.2 (mainly Photo), now ex-Adobe CC

CPU: AMD A6-3670. RAM: 16 GB DDR3 @ 666MHz, Graphics: 2047MB NVIDIA GeForce GT 630

##### Share on other sites

Helpful. Thanks. I've yet to get properly into oscillators, etc. Mostly doing RGB algebra of late.

It would be great if there was more definitive help available on the PT functions.

Dave Straker

Cameras: Sony A7R2, RX100V

Computers: Win10: Chillblast i9 Custom + Philips 40in 4K & Benq 23in; Surface Pro 4 i5; iPad Pro 11"

Favourite word: Aha. For me and for others.

##### Share on other sites
4 hours ago, dmstraker said:

Helpful. Thanks. I've yet to get properly into oscillators, etc. Mostly doing RGB algebra of late.

It would be great if there was more definitive help available on the PT functions.

While this may be better explained by a math professor or an Affinity developer, I will try to do my best to dissect these into digestible bite sized portions.  Soon I plan on posting some basics on rx,ry math.  May be easier to understand in a video(not my thing...yet...) due to having a visual reference.  I will include simple macros of movement examples.  I think that seeing it and being able to play with it at the same time helps reinforce the connection.

Right now I am about 8 macros ahead of myself of R,G,B variations of the standard presets.  It has increased my appreciation for these formulas beyond belief.  They are all usable by the beginner to create multi colored gradients or use as a starting point and just have exponential fun.  Looking forward to your and everyone's contribution to this. - T V

##### Share on other sites

noise

perlin(rx*c1, ry*d1, a, b)*red

perlin(rx*c2, ry*d2, a, b)*green

perlin(rx*c3, ry*d3, a, b)*blue

controlers                                                                                         default

red, green, blue (0,1) controls base colors                                   r,g,b (0,1) slider =1

a (R) octives ( waves )                                                                     a(R) = 10

b (0,1) persistence ( contrast )                                                       b(0,1) = 0

c1,c2,c3 (R) horizontal shift                                                            c1,c2,c3(R) = 1

d1,d2,d3 (R) vertical shift                                                                d1,d2,d3(R) = 1

- notes on formula

perlin  function controls 4 factors/parameters (position rx, position ry,  parameter a, parameter b)  separated by commas

rx*c1  relative x multiplied by horizontal shift variable (small increments better)

ry*d1  relative y multiplied by vertical shift variable (small increments better)

a = octives  seems to affect hardness in relation to b persistence

b = persistence  seems to act as contrast and blur in relation to  a  when  a > 1

*red  multiply by a number between 0 and 1 can also be thought of as 0-255

default                               horiz r3,g2,b1                    horiz r,g,b=1 vert=0               horiz=0 vert r,g,b=1                    vert r3,g2,b1

Here is an example of this in a macro...

ENJOY AND EXPERIMENT - T V

Apologies, as lost track of where I got this example.  I may have simplified it from a preset as it indicates octives and persistence.  It is an easy introduction into something different and in it's black form I had no perceived use until now in r,g,b.  Please note this can be expanded upon introducing a scale factor to grow, variables for r,g,b separations, etc..  By complete coincidence, go to Graphicxtra.com on youtube and see today's Affinity Photo video.  It will help you finish this off to new levels of creativity!

##### Share on other sites
22 hours ago, T V said:

ENJOY AND EXPERIMENT - T V

OK, so I install and apply your macro to an image, and I get four black or white rectangles. What equations did you use to create these? How can I modify it to suit my needs. I need to grasp the relationship between these identifiers in the formulae to actual parameters that I can insert into an equation.

Say I wanted to create a Perlin Noise pattern that I wish to blend into an image. What formulae do I enter into the boxes in the Procedural Texture filter? Once I can see a couple of worked examples, I should be better placed to create filters myself.

John

Windows 10, Affinity Photo 1.9.2 Designer 1.9.2 and Publisher 1.9.2 (mainly Photo), now ex-Adobe CC

CPU: AMD A6-3670. RAM: 16 GB DDR3 @ 666MHz, Graphics: 2047MB NVIDIA GeForce GT 630

##### Share on other sites
12 hours ago, John Rostron said:

OK, so I install and apply your macro to an image, and I get four black or white rectangles. What equations did you use to create these? How can I modify it to suit my needs. I need to grasp the relationship between these identifiers in the formulae to actual parameters that I can insert into an equation.

Say I wanted to create a Perlin Noise pattern that I wish to blend into an image. What formulae do I enter into the boxes in the Procedural Texture filter? Once I can see a couple of worked examples, I should be better placed to create filters myself.

John

Hi John,

Please double click on the procedural texture layer and the procedural texture dialog box will appear with the formula in the R, G, B locations at the top.  The controllers are at the bottom of panel.  When you make any adjustments of the formula the box at the top with the procedural texture name will disappear.  At this point you will know that you can save the new formula as a preset.  Also, when making adjustments of the controls from the default setting you will be able to save as a control presets just above the controls.  When you save these settings you will be able to see the control settings to know how you ended up where you are.

Please see the wikipedia  perlin link for more info.  These formulas seem to use the x,y coordinates as a square grid cell to warp in a predictable way.  That is how the knowing the math function and what they do help you make the effects that you want.  See Graphicxtra for some outside of the box creativity...

These examples are not perfect.  It is a mystery to me when I merge the colorful representation to a pixel layer or overlay it seems to mute the colors to a 50% greyed out(hue).  Applying a blend mode at 100% softlight looks as if it was really 50% opacity(softlight nullifies the 50% grey visibility).  I have verified that other formulas are not acting as this.  Perhaps this is a problem using the perlin function as perlin alone. Perlinsc does not change this problem.

I will look for other perlins as examples...  - T V

##### Share on other sites

noise 2

var v1=vec2(rx,ry)*cells1/w; tocui(perlinhsc(v1,oct1,pers1)*cont1)+br1
var v2=vec2(rx,ry)*cells2/w; tocui(perlinhsc(v2,oct2,pers2)*cont2)+br2
var v3=vec2(rx,ry)*cells3/w; tocui(perlinhsc(v3,oct3,pers3)*cont3)+br3

controllers

oct1,oct2,oct3(Z) r,g,b octaves                               default to 5
pers1,pers2,pers3(0,1) r,g,b persistence               default to .5
cont1,cont2,cont3(0,1) r,g,b contrast                     default to 1
br1,br2,br3(-1,1) r,g,b brightness                             default to 0
cells1,cells2,cells3(Z) r,g,b cell count                     default to 10

- notes on formula

variable  var (defines the variable v1)
v1=vec2(rx,ry)*cells1/w;
vec2 creates a vector at relative (x,y) position
multiplied by cells1 divided by document width creates size or scale in relation to width, separated by a semicolon;
the variable v1 can then be used in the function.

- notes on function

tocui(perlinhsc(v1,oct1,pers1)*cont1)+br1

tocui is a numeric range conversion between 0 and 1

tocui controls (perlinhsc function multiplied by contrast)
perlinhsc (harmonic s curve) function with 3 factors/ parameters (v1,oct1,pers1)
multiplied by contrast (cont1) effects hue/intensity of color
addition of brightness (br1) effects light to dark

default                           persistence r,g,b=1             persistence r0,g.5,b1                      red cell 9                     red cell 9 green cell 8

Here is an example of this in a macro...

ENJOY AND EXPERIMENT - T V

##### Share on other sites

noise 3

var v=vec2(rx,ry)*(a1/w); noisesc(v+(udirsc(v)*b1))
var v=vec2(rx,ry)*(a2/w); noisesc(v+(udirsc(v)*b2))
var v=vec2(rx,ry)*(a3/w); noisesc(v+(udirsc(v)*b3))

controllers

a1,a2,a3 (Z)  r,g,b square count             default to 10
b1,b2,b3 (-1,1)  r,g,b turbulence            default to 0

- notes on formula

var v=vec2(rx,ry)*(a1/w);

variable v=vec2 creates vector at (rx,ry)
multiplied by ( a1(Z) square count divided by document width ) separated by a semi colon; creates divisions of document width

- notes on function

noisesc(v+(udirsc(v)*b1))

noise s curve ( with 1 factor/parameter )
( variable v + ( udirsc ( variable v ) multiplied by turbulence input b1(-1,1) )
udirsc  directional noise s curve ( with 1 factor/parameter )

default rgb10                          r12,g11,b10                             r20,g15,b10                r20,g15,b10 rt-1,gt0,bt1            rgb10,rt-1,gt0,bt1

Here is an example of this in a macro...

EXPERIMENT AND ENJOY - T V

##### Share on other sites

Droplets

var v1=vec2(rx,ry)*(a1/w); smoothstepn(c1-(b1*0.1), c1+(b1*0.1), osc(v1+(udirsc(v1)*d1*2)))
var v2=vec2(rx,ry)*(a2/w); smoothstepn(c2-(b2*0.1), c2+(b2*0.1), osc(v2+(udirsc(v2)*d2*2)))
var v3=vec2(rx,ry)*(a3/w); smoothstepn(c3-(b3*0.1), c3+(b3*0.1), osc(v3+(udirsc(v3)*d3*2)))

controllers

a1,a2,a3 (Z)  r,g,b square count          default to 10
b1,b2,b3 (0,1)  r,g,b smoothing           default to 0
c1,c2,c3,c4 (0,1) r,g,b offset                default to .5
d1,d2,d3,d4 (-1,1) r,g,b turbulence      default to 0

- notes on formula

var v1=vec2(rx,ry)*(a1/w);
vec2 creates vector at relative (x,y) multiplied by input a1 divisions divided by doc width, separated by a semicolon;

- notes on function

smoothstepn(c1-(b1*0.1), c1+(b1*0.1), osc(v1+(udirsc(v1)*d1*2))

smoothstepn is a stepping function and has 3 factor/ parameters

(c1-(b1*0.1),
input offset c1(0,1) minus ( smoothing b1(0,1) multiplied by 10 percent )

c1+(b1*0.1),
input offset c1(0,1) plus ( smoothing b1(0,1) multiplied by 10 percent )

osc(v1+(udirsc(v1)*d1*2))
oscillation osc function with 1 factor/ parameter
( variable v1 plus( udirsc ( variable v1 ) multiplied by input d1 (-1,1) multiplied by 2))  udirsc is directional noise s curve with 1 factor/parameter

default                               scr12,g11,b10                         scr30,g15,b5                          rt-1, gt-.5, bt0           sc45,15,10 smooth=1 turb-.5,.5,1

Here is an example of this in a macro...

ENJOY AND EXPERIMENT - T V

##### Share on other sites

Urban Camoflage

var v1=vec2(rx,ry)*(a1/w); noisei(v1+(dirsc(v1)*b1*4))
var v2=vec2(rx,ry)*(a2/w); noisei(v2+(dirsc(v2)*b2*4))
var v3=vec2(rx,ry)*(a3/w); noisei(v3+(dirsc(v3)*b3*4))

controllers

a1,a2,a3(Z) square count                default set to 10
b1,b2,b3(0,1) turbulence                  default set to 0

- notes on formula

variable var v1=vec2(rx,ry)*(a1/w);
var creates variable v1
vec2 creates vector at relative (x,y)
multiplied by a1(Z) divided by document width sets divisions by document width, separated by a semicolon;

- notes on function

noisei(v1+(dirsc(v1)*b1*4))
noisei noise function interval with 1 factor/parameter
uses variable v1 plus
dirsc directional noise s curve with 1 factor/parameter (v1)
multiplied by b1(0,1) turbulence percentage multiplied by 4

default                         sc = 10 rt.25, gt.13            sc = 10 rt.25,gt.5,bt.75        sc20,15,10 turb .25,.5,75        scr20,g15,b10 turb = 1

Here is an example of this in a macro...

ENJOY AND EXPERIMENT - T V

##### Share on other sites

Oils

var v1=vec2(rx,ry)*(a1/w); perlin(v1+(dirsc(v1)*b1),5,0.5)*c1
var v2=vec2(rx,ry)*(a2/w); perlin(v2+(dirsc(v2)*b2),5,0.5)*c2
var v3=vec2(rx,ry)*(a3/w); perlin(v3+(dirsc(v3)*b3),5,0.5)*c3

controllers

a1,a2,a3(Z) r,g,b square count                  default set to 10
b1,b2,b3(0,1) r,g,b turbulence                   default set to 0
c1,c2,c3(0,1) r,g,b brightness                    default set to .5

- notes on formula

variable var v1=vec2(rx,ry)*(a1/w);
var creates variable v1
vec2 creates vector at relative (x,y) position
multiplied by a1(Z) square count divided by document width, separated by a semicolon; creates divisions of document width

- notes on function

perlin(v1+(dirsc(v1)*b1),5,0.5)*c1

perlin function with 3 factors/parameters separated by commas

v1+(dirsc(v1)*b1)  variable v1 plus directional noise s curve function with 1 factor/parameter dirsc ( variable v1 ) multiplied by b1(0,1) turbulence
fixed input 5 octaves
fixed input .5 persistence
multiplied by c1(0,1) brightness

default                               scr20,g15,b10                   r30,g20,b10,rtgtbt1        r30,g20,b10,rtgtbt1,rb.75      r30,g20,b10,rb.75,gb.5,bb1

Here is an example of this in a macro...

ENJOY AND EXPERIMENT - T V

##### Share on other sites

@T V I'm out of likes and thanks to spend on this forum, so like this: great hints, thanks! 😀

##### Share on other sites
3 hours ago, wigglepixel said:

@T V I'm out of likes and thanks to spend on this forum, so like this: great hints, thanks! 😀

Thanks from me as well. I think that I may actually be able to create one of these textures myself before too long!

John

Windows 10, Affinity Photo 1.9.2 Designer 1.9.2 and Publisher 1.9.2 (mainly Photo), now ex-Adobe CC

CPU: AMD A6-3670. RAM: 16 GB DDR3 @ 666MHz, Graphics: 2047MB NVIDIA GeForce GT 630

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×

• #### Affinity

×
• Create New...