Sum of values in volume

   898   2   1
User Avatar
Member
11 posts
Joined: 2月 2018
Offline
Hi, I'm trying to sum the values of a layer in my volume. Currently I'm doing this with a detail wrangle and calling volumeindex for every cell. This is pretty slow and I was wondering if there was a better way? I have attached a sample .hip file.

float sum = 0.0;
for (int x = 0; x < gridSamples; x++)
{
    for (int y = 0; y < gridSamples; y++)
    {        
        float value = volumeindex(1, "value", set(x, y, 0));
        sum += value;            
    }    
}

Thanks!

Attachments:
sum_value_in_volume.hip (93.6 KB)

User Avatar
Member
4530 posts
Joined: 2月 2012
Offline
Hi use volume reduce sop.
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
User Avatar
Member
11 posts
Joined: 2月 2018
Offline
Exactly what I was looking for! Thanks!
  • Quick Links