Best practices for getting point attribute extrema

   804   3   1
User Avatar
Member
129 posts
Joined: 9月 2021
Offline
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
388 posts
Joined: 11月 2016
Online
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
8545 posts
Joined: 7月 2007
Offline
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
FX Supervisor
Method Studios, NY
User Avatar
Member
4512 posts
Joined: 2月 2012
Offline
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]

youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
  • Quick Links