Jump to content

Attribute VOP neighbour node

Recommended Posts

Hi everyone!

I'm REALLY stuck with this issue and seem to be going round in a circle and repeating my self.

So i'm attempting to learn more about the neighbour vop and from what i've heard and seen, it's very powerful and useful. 

Within the project file attached, i'm trying to select point number 464 and it's neighbours and change it's colour white. currently i'm unable to even turn point number  464 on it's own white. Could someone please point me in the right direction? am i approaching this wrong?

I've attached bind exports to a couple of nodes simply to see what values i'm getting back. I have tried looking at the houdini help section and looked at the example project file but i don't seem to be able to carry that across?




Share this post

Link to post
Share on other sites

This diagram is fantastic! thanks a bunch for that.

Just a quick couple of questions, if i had multiple points that i wanted to do this to, would i feed their point numbers directly into the neighbour count node or would the neighbour count node live within the for loop so i would feed the numbers into the beginning of the for loop? 

Also when looking at the plane if the VOP network is working surely there should be a white patch on the grid it self?

Share this post

Link to post
Share on other sites

for multiple points, you need a second loop.

First loop to identify which point you want to find the neighbours
Second loop to actually find the neighbours and colour them

I'd say you're starting to see why AttribVOP is a good thing to hide the scary code to beginners but it quickly starts to be really convoluted to do a simple double loop. I added a VEX solution that does the same job in a few lines, much simpler to debug than a web of lines between nodes in AttribVOP. At least in my opinion.
I'd suggest suffering a bit at the beginning but it's definitely worth spending the time to learn VEX.


Not sure what you mean by the white patch, the grid is indeed coloured in white where neighbours are found.

Edit: even better, if you paint an attribute on points, you can run your AttribWrangle in point mode, which means multithread and save you one loop as you have it for free. Won't make any difference in your scene but try to run the same thing on a multimillion points mesh and it'll be pretty obvious. see file v3




Edited by iamyog
added info
  • Like 1

Share this post

Link to post
Share on other sites

Wow this is really useful! my ultimate end goal is to create the game of life within Houdini, i do know python and use it within Maya and can see it being a lot easier to use coding rather than VOPs.

And yes i'm finding vops to be here and there as i cannot be 100% certain what each node is spitting out or doing or if i'm even using it right. I might go through a bit of VEX tutorials to learn from the ground up as this might be able to make things a lot faster and cut down on a lot of guess work.

Within the first file you uploaded (second post) there are no white patches as far as i can see. 


And it's Cd attribute seems to be 0



Looking at your snippet 2 (row_point) currenly my knowledge of VEX is 0 so i'm trying to pick appart that 1 line to figure out what it's doing as VEX is so different to python. 

I'm slowly picking away at what you've added in VOP and trying to bring it back down to beginners terms. I've painted the attribute Pstate onto points which in turn turn are white. But i'm unsure which vop nodes would do the same job as your Snippet2 as the line of VEX is totally alien to me :( but learning VEX is definitely at the top of the list now! 


Share this post

Link to post
Share on other sites

full disclosure: I've no idea how to recreate this in an AttribVOP without using VEX in a snippet...

I find arrays to be kind of a pain to deal with in Houdini. Possibly by a lack of knowledge on my side.
I think I remember reading there were updates on that, but in the past you could not really save an array as a point attribute. I'm usually using the technique where you convert the data into a string, saved as a string attribute per point then converted back into int/float values after. It works but it's not handy to use. Not even talking about multi dimension arrays.
Since the new array change, I never had to deal with heavy array things to store as attribute so I did not wrap my head around yet. I should.

Back on the topic, you are painting a Pstate attribute and try to use this as an input for the loop.
You declared Pstate as an int array, but if you check the Geometry Spreadsheet (protip: ALWAYS have this open to check what's happening), you will see Pstate is actually empty.

Into AttribVOP, since the array is empty, arrayLength will return 0 and the loop will never iterate.


snippet2 is easy: pt_to_process = row_point[iteration];

I feed a constant called pt_to_process in which I will save the point number I want to work on for this loop iteration.
row_point is the array containing all the points that I want to be considered. This is basically the content of snippet1
iteration is the index of the loop iteration.

row_point could be written as
[id] [value]
[0] [464]
[1] [258]
[2] [211]

First loop iteration, index == 0 so the code output 464 in pt_to_process
2nd loop iteration, index == 1, the code output 258 in pt_to_process

hope it makes sense.


edit: not sure what's wrong with the white patch, I got colours:


Edited by iamyog

Share this post

Link to post
Share on other sites

Thanks for taking the time to help me out this is a MASSIVE help! 

I've realised what you mean about the array within point attributes and just trying to think of a way to get around this. 

Instead of using Pstate to store the point numbers within an array, it could store 0 or 1 and use an attribute import to look up it's value and feeding that into a compare if it's 0 it would not continue if 1 it'll continue to the next for loop.

Would this be a viable option? i know this would be slower as it would have to search every point every frame rather than given a list of point numbers within an attribute. 


I managed to figure out that the array was stored within the row_point[iteration]. But does row_point draw the array from row because of the variable row_, feels like i've explained this poorly, but i only ask because i saw in the VEX solution there were variables with names such as _ncount. But what's really confusing me is the pt_to_process within the constant node. how does the constant node fetch the current points number? There are no inputs going into the constant or any way i can tell for it to fetch the current point number to then store in pt_to_process.


Share this post

Link to post
Share on other sites

Since you plugged ptnum into the length of "for_begin1", I believe you are misunderstanding how the for loop works in an AttribVOP.

An attribVOP, or a attribwrangle set on anything else than detail mode, will process all of your points at the same time through all the cores available on your CPU. It is NOT a linear iteration through all points.
When you plug ptnum into the length input of a for loop, you are actually telling the attribVOP to loop for ptnum'th times.
The way you connected your nodes means:
- For point 0, please loop 0 time.
- For Point 1, please loop 1 time and import the Pstate attribute where ptnum == length (import Pstate from point 1)
- For Point 899, please loop 899 times and import the Pstate attribute where ptnum == length  (import Pstate from point 899, but do it 899 times...)

Regarding the snippet2, the constant is just a blank attribute created outside the snippet that I then fill with the correct point number value.
When you plug a constant in a snippet, it generates the corresponding output for you (try it by yourself). I'm using this output for the rest of the loop.
If I did not plugged the constant pt_to_process in, I would have had to use either the row_point array or the iteration attribute blue arrows ouputs to carry on my loop. Since I want to keep them clean for their own purpose, I created the constant and used it to ouput the data I needed.

pt_to_process does not fetch anything, it is just a placeholder created before where I store the correct data I've found.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now