How does volume sample work?

   2277   3   1
User Avatar
Member
433 posts
Joined: April 2018
Offline
I'm trying to get a density ramp on a volume and I'm having trouble understanding how volume sample works. I assume that it returns -1 to 0 when it's inside the volume and 0 to 1 outside. Somehow I'm not able to drive the density with the output. It just seems to affect a tiny portion of the edge and a giant chunk of the inside. What am I doing wrong? (I also tried a switch to only send a value to density when volume sample is between -1 and 0, plus a fit to switch it to 0 to 1 so that it's a usable density value, but still no luck.) See attached HIP file. Thank you!
Edited by BrianHanke - Dec. 16, 2020 09:57:45

Attachments:
density.hiplc (199.8 KB)

Subscribe to my Patreon for the best CG tips, tricks and tutorials! https://patreon.com/bhgc [patreon.com]

Twitter: https://twitter.com/brianhanke [twitter.com]
Behance: https://www.behance.net/brianhanke/projects [www.behance.net]
User Avatar
Member
4532 posts
Joined: Feb. 2012
Offline
Hi,

I assume you are using the @density directly in the chramp function, which would cycle the density value over 1 back to the beginning, i.e. keep only the fractional part over 1.0.

If you fit your density first, it will make sure to clamp them properly to 0-1 range:

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
433 posts
Joined: April 2018
Offline
animatrix_
If you fit your density first, it will make sure to clamp them properly to 0-1 range:

Thanks for the reply. I added the VEX you suggested and I'm still getting control only over the very edge of the sphere. I tried a few different inputs and ramp settings, as well as tweaking the VOP, but still no luck. I'm just having trouble visualizing what exactly volume sample is outputting. Is there a way to check on it? Geometry spreadsheet doesn't show the density values for each voxel.

Attachments:
density.png (515.4 KB)

Subscribe to my Patreon for the best CG tips, tricks and tutorials! https://patreon.com/bhgc [patreon.com]

Twitter: https://twitter.com/brianhanke [twitter.com]
Behance: https://www.behance.net/brianhanke/projects [www.behance.net]
User Avatar
Member
433 posts
Joined: April 2018
Offline
Update! I switched out the cloud for a VDB from polygons. Same result, but then I checked "fill interior" and suddenly it's working. I have no idea what's going on.

Edited by BrianHanke - Dec. 16, 2020 11:27:43

Attachments:
density2.png (639.7 KB)

Subscribe to my Patreon for the best CG tips, tricks and tutorials! https://patreon.com/bhgc [patreon.com]

Twitter: https://twitter.com/brianhanke [twitter.com]
Behance: https://www.behance.net/brianhanke/projects [www.behance.net]
  • Quick Links