Unexpected behavior from Vector Converter in Node Geometry Editor

I’ve been playing with the NGE, and am a bit confused by the Vector Converter. Here’s my editor: Babylon.js Node Geometry Editor

As you can see, I’m trying to scale the spheres proportionally to the y value of their position. I’m feeding in random values into the converter, sending the xyz output to the position input of Instantiate and sending the y output to a Map Range for scaling. However, it’s not working. The scaling seems totally random and not correlated to the height.

I placed debug nodes to capture the output of the Vector Converter, and expected the Y value in the XYZ output and the Y value output to be the same, however, they’re not. They seem unrelated.

What am I missing?

I think what’s going on is that each output is calling the random function again, so it’s effectively a new value. But there is a way to disable this behavior, the LockMode on the random blocks:

With that the values match: Babylon.js Node Geometry Editor (babylonjs.com)

I know @PatrickRyan is hard at work in the NGE documentation, so maybe he has written something about LockMode already? (please keep in mind he’s OOF so it will take a while for him to see this)


@thomas, the concept of context that comes with this tool is the hardest to grasp because it is so different than all our other tools. Basically, you have to know when you are evaluating context and what that context will be. For any node that can evaluate context, you have to tell it whether to evaluate it each the time the node is called or to evaluate it once and return the same value for each call. Similarly, there are nodes that generate random data of some sort and those have a lock mode on them which limits when the random data will be generated. You can do it always, only on loop (for the closest possible looping node), or only on instance (which will generate the data once per instance created). The last one, once per instance, also works if you aren’t instantiating anything but have nested loop nodes which could generate the data many times. Locking the node to generate per instance acts like a restriction to only ever generate the date once if there is no instancing of the mesh.

The best parts of the documentation to read would be this section about context and how it is used. We also have a quick description of lock mode on the random node, but we need to go back and expand it since we added lock per instance after the initial documentation was written. I will likely also go back and add a section after evaluating context to dive deeper in to lock mode as it goes hand-in-hand with context evaluation.