Best practices for getting point attribute extrema

   1466   3   1
User Avatar
Member
134 posts
Joined: 9月 2021
オフライン
Hi!

I often find myself using an attribute promote (point to detail) to get the max, min, or average of point attributes:


Is there a way that this can be done in Vex so that I don't have to put an attribute promote node between two attribute wrangle nodes if I want to subsequently operate using the extrema of the point attributes?

Thanks!
Anson

Attachments:
2023-05-03_14-18.png (57.0 KB)

User Avatar
Member
545 posts
Joined: 11月 2016
オフライン
There's a way to iterate over your points in vex, something like:


float minvalue = point(0, attribute, pt);
float maxvalue = point(0, attribute, pt);

for(int pt=0; pt < i@numpt; pt++){
    float value = point(0, attribute, pt);
    
    if(value < minvalue){
        minvalue = value;
        }
        else{
            if(value > maxvalue){
                maxvalue = value;
                }
            }
    } 

...but using Attribute Promote is faster.

If you're already setting the values for the attribute in the wrangle, you should be able to also manually set rough max and min values, but if you need the exact ones, I always use Attribute Promote and two wrangles.
Edited by Tanto - 2023年5月3日 16:49:56
User Avatar
Member
9417 posts
Joined: 7月 2007
オフライン
here is the whole thread about that discussed in depth
https://www.sidefx.com/forum/topic/37816/?page=1 [www.sidefx.com]

but ultimately Attribute Promote is probably the way to go
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
5128 posts
Joined: 2月 2012
オンライン
Attribute Promote SOP is the fastest method currently.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
  • Quick Links