# Procedural texture, logic functions

## Recommended Posts

Hi Affinity team,

can you please add logic functions that would allow to process if/select-clauses?

i currently try to simulate by + and *, but could lead to complex formulas and wrong results

0 rated as false, all other values rated as true

* means any other value (except those listed above)

logic functions and, or, not should return only 0 or 1, normalizing all non-0 to 1

E.g.

and(a,b) res

0 * 0

* 0 0

* * 1

or (a,b): res

0 0 0

* * 1

not (a) res

0 1

* 0

if (c,y,n) res

0 y n n

* y n y

Ifsign (c, n, z, p) res

C=0 z

c<0 n

c>0 p

##### Share on other sites

I do a fair amount of Procedural Texture programming and handle conditional statements by such as first deriving 0-1 for true-false and then multiplying by the result for condition a then adding multiplying by inverse for condition b. For comparing numbers, I typically subtract and do a roundup (scaling numbers as needed).

eg (untested, so fingers crossed) a version of max(R,G) is:

var ifrg=roundup(R-G); //is zero if green greater than red else 1

var mxrg=ifrg*R+(1-ifrg)*G;

And yes, things get complex!

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
23 minutes ago, dmstraker said:

I do a fair amount of Procedural Texture programming and handle conditional statements by such as first deriving 0-1 for true-false and then multiplying by the result for condition a then adding multiplying by inverse for condition b. For comparing numbers, I typically subtract and do a roundup (scaling numbers as needed).

eg (untested, so fingers crossed) a version of max(R,G) is:

var ifrg=roundup(R-G); //is zero if green greater than red else 1

var mxrg=ifrg*R+(1-ifrg)*G;

And yes, things get complex!

absolutely. Normally a+b can be used for "OR", but if you don't always normalize and have e.g. 1 + (-1) you get wrong results.

##### Share on other sites

Ah yes. -ves of course.

Another gotcha is calcs done as real numbers. So what should be 0 could be just out.

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

Hi Dave (dmstraker)

Are your Procedural Texture  macros cross platform compatible. I run on MAC and have had trouble with your macros in 1.9.1

I don't code but am really interested in getting your macros to work especially the Luminosity ones

I have attached a screen capture of what they look like. (missing sliders)

Thanks for any info

##### Share on other sites
On 3/9/2021 at 8:27 PM, spiderpod7d said:

Hi Dave (dmstraker)

Are your Procedural Texture  macros cross platform compatible. I run on MAC and have had trouble with your macros in 1.9.1

I don't code but am really interested in getting your macros to work especially the Luminosity ones

I have attached a screen capture of what they look like. (missing sliders)

Thanks for any info

Looks like you can scroll down to other sliders -- see the scroll bar to the right of sliders visible.

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

There is a bug (afp-4203) in the current Mac1.9.x versions of the procedural texture dialog where the input controls are not displayed and you only see blank space.

Hoping this is fixed by end of 1.9.2 beta as I use Dave's (great) macros too, a significant enhancement to the attribute based selection of APh.

##### Share on other sites

Thanks Beau for the heads up

Thanks again

## 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...