Density gradient between two surfaces

   2373   5   2
User Avatar
Member
4 posts
Joined: Dec. 2018
Offline
Hello, I would like to create a density gradient inside a VDB (object in first image). I need the density values to be one along the bottom surface and transition smoothly into density values of zero along the top surface (see second image).

I have tried to mix together VDBs with different types of densities to achieve this effect but the gradient doesn't adhere to the curvature of the surfaces (see thrid image).

How do I blend the density smoothly and consistently between the two surfaces?

Example files would be helpful as I am still learning Houdini, thank you.

Attachments:
Density_Gradient_1.jpg (370.9 KB)
Density_Gradient_2.jpg (121.4 KB)
Density_Gradient_3.jpg (135.2 KB)
Density_Gradient.hip (539.8 KB)

User Avatar
Member
143 posts
Joined: Oct. 2015
Offline
Hello
Maybe with something like this ?
Made a custom Volume Vop to try to match what you're after…
getting the normal from near bottom point then sending some ray in N dir to top and bottom
then output to density the distance to top divided by distance to top plus distance to bottom

Attachments:
Density_Gradient.hiplc (617.6 KB)
Clipboard01.jpg (154.1 KB)

User Avatar
Member
4 posts
Joined: Dec. 2018
Offline
Hi Benjamin, thanks for getting back to me and including an example file. Your method works well and produces a much better result than my original attempt.

Perhaps I drew the arrows incorrectly in the original diagram. I think the VOP needs to use the normals from the top surface as well as the bottom surface. I have been through your file and made some adjustments in an attempt to get it looking closer to the gradient seen in the diagram. It's nearly there (not sure if this is the best way) but now I need to get rid of the white lines running vertically through the centre. I think this might be caused by the way the near point node is finding the closest points on the top surface where there is steep curvature.

Do you have any suggestions on how I could fix this please?

Attachments:
Density_Gradient_V2.hiplc (617.3 KB)
Density_Gradient_4.jpg (133.2 KB)
Density_Gradient_5.jpg (100.8 KB)
Density_Gradient_6.jpg (111.6 KB)

User Avatar
Member
143 posts
Joined: Oct. 2015
Offline
Hello
You could use normal from the top surface too with the dame setup and compute one of the distance with it. but anyway this is a craft setup , cause the ray I'm sending won't be in the direction you want…it would mean do the opposite…from a point getting to know which point normal is passing trough then compute the distance… I'm not so good at math thinking but there must be a way !
I have no time to dig further.
But i will be happy to know if you find something…
Cheer

Benjamin
User Avatar
Member
143 posts
Joined: Oct. 2015
Offline
Hello again
I'm not at home but i just had an idea….
With volume sample and volume gradient you would get some direction and distance to the next surface , the problem would be to get the distance to the opposite surface, you could maybe negate the volume gradient vector…. But it will be more or less the same but with a better direction though…

Good work !
Benjamin
User Avatar
Member
4 posts
Joined: Dec. 2018
Offline
Thanks for your suggestions. I think my second attempt is similar to one of your ideas as I managed to integrate the normals from the top and bottom surface, it's just not blending as smooth as I would like. I'll keep working it, thanks for your help!
  • Quick Links