Jump to content

Procedural Texture: "var aa = 0; aa = aa * 1; aa" Does not work


Recommended Posts

What Application are you using? 
Designer

Are you using the latest release version?
v2.1.1

Can you reproduce it?
Yes

Does it happen for a new document? If not can you upload a document that shows the problem?
Yes

hardware acceleration
Same issue with both.

What happened for you (and what you expected to happen)

Does not work: "var aa = 0; aa = aa * 1; aa"

Does not work: "var aa = 0; var aa = aa * 1; aa"

 

But this does: "var aa = 0; var aa_ = aa * 1; aa_"

Meaning I can't use a variable to update itself?



If for some reason this is by design, I think that it would be a VERY good idea to mention this in the documentation, preferably highlighted in red

Link to comment
Share on other sites

  • Staff

Hi @Ezbaze,

Do you have an afphoto/afdesign setup where the working example is being used?  I'm struggling to see what the end goal is from just the working example and if something needs logging with the Developers around this, a sample file would be a big help!

 

Link to comment
Share on other sites

1 hour ago, stokerg said:

Hi @Ezbaze,

Do you have an afphoto/afdesign setup where the working example is being used?  I'm struggling to see what the end goal is from just the working example and if something needs logging with the Developers around this, a sample file would be a big help!

 

Agreed, here is the file:

image.png.d75e26455d729a2c1f84cd5312fadfe7.png

File: Reassign_Variable.afphoto

Link to comment
Share on other sites

14 hours ago, stokerg said:

I'm struggling to see what the end goal is from just the working example [...]

The end goal of the OP's example is irrelevant.

The bug is that the PT filter produces no effect when a new value is assigned to an already defined variable.

For example, the following contrived example will break the PT:

var aa = 0.2; aa = 0.4; aa

Whereas, the following will not break the PT:

var aa = 0.4; aa

 

Link to comment
Share on other sites

This is old, at least since 1.5, probably from beginning. despite the name „var“, the named objects are constants, not variables. You can assign a value only once per expression.

my workaround is to add a number to the „var“ name for re-assignments.

 

Mac mini M1 A2348 | Windows 10 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080

LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5

iPad Air Gen 5 (2022) A2589

Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps.

My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected.

 

Link to comment
Share on other sites

On 7/8/2023 at 8:08 PM, Ezbaze said:

Meaning I can't use a variable to update itself?

Yes.

Mac mini M1 A2348 | Windows 10 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080

LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5

iPad Air Gen 5 (2022) A2589

Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps.

My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected.

 

Link to comment
Share on other sites

4 hours ago, lepr said:

The end goal of the OP's example is irrelevant.

The bug is that the PT filter produces no effect when a new value is assigned to an already defined variable.

For example, the following contrived example will break the PT:

var aa = 0.2; aa = 0.4; aa

Whereas, the following will not break the PT:

var aa = 0.4; aa

 

That's wrong actually, the issue is with using the variable to reassign the same variable: var a = 0; a = 1; a

Link to comment
Share on other sites

1 hour ago, Ezbaze said:

That's wrong actually, the issue is with using the variable to reassign the same variable: var a = 0; a = 1; a

Actually, what I wrote is not wrong. Your new example is identical to mine, except you used 'a' where I used 'aa' and you used 0 and 1 where I used 0.2 and 0.4.

The bug involves the assigning of anything to an already defined variable.

Link to comment
Share on other sites

Probably this is no bug, but a misleading name.

variables in PT filters are effectively constants, which can only be set once as input.

variables in the lower part are kind of global: these names are recognized in all formulas (channels).

variables set in formulas are local (recognized only in that line/formula per channel.

None of these can be re-assigned.

Mac mini M1 A2348 | Windows 10 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080

LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5

iPad Air Gen 5 (2022) A2589

Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps.

My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected.

 

Link to comment
Share on other sites

1 hour ago, lepr said:

Actually, what I wrote is not wrong. Your new example is identical to mine, except you used 'a' where I used 'aa' and you used 0 and 1 where I used 0.2 and 0.4.

The bug involves the assigning of anything to an already defined variable.

You're right, I just tried "var aa = 1; aa = 0; aa" which should have turned the white fill layer to black but it stayed white 

Link to comment
Share on other sites

7 minutes ago, NotMyFault said:

Probably this is no bug, but a misleading name.

variables in PT filters are effectively constants, which can only be set once as input.

variables in the lower part are kind of global: these names are recognized in all formulas (channels).

variables set in formulas are local (recognized only in that line/formula per channel.

None of these can be re-assigned.

Yes I see how this could be intended, but as someone who writes code I was very surprised when I noticed that it isn't working as code usually does, it also gets very messy the more things you add to the function line input per channel ( Using 0/1 as on/off for parts of PT filter )

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

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

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.