+18

Ability to have multiple outputs for the code node

Jason Booth 10 years ago updated by behealed 8 years ago 1
I would like to be able to have multiple outputs for the code node. This would change the function signature such that we don't return a value anymore, but rather assign a value to a passed in 'out' parameter. The current return value semantics limit us to one generically named output and a float4 of data, which is insufficient for some techniques.

Three years old and still sitting here hmm. :P


Just create a "property" node, of any type (except maybe texture asset), and right click it, and click "set global". Then in your code node, in the actual text of the code that is, you can set its value to whatever you like. Just be careful, GPU's are multi threaded, so make sure you do not "use" that global node anywhere where it might get "used" prior to it's value being "set" by your code node. In other words, it needs to be used only DOWN STREAM from the same branch that the code node is on, to guarantee it doesn't get used until after the code node is finished setting its value.


PS: your "code" node has to be created AFTER you create the global property nodes, so that they will be "above" the code node in the shader file, otherwise you'll see errors. You can simply duplicate your code node (ctrl+D) after you make the global nodes.