Jump to content

Max value of surrounding points attribute / Attibute Gradient Field


dpap

Recommended Posts

How can I find for every point, which one of its 8 surrounding points (not only out of the 4 neighbours)(pic.2)

has the maximum value of an attribute ?

I want to create a vector at each point that points to the direction that the attribute increases(pic.1)

I believe this is called Attibute Gradient.

I want to achieve that in VOPS. I have made some progress but something is not right.(pic.3)

I know for sure that one of my mistakes, is that when ask from pcopen the 8 closest points, one of them is the lookup point itself..

How do I exclude it?

Any help or idea is more than welcome!!!

post-9497-0-58971900-1385595915_thumb.jp

post-9497-0-69394600-1385596492_thumb.jp

post-9497-0-24660000-1385596780_thumb.jp

Attribute Gradient 1.hipnc

Link to comment
Share on other sites

You can use the primneighbours expression to store all those 8 points in an attribute for each point.

Then parse that string in VEX and loop through all those points, and do a comparison to get the maximum using the max function.

Finally store the result :)

Link to comment
Share on other sites

Thanks for your replies!

@ edward : this doesn't work.. (only works for point 0. see pics)

@magneto : I managed to make a string attr with the surrunding points as you said. However my vex skills are reeeealy bad! I am not a programer...

Isnt there way to do this with vops?

I got the numbers from the string into an array (with an inline code...very inconvinient....) but how do I feed them one by one in the for loop?

The workflow with arrays in houdini is very bad if you dont know vex... Actually you cant use arrays in Houdini if you dont use vex.. Thats so disappointing...

post-9497-0-30140600-1385636294_thumb.jp

post-9497-0-96823200-1385636298_thumb.jp

post-9497-0-35756800-1385638941_thumb.jp

primneighbours.hipnc

  • Like 1
Link to comment
Share on other sites

If you use the Inline VOP, you can do it in VOPs :) But otherwise as you have also discovered there are no arrays in VOPs, so using Inline is pretty much the same as using the Point Wrangle SOP. If you use the Point Wrangle SOP, you might as well use the Attrib Wrangle :)

If it's always a fixed number, I suppose you could output 8 elements from the Inline VOP. But I don't think it's as robust, and for loops is a little harder to do in VOPs.

Link to comment
Share on other sites

How can I find for every point, which one of its 8 surrounding points (not only out of the 4 neighbours)(pic.2)

has the maximum value of an attribute ?

I want to create a vector at each point that points to the direction that the attribute increases(pic.1)

I believe this is called Attibute Gradient.

I want to achieve that in VOPS. I have made some progress but something is not right.(pic.3)

I know for sure that one of my mistakes, is that when ask from pcopen the 8 closest points, one of them is the lookup point itself..

How do I exclude it?

Any help or idea is more than welcome!!!

just to make sure i understand what you are after:

do you want the vector pointing to the max-value of the neighbouring points or is it rather the actual gradient of the attribute what you would like to calculate?

because that´s not the same.

petz

  • Like 1
Link to comment
Share on other sites

@Petz :

I want to find one vector for every point,

that starts from the point itself

and ends at one of the surrounding* points

which has the highest value amongst them.

I thought this was essensially the culculation of the gradient of the attribute..No?

*there is a difference in the definition between "neighbouring"(connected with an edge to the lookup point, 4 point in this case) and

the surrounding points(pic 2) which are 8.

Link to comment
Share on other sites

@Petz :

I want to find one vector for every point,

that starts from the point itself

and ends at one of the surrounding* points

which has the highest value amongst them.

I thought this was essensially the culculation of the gradient of the attribute..No?

*there is a difference in the definition between "neighbouring"(connected with an edge to the lookup point, 4 point in this case) and

the surrounding points(pic 2) which are 8.

no, thats two different things even if it seems to be the same at a first glance.

well, there are some similarities, for example both are tangent vectors but the definition and how the gradient get calculated is very different. a vector pointing to the max-value-point of its surrounding is just like a very rough approximation of the gradient but not the same!

to get the gradient you´ll usually need to calculate partial derivatives (differentiate a function). in your case there is no function so you have to solve it nummerically.

anyway, attached is a file where you can see the difference. i did´nt calculate derivatives in the example, instead i used the fact that the gradient is allways perpedicular to the contour line of an value. that way you do not have to care about boundary conditions ...

btw. instead of primneighbours(...) you want to use pointneighbours(...) to get the string. with higher polycounts i would stay away from that expression since it will be slow and is not really needed ...

hth.

petz

gradient.hipnc

  • Like 4
Link to comment
Share on other sites

Petz!

I dont know how to thank you man for sharing your knowldge...

Your example file is like a lesson in a box!

But what impressed me most is the way you calculated the gradient field.

You actually solved a numerical problem in kind of a geometric way !

I would never have thought of that. How did you come up with this idea?!

Respect man ! Respect!

I realised also that there are some functions in Vex called "Du " and "Dv " . Would they be the ones to use if you wanted to calculate the actual derivatives in more typical way?

How about the "Gradient" and "Contour" functions? Could there be any use for them in this situation or do they only work in SHOP and COP context?

you do not have to care about boundary conditions ...

:) You time-traveled me around 12 years back...Nowadays my differential equation skills are more than rusty am afraid!

Thank you once again!!!

Edited by dpap
Link to comment
Share on other sites

If you've an array from each 8 points as you have mentioned, won't it be possible to have the vop inside a foreach sop ? That way it will be looped through each one.

Just crossed my mind. Don't know if it will work. I am a noob in houdini :D

Link to comment
Share on other sites

@xrm: that could be done but it would be slower in comparison to a vex based solution

@ Anim:

I recently realised what you just mentiond but Polyframe in H13 doesn't work when you feed other attribute than color . Maybe a bug,I dont.(...yes you can work around it....)

Moreover it gives funny results in some areas like the equator of a torus . Have a look a the vectors in the first pic of another post and you will see what I mean.

http://forums.odforc...e-flow-problem/

Edited by dpap
Link to comment
Share on other sites

1. it works with vector attributes but computing gradient for each component so you should have no problems converting float attrib to vector or for 12.5 you can convert it to uv attrib since Polyframe could compute gradient for uvs even prior to 13

2. the way you are using Polyframe there is absolutely not what I was talking about since you are not using it to compute gradient from attribute and therefore it relies only on neighbour points order which of course will change direction where relative point order is different

I will upload the file when I get home as I can't do it from work

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...