Jump to content
Sign in to follow this  
magneto

How to read/write attributes in Volume Wrangle?

Recommended Posts

Hi,

Is there a way to read/write attributes in Volume Wrangle? For example if your volume primitive had a count attribute? Or if you want to get the name of the currently processed volume and store it?

It feels a little like a black box.

Also when you don't bind every volume to density and change each volume, is it the same as using Bind Each Volume to Density in terms of performance?

I just don't know if doing this:

  1. @density = 1;
  2. @heat = 1;
  3. @temp = 1;
  4. ...

is the same as (when Bind Each Volume to Density):

  1. @density = 1;

Because if it was in Attribute Wrangle, it would be different as the first method would be run for each element.

 

Thanks :)

Share this post


Link to post
Share on other sites

VolumeWrangle is just HDA with Volume VOP inside.

To my quick test with VolumeVOP (4xfloat VDB, bind/bind export node and multiplied by AA noise), Bind Each Volume to Density is slower then Autobind by Name.

Try to think about volumes as different type of primitives. Name is just another primitive's attribute.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks pezetko. If I do something like this in a Volume Wrangle, I don't see any new attribute though.

For example I have a prim attribute called count with a value of 5 for everyone:

  1. i@mycount = i@count;

I don't get a new attribute on the volumes. I just wanna see if I am able to access i@count properly which also doesn't seem to be the case.

 

Share this post


Link to post
Share on other sites
On 5/30/2016 at 7:08 AM, Skybar said:

If you want an attribute on the primitives, use the Primitive Wrangle?

I can't because I need to modify voxel values.

Share this post


Link to post
Share on other sites

if you need to get/set primitive attributes from Volume Wrangle, use prim(), addprimattribute() and setprimattribute() functions, since binding in Volume Wrangle binds to volume data not primitive attributes

Share this post


Link to post
Share on other sites

Thanks anim. What do you use for the @primnum? Do you get the @primnum from the volume name, which might actually have a duplicate?

Share this post


Link to post
Share on other sites

there is no @primnum or @ptnum as Volume Wrangle doesn't iterate over volume primitives in the same way as in Attrib Wrangle, what are you trying to do?

 

Share this post


Link to post
Share on other sites

I just want to modify volumes using prim attributes. For example divide voxel values by a value stored in a prim attribute on that volume.

But doing this for multiple volumes that each have their own prim attributes.

Share this post


Link to post
Share on other sites

not sure how you can do it in just Volume Wrangle/VOP for arbitrary number of input volumes

maybe use ForEach to loop over volume primitives, then you can always get attribute from primitive 0, bind to density and alter it, you would need to make sure all volumes are just float volumes

 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks anim, I understand. That's the problem with volumes, they could be floats but also VDB vec3s, but overall I will use your ForEach idea.

Share this post


Link to post
Share on other sites

well, I said that mostly for simplicity as you can always have just float volumes even to represent vector or matrix fields

but of course you can make it to work with mix of vec3, float vdbs and houdini volumes

then in foreach just switch between Volume Wrangle/VOP bound to vector field and Volume Wrangle/VOP bound to float field based on type of the volume 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks anim that would be a good technique but if you want to cover all types of volumes, I imagine you will have to have a dozen volume vop/wrangles, right? int32, int64, bool, matrix volumes etc?

Share this post


Link to post
Share on other sites

well, not really

all houdini volumes are composed of float volumes, no matter what data type they represent

and most used VDBs are either float or vec3 (personally I have never used int or bool, but they would probably both bind as int, so in the end you would end up switching max 3 types)

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×