Sample the mask of a heightfield in Attribute Wrangle

   1112   7   2
User Avatar
Member
4 posts
Joined: Aug. 2023
Offline
Hello, I'm trying to use the volumesample VEX function to sample the mask volume of a heightfield in a Attribute Wrangle node. This works for every other volume but it simply cannot sample the mask. What is the reason for this, and how can I do it?

Edit: I had erroneously written Volume Wrangle node, instead of Attribute Wrangle
Edited by ptzdan - Sept. 18, 2023 11:15:22
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
ptzdan
Hello, I'm trying to use the volumesample VEX function to sample the mask volume of a heightfield in a Volume Wrangle node. This works for every other volume but it simply cannot sample the mask. What is the reason for this, and how can I do it?

could you post a simple example showcasing the issue?
User Avatar
Member
4515 posts
Joined: Feb. 2012
Online
ptzdan
Hello, I'm trying to use the volumesample VEX function to sample the mask volume of a heightfield in a Volume Wrangle node. This works for every other volume but it simply cannot sample the mask. What is the reason for this, and how can I do it?

Are you using the "mask" volume name?
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
4 posts
Joined: Aug. 2023
Offline
animatrix_
ptzdan
Hello, I'm trying to use the volumesample VEX function to sample the mask volume of a heightfield in a Volume Wrangle node. This works for every other volume but it simply cannot sample the mask. What is the reason for this, and how can I do it?

Are you using the "mask" volume name?

Yes. I just have an Attribute Wrangle node with the first input being a grid and the second being the volume whose mask I want to sample. The VEX code in the node is:

float mask = volumesample(1, 'mask', @P);

@Cd = lerp(@Cd, {1., 0., 0.}, mask);

For any other volume name is works, but for the mask it always returns 0.
I create the mask with a Heightfield Draw Mask node.
User Avatar
Member
4515 posts
Joined: Feb. 2012
Online
Are you sampling the displaced grid or the flat grid? If you are using the displaced grid, you have to make sure you are sampling the correct height:

vector p = set ( @P.x, 0, @P.z );
float mask = volumesample ( 1, "mask", p );

@Cd = lerp ( 1, set ( 1, 0, 0 ), mask );

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
4 posts
Joined: Aug. 2023
Offline
Thank you. This solved the issue. It still seems to me a bit weird how for any other volume primitive this wasn't problematic. Wrapping seems to be handled specially for the mask
User Avatar
Member
4515 posts
Joined: Feb. 2012
Online
ptzdan
Thank you. This solved the issue. It still seems to me a bit weird how for any other volume primitive this wasn't problematic. Wrapping seems to be handled specially for the mask

This is due to the border type of the mask field. If you set it to Streak just like the height field, you should get the same result, even without setting @P.y to 0:

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
4 posts
Joined: Aug. 2023
Offline
I had imagined that it had something to do with some intrinsic but when I looked for it I failed to find it. Thanks again for clearing that up
  • Quick Links