Skip to main content
Participant
September 19, 2024

addition, subtraction, multiplication, and division produce incorrect results.

  • September 19, 2024
  • 7 replies
  • 626 views

在 Value Processor 和 FX-Map 中,使用 While 循环和 Distance_vec2 进行累积计算后,加法、减法、乘法和除法会产生不正确的结果。

7 replies

Luca Giarrizzo
Community Manager
Community Manager
September 27, 2024

Hello,

 

Thank you for sharing the SBS file. I have received it and will let you know of my findings early next week.

The SBS file is missing some bitmap dependencies, are they necessary for reproducing the issue?

 

Best regards.

Luca Giarrizzo | Quality Engineer - Substance 3D Designer | Adobe
Participant
September 24, 2024

I attempted to send the project file to you via private message, but I couldn't find where to attach the file. So, I uploaded the project to Google Drive. Please retrieve it from there.

https://drive.google.com/file/d/1mhQDKN9YbUfC5X48gViu2eZtJRz3PwiD/view?usp=sharing 

Participant
September 24, 2024

I used the method you provided, setting the values as variables using the 'set' node and performing addition, subtraction, multiplication, and division operations with the 'sequence' node in the 'last' input. As a result, the correct outcome is displayed in the 'Value Processor' node, but the calculations in the FX Map are still incorrect.

I have sent my project to you via private message.

 

Luca Giarrizzo
Community Manager
Community Manager
September 23, 2024

Hello,

 

Thank you for the details! Indeed, feel free to send me a project file to I can assess your use case and the unexpected result.

You may send them to me over direct message.

 

Best regards.

Luca Giarrizzo | Quality Engineer - Substance 3D Designer | Adobe
Participant
September 19, 2024

Apologies, using the Random node is not my actual intention. My real need is to calculate the length differences between different segments of a curve. I am using a While loop and Distance_vec2 for cumulative length calculations along the curve. When performing addition, subtraction, multiplication, and division on the cumulative results, incorrect outcomes occur. If you need the original project, I can send it to you via email.

Thank you very much for your help!

 

Luca Giarrizzo
Community Manager
Community Manager
September 19, 2024

Hello,


Thank you for reaching out, as well as providing files for assessing the problem accurately.

 

The use of Random nodes in the loops means each will provide a different result, which is expected.

If you need to produce 4 random values then use them in the loops, and those values should remain constant, then you may store them in a variable before executing the loops – the 'before' is ensured by using a Sequence node. Then, retrieve that variable in both loops:

 

 

 

Also, I do not recommend using the same variables in both loops with no Sequence node to control when these variables should be used and reset.

 

In other words, you have two loops which both initialize   and  l  variables to 0 then update them on every iteration. However you cannot be sure about when these loops will be computed. The Sequence node is there to provide that control over flow and order or computations.

 

To illustrate my point, I have modified the function in two different ways so we can compare the results:

  1. Each loop use different variables;
  2. Each loop use the same variables, but a Sequence node makes sure one is entirely computed before the other.

 

Both methods provide the same result for the same random seeds:

 

 

 

I hope this is helpful!

 

Best regards.

Luca Giarrizzo | Quality Engineer - Substance 3D Designer | Adobe
Participant
September 19, 2024

In the Value Processor and FX-Map, after using While Loop and Distance_vec2 for cumulative calculations, addition, subtraction, multiplication, and division produce incorrect results.