Merge Scalar into vector volumes

   8832   11   1
User Avatar
Member
55 posts
Joined: Nov. 2015
Offline
Hi,
Is there a node similar to the VDB Vector merge tool that works on unifying 3 separate scalar volumes into a single named vector volume? I know that vector volumes are anyway considered 3 scalar volumes but I'm trying to optimize a Volume VOP node where I'm calling the samplevolume function 3 separate times(once for each scalar volume representing the vector) and I wonder if calling the function once referencing a vector volume(as in vel instead of vel.x .y .z) would be faster.


Regards,
Ihab
User Avatar
Member
4495 posts
Joined: Feb. 2012
Offline
You can use the volumesamplev VEX function.
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
User Avatar
Member
55 posts
Joined: Nov. 2015
Offline
Thanks pusat

My problem is I have 3 scalar volumes and I'd like to use the function you states so I'd like to know how to convert standard Houdini volumes from scalars to vectors.
User Avatar
Member
4495 posts
Joined: Feb. 2012
Offline
The only way is VDB, but if it becomes a vector field as a whole you will still have to use volumesamplev.

If the fields are matching, .x, .y, .z, Houdini will sample them as a whole so you only have to call this function once.
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
User Avatar
Staff
2540 posts
Joined: July 2005
Offline
With Houdini volumes named with basename.x basename.y basename.z extensions to the name are treated as vectors and you should be able to fetch and work with basename.* in group fields and in VEX/VOPs using Bind VOPs using just the basename set to vector.

See the example file on how to use Bind VOP and Bind Export VOPs to bring in vector volumes and write to vector volumes.

Attachments:
volume_vop_vector_volumes.hip (252.3 KB)

There's at least one school like the old school!
User Avatar
Staff
2540 posts
Joined: July 2005
Offline
As well have a look at some of the HDA's that ship with Houdini that deal with Vector Volumes like the Fluid Source SOP. Dive in and see how vector volumes are dealt with inside of the Volume VOP context.
There's at least one school like the old school!
User Avatar
Member
55 posts
Joined: Nov. 2015
Offline
Thanks Jeff. My only issue is converting named scalar volumes to what you describe above(something that's treated as a single vector volume). So I have 3 volumes named R G and B and I want to be able to use the volumesamplev function inside my volume VOP instead of using 3 instances of the volumesample function in order to optimize the VOP execution time(the volumes here are in billions of voxels so they take a while to process through the VOP). I assumed that with volumesamplev instead of sampling each volume each time, the process would be some how done in parallel. Again my problem is my inputs are 3 separate standard scalar volumes(generated by a volume rasterize particles SOP)so I was looking for a way to combine them together before I go into the volume VOP.

As pusat mentioned, I can convert the volumes to a VDB, use volumesamplev then separate the components again(or in my case sample them as RGB in Arnold). I'm just wondering if there is a different way that doesn't involve the conversion step.

thanks for all your help!
User Avatar
Member
242 posts
Joined: Jan. 2008
Offline
Ihab Ali
Thanks Jeff. My only issue is converting named scalar volumes to what you describe above(something that's treated as a single vector volume). So I have 3 volumes named R G and B and I want to be able to use the volumesamplev function inside my volume VOP instead of using 3 instances of the volumesample function in order to optimize the VOP execution time(the volumes here are in billions of voxels so they take a while to process through the VOP). I assumed that with volumesamplev instead of sampling each volume each time, the process would be some how done in parallel. Again my problem is my inputs are 3 separate standard scalar volumes(generated by a volume rasterize particles SOP)so I was looking for a way to combine them together before I go into the volume VOP.

As pusat mentioned, I can convert the volumes to a VDB, use volumesamplev then separate the components again(or in my case sample them as RGB in Arnold). I'm just wondering if there is a different way that doesn't involve the conversion step.

thanks for all your help!

Just use a name SOP and rename the string volume attribute called name.
scalarVolR -> vectorVol.x
scalarVolG -> vectorVol.y
scalarVolB -> vectorVol.z
User Avatar
Member
55 posts
Joined: Nov. 2015
Offline
mawi, thanks so much I can't believe how stupid I was That did the trick!


however and unfortunately, running a volumesamplev vs 3 volumesample did not save any time.

I did try the VDB vector merge method and that seemed to improve the performance time of the VOP significantly(because the no value voxels are not processed). However it doesn't seem to be processing things correctly.

I'm essentially using the volume VOP to advect 3 color value volumes using the rest field from a pyro simulation. I'm not sure why, but it seems when I sample the value of the VDB based on the position stored in the rest volume it's not resizing the bounding box of the base VDB….it just seems to be moving voxel values outside the original VDB bounding box(a quick render in Arnold shows output that doesn't make sense anyway).
I'm basically sampling the VDB and reassigning the color value to the same VDB…is that possibly the cause of the strange output?




User Avatar
Member
55 posts
Joined: Nov. 2015
Offline
So apparently with VDBs, if the original voxels were not active then they cannot be processed through a volume VOP(at least that's what I understood from the VDB activate function). Is there a way to dynamically activate VDB voxels inside a VOP?
User Avatar
Staff
2540 posts
Joined: July 2005
Offline
No not that I am aware of to expand inside of VEX.

You can use the second input of the VDB Activate to activate a region of interest. If you can take your algorithm and simplify a version of it working on a greatly reduced LOD of the volume data with an upstream VOP network to identify areas where you want to do work, then activate on that, then do your heavy lifting later on with the regions that have been expanded carefully where you want to push and pull voxels.

That would be the most efficient. I believe that the Volume VOP processing VDB grids only works on active areas of the grid so you get that nice efficiencies over and above regular Houdini volumes.
There's at least one school like the old school!
User Avatar
Member
55 posts
Joined: Nov. 2015
Offline
thanks Jeff. So I kind of did that but for some reason after processing through the VOP both VDBs end up having the exact same number of active voxels. I checked the vex code and all it's doing is a simple assignment
:resultvdb=sourcevdb, for a particular test case at least yet sourcevdb ends up being fully active and therefore that vop is now taking longer to execute than with standard houdini volumes.

I'm essentially just trying to advect a volume represnting voxel color information(extracted from some base geo color) using pyro simulation's rest field(since I can't affect this custom volume directly in the pyro solver. So after the simulation, I'm sampling those color voxels using information from the rest field and essentially moving the colors to their new advected positions using a volume vop. Because the color volumes are very high density(in order for the volumes to render nicely) the vop is obviously taking forever to execute and I was just trying to get it to be more efficient.

I've attached the scene file, if anyone has a better way of doing this I would really appreciate any advice!

Edited by Eyecon - July 30, 2016 04:19:37

Attachments:
voulme take2.hipnc (597.5 KB)

  • Quick Links