Correction: Everything that is written in the description of this topic: false understanding of the error. It was found and fixed.
Geometry Nodes are not a programming tutorial. They are not for beginners. It is a programming language that is fast and adapted to the task of procedural modeling. And as in any programming language, if you make a mistake, you fall.
I was making a simple tree generator using matrices to convey branch direction data. And in the process, I noticed very serious drops in performance. I will tell you about an error, which will be very difficult here, where we do not write about what our code details.
You may not understand yet, but the error is:
Just a bunch of vertex multiplication nodes. Their meaning is not important, it is just a test bench. If I run the update, it will be like this:
https://cdn.discordapp.com/attachments/340195875399663617/918881219066884106/2021-12-10_18-03-55_video-converter.com.mp4
(Please note the running time is different from the prompt)
And you can put up with it and say that matrices are expensive.
And you can think and ask: why?
Hint: Anything is expensive if done so blindly.
This error is so simple but not intuitive as long as we are no looking at just a bunch of lines.
It seems to us that we have linked memory cells and all data flows from beginning to end in a straight line.
But, these are not threads, these are function CALLS.
If you write the code, then it looks like this:
MatrixMultiply(
MatrixMultiply(
MatrixMultiply(
MatrixMultiply(
MatrixMultiply(
//INPUT data for any vertex
)
MatrixMultiply(
//INPUT data for any vertex
)
MatrixMultiply(
//INPUT data for any vertex
)
MatrixMultiply(
//INPUT data for any vertex
)
MatrixMultiply(
//INPUT data for any vertex
)
MatrixMultiply(
//INPUT data for any vertex
)
)...CopyPast
)...CopyPast
)...CopyPast
)...CopyPast
For matrices, input 6 vectors, 5 matrices and 6 vertices, 6 ^ (5 + 1)
This is a recursion of 46656 calls! 46656 *… vector multiply! FOR JUST CUBE!
And even a novice programmer will fix:
M1x = MatrixMultiply(
INPUT data for any vertex
)
M1y = MatrixMultiply(
INPUT data for any vertex
)
M1z = MatrixMultiply(
INPUT data for any vertex
)
M2x = MatrixMultiply(
INPUT data for any vertex
)
M2y = MatrixMultiply(
INPUT data for any vertex
)
M2z = MatrixMultiply(
INPUT data for any vertex
)
MatrixMultiply(
M1x,
M1y,
M1z,
M2x,
M2y,
M2z,
)
That is, just capture the result of the matrix to the geometry…
https://cdn.discordapp.com/attachments/340195875399663617/918880481146179594/2021-12-10_18-02-33.mp4
Such a pitfall almost made me write a message about an error in the work of the blender, it confused me. You shouldn’t think that the blender will decide this on its own, this is the rule that now needs to be adhered to, this is how the nodes work.