so far I understand the average node computes an average of multiple inputs. every point with the input. what I need is the average of all points.
general speaking, how one would work on the whole set of components?
vop sop: getting the average of all points
25581 13 3- sekow
- Member
- 238 posts
- Joined: 11月 2013
- Offline
- animatrix_
- Member
- 4731 posts
- Joined: 2月 2012
- Offline
At the VOP level, you would have to loop yourself, and make sure to set Run Over to Detail mode.
Or easier to do it in VEX:
vector computeCenter ( )
{
int count = npoints ( 0 );
vector center = 0;
for ( int i = 0; i < count; ++i )
{
vector p = point ( 0, “P”, i );
center += p;
}
return center / count;
}
These will not be very fast though.
A better way IMO is to use Set Attribute VOP or setattrib function to add a detail attribute value (Merge Mode: Add).
Then using another SOP you would have to divide this value.
Or easier to do it in VEX:
vector computeCenter ( )
{
int count = npoints ( 0 );
vector center = 0;
for ( int i = 0; i < count; ++i )
{
vector p = point ( 0, “P”, i );
center += p;
}
return center / count;
}
These will not be very fast though.
A better way IMO is to use Set Attribute VOP or setattrib function to add a detail attribute value (Merge Mode: Add).
Then using another SOP you would have to divide this value.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
- takita
- Member
- 207 posts
- Joined:
- Offline
One thing I do kind of miss coming from ICE (having not found an equivalent in VEX) are the Statistics nodes (min/max/average/sum/product).
The AttribPromote Sop will easily compute the average of the entire point set if you promote the Point attribute to a Detail attribute, but design-wise it requires that you break your graph in to sections if you ever need to compute the average of the entire point-set in what would be the middle of a graph.
-T
The AttribPromote Sop will easily compute the average of the entire point set if you promote the Point attribute to a Detail attribute, but design-wise it requires that you break your graph in to sections if you ever need to compute the average of the entire point-set in what would be the middle of a graph.
-T
- sekow
- Member
- 238 posts
- Joined: 11月 2013
- Offline
- grayOlorin
- Member
- 1799 posts
- Joined: 10月 2010
- Offline
dependnig on what you are trying to do, it may be also useful to use the point cloud vop nodes.
http://www.sidefx.com/docs/houdini13.0/nodes/vop/pcopen [sidefx.com]
the advantage on these is that they are really fast if you only are looking for weighted average data withing a radius.
http://www.sidefx.com/docs/houdini13.0/nodes/vop/pcopen [sidefx.com]
the advantage on these is that they are really fast if you only are looking for weighted average data withing a radius.
-G
- sekow
- Member
- 238 posts
- Joined: 11月 2013
- Offline
grayOlorin
dependnig on what you are trying to do, it may be also useful to use the point cloud vop nodes.
http://www.sidefx.com/docs/houdini13.0/nodes/vop/pcopen [sidefx.com]
the advantage on these is that they are really fast if you only are looking for weighted average data withing a radius.
I'll check that one out, but it feels a bit to much for what I am trying to do.
I just want to add up all Positions and divide them by there ptnum.
In ICE you are able to work on the whole point set of an object.
So one can average (sum, min, max…) the whole point position set.
In vops yo are limited to just individual points, so it seems. Please correct me if I am wrong.
- grayOlorin
- Member
- 1799 posts
- Joined: 10月 2010
- Offline
Yes, but it is that way foe an important reason, the vex/vop contexts run in a highly multithreaded single instruction multiple data (simd) archittexture, which is why is so fast. Its a very important advantage as it allows for processing of massive data (ie scan data) in a fraction of time
Fir doing operations on all points against each other (ie statistics), I feel in most cases regular operators (sops, pops, etc ) are better. You can also extend quite a bit with python nodes which even allow you to use snippets of inline cpp code (see inlinecpp module) numpy us also available with hou
For average of all points , you can also add a vector detail attribute and set each axis to this expression:
Centroid(“../youroperator”, D_X)
Centroid(“../youroperator”, D_Y)
Centroid(“../youroperator”, D_Z)
For things like sum, attribVOP is the way to go (since you can simd that). Check out the setAttribute VOP
For weighted averages or thongs of the sort, point cloud VOPs are awesome and fast
For other things , attribPromote and python operators (ie python snippets) are very easy
I guess the reason there is not a single node is that you would do each statistic operation in one way or another for speed and versatility but remember you can always make your own statistics digital asset for yourself (or share it in orbolt store). I have made my own l1 median it is important to remember that ICE == SOPS and VOPs, not just VOPS
Hopes this helps!
Centroid(
Fir doing operations on all points against each other (ie statistics), I feel in most cases regular operators (sops, pops, etc ) are better. You can also extend quite a bit with python nodes which even allow you to use snippets of inline cpp code (see inlinecpp module) numpy us also available with hou
For average of all points , you can also add a vector detail attribute and set each axis to this expression:
Centroid(“../youroperator”, D_X)
Centroid(“../youroperator”, D_Y)
Centroid(“../youroperator”, D_Z)
For things like sum, attribVOP is the way to go (since you can simd that). Check out the setAttribute VOP
For weighted averages or thongs of the sort, point cloud VOPs are awesome and fast
For other things , attribPromote and python operators (ie python snippets) are very easy
I guess the reason there is not a single node is that you would do each statistic operation in one way or another for speed and versatility but remember you can always make your own statistics digital asset for yourself (or share it in orbolt store). I have made my own l1 median it is important to remember that ICE == SOPS and VOPs, not just VOPS
Hopes this helps!
Centroid(
-G
- grayOlorin
- Member
- 1799 posts
- Joined: 10月 2010
- Offline
- sekow
- Member
- 238 posts
- Joined: 11月 2013
- Offline
- jason_iversen
- Member
- 12672 posts
- Joined: 7月 2005
- Offline
FYI, you can AttribPromote SOP to a detail attribute to do this simply.
Jason Iversen, Technology Supervisor & FX Pipeline/R+D Lead @ Weta FX
also, http://www.odforce.net [www.odforce.net]
also, http://www.odforce.net [www.odforce.net]
- symek
- Member
- 1390 posts
- Joined: 7月 2005
- Offline
In Vops, use Bounding Box Vop, to compute centroid (centroid = min+(max-min)/2). Neither that nor centroid() expression will give an average of positions though. They both are center of bounding box, which is not the same thing.
edit: there is pointavg() [sidefx.com] expression also.
edit: there is pointavg() [sidefx.com] expression also.
Edited by - 2014年4月27日 08:15:13
- sekow
- Member
- 238 posts
- Joined: 11月 2013
- Offline
- symek
- Member
- 1390 posts
- Joined: 7月 2005
- Offline
pusat
Or easier to do it in VEX:
vector computeCenter ( )
{
(…)
}
These will not be very fast though.
I would say this code has a good chance to have comparable performance with C++ node, but apparently not (it's ~x3.5 slower from AttributePromote in average mode, which is not bad, as it's still bellow a second for 5mil points, but still…).
Pure speculation here, but this is probably due to point()/import() functions which force atomic access to the attribute's array and per element compute (bye bye simd), unlike HDK which has these days very cache/simd friendly batch access to attributes. Looks like llvm/vex doesn't do its best here.
I think avg() on a big array of x, y, z's might be a way faster, but costs creating such an array doesn't make any sense. VEX functions like min(string attr)/max(string attr)/avg(string attr) would be helpful.
- animatrix_
- Member
- 4731 posts
- Joined: 2月 2012
- Offline
SYmek
I would say this code has a good chance to have comparable performance with C++ node, but apparently not (it's ~x3.5 slower from AttributePromote in average mode, which is not bad, as it's still bellow a second for 5mil points, but still…).
Pure speculation here, but this is probably due to point()/import() functions which force atomic access to the attribute's array and per element compute (bye bye simd), unlike HDK which has these days very cache/simd friendly batch access to attributes. Looks like llvm/vex doesn't do its best here.
I think avg() on a big array of x, y, z's might be a way faster, but costs creating such an array doesn't make any sense. VEX functions like min(string attr)/max(string attr)/avg(string attr) would be helpful.
This is actually a case even Python have comparable performance to VEX. From what SESI told me the point() vex function is written expecting to be able to amortize setup time across many procs, and a function like point_many that let you fetch a batch of points at once, returning the result in a VEX array would make it a lot faster.
So if we have point_many, prim_many functions in addition to min(vector array), max(vector array), avg(vector array), etc it would be extremely useful.
Please submit an RFE if you would like to see this
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
-
- Quick Links