Smarter Heightfield Mask Expand node

   1123   4   1
User Avatar
Member
10 posts
Joined: March 2018
Offline
Hi all,

I'm trying to create a smarter heigthfield mask expand node but I'm struggling to find a good solution.
What I basically want is a mask expand that also considers height distance instead of only 2d distance.
e.g. I expand a mask by 10 meters but I don't want it to creep up all the way on a steep slope.
The closest I got was clipping away the mask when its height was larger than a set maxheight. In this case it was the max height of the masked area which I managed to get by doing:
setdetailattrib(0,"minHeight", @height*@mask, "min");
setdetailattrib(0,"maxHeight", @height*@mask, "max");
This can be useful if my masked area is rougly around the same height level but becomes useless if there is elevation happening.

I think the main reason I'm stuck is that I'm more familiar working with points etc than heightfields or volumes. The built-in volume expand function is also a compiled node I can't open to read the code.

I thought this was going to be an easy function to add but Houdini proved me wrong!
Anyone have any ideas that might help me?
User Avatar
Member
28 posts
Joined: Nov. 2016
Offline
Take this with a grain of salt as this isn't expanding the mask by a given distance at all yet (and is currently also dependent on the voxelsize), but scales the expansion of the mask by the difference between adjacent height voxels and fits that between arbitrary values.
So the mask is basicly just growing slower up/down hill.


I guess this could be a starting point for your use case? Most of the code is taken from the opencl Masterclass from Jeff Lait [vimeo.com].
Expansion iterations would be handled by the opencl SOP iterations.

Attachments:
mask_expand.hipnc (184.5 KB)

User Avatar
Member
10 posts
Joined: March 2018
Offline
Thanks for the link and the example file @gorrod!
I was afraid openCL was going to be the answer here.. Guess it's time to get my feet wet with it
Thanks!
User Avatar
Member
4515 posts
Joined: Feb. 2012
Offline
FloreV
Thanks for the link and the example file @gorrod!
I was afraid openCL was going to be the answer here.. Guess it's time to get my feet wet with it
Thanks!

You can do this in VEX also. You are using detail attribute functions on a volume. If you want to do the equivalent operation on volumes, have a look at the 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 | animatrix2k7.gumroad.com
User Avatar
Member
10 posts
Joined: March 2018
Offline
After tinkering around a bit with your working file and watching that opencl masterclass I have a better understanding for what I can use OpenCL. So thanks for that @gorrod!
I realised the easiest way to achieve my goal is to write a height dilate node. Like you see with alpha textures where the edges bleed all the way to the edge of the image but with the height.
I tried doing this with opencl and it kind of works but it's very jittery and the result can look vastly different every iteration(the range of the dilate increases every iteration). If I blur the dilated area it should work for my intended purposes but I do wonder if I can make the dilation more consistent and cleaner. I basically just check neighbouring points to see if any of them are in the masked area, if so we copy their height in the current point and add the current point to the mask. They also have a checked parameter to see if they have already copied data or not.

If you look at the image below you see the height sometimes shoots up for no reason. The place where this happens changes every iteration.

If anyone has any more pointers, I would appreciate that!
Edited by FloreV - Oct. 1, 2022 07:39:39

Attachments:
Screenshot 2022-10-01 122822.png (1010.6 KB)

  • Quick Links