VOP array append.

   3860   3   1
User Avatar
Member
2 posts
Joined: Nov. 2015
Offline
Hi everyone,

I wonder if someone could help me with arrays in a VOP context please.
I'm trying to feed a detail attribute (integer array) with point numbers filtered in an attribute VOP.
My problem is that I can append only one point in the array and I have no idea how to get all of them.
I guess I need a “for loop” but I didn't have any success so far.
Am I wrong when I assume a VOP node is a loop for each point?

Thanks.

Attachments:
arrayAppend01.JPG (81.8 KB)

User Avatar
Member
1736 posts
Joined: May 2006
Offline
The great thing about vops/vex is that they run in parallel across all points.

The curse of vops/vex (sometimes) is that they run in parallel across all points.

For this parallelism to run efficiently, its best if you don't allow points to access information of other points. There's ways around this, but it gets fiddly quickly. For example, you could change your point vop to run in detail mode, which turns off the parallelism, but then you have to control looping through all the points yourself, reading their attribs one by one.. its boring.

Similarly, setting a detail attrib from inside a point vop becomes a race; all the points are trying to set it simultaneously, none have context of what the others are doing. Again, there's tricks and ways around, but best to avoid.

Here's the way I was shown to deal with this sort of thing, it feels more ‘houdiniesque’ to me, for want of a better phrase.

Basically, do it in 2 nodes. First a point vop (or wrangle) to tag points, then a detail vop (or wrangle) to loop through the tagged points, create the array, assign it to a detail attribute.

The example I've attached blasts the ‘boring’ points after the point vop, then uses an attribcopy to put the detail attrib back onto the original geo. There's shorter ways, but this makes it clear to debug when things go wrong, works well enough for me.

To answer your question, no, the for loop vop doesn't loop points, its just a loop. What you do inside the loop is up to you (eg, it could access points, or accumulate colour on the current point, or whatever else), but the loop by itself doesn't implicitly know how to loop over points.


-matt

Attachments:
points_to_detail_array.hipnc (123.1 KB)

http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
2 posts
Joined: Nov. 2015
Offline
Thank you so much for your time Matt ! this is very very helpful !
I was just trying to optimize the process using a compare for both point and detail attribute.
But I understand a bit more the concept of data flow inside a VOP node thanks to you.
Sorry for my ignorance but would it be easier to do that kind of thing inside an attribute wrangle?
I noticed you use Bind attribute. Is there any difference with a set attribute?
I read somewhere that a bind attribute is faster then set attribute but I'm not sure if it's still true in H15.

Cheers!
User Avatar
Member
1736 posts
Joined: May 2006
Offline
Re vops vs wrangles, depends on the task. Sometimes vops are easier, especially if you're doing things like mixing different noise functions or patterns, or you don't have a clear idea of what you want to do, and are just sketching ideas. The drag-n-drop, wire this-to-that is more intuitive. Other times, like a simple statement or a loop, wrangles are easier.

Don't forget you can combine vop and vex by using a snippet vop in a vopnet. Best of both worlds!

Re bind vs set, I started using houdini in earnest around v13, when binds became the preferred way. Or to be clear, any new examples in the help from v13 onwards, or any hda's created by sidefx, all used binds rather than set attribs. When I asked a co-worker, he shrugged and said ‘That’s how sidefx are doing it, I guess we should do the same.'

There's some posts either here or on odforce by some sidefx folk, they explained why bind was better, but I don't remember the details. Something about performance or memory.

Having just tried to use a setattrib while typing this, now I remember why i prefer bind; it implicitly uses the current @ptnum, whereas a setattrib requires you to connect it. Setattribs are handy if you need to set it on other geo of course, or if you're in a detail vop and need to set it on an explicit point, but for most cases, bind is less effort.
http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
  • Quick Links