Page MenuHome

Geometry Nodes: Add Volume to Mesh Node
ClosedPublic

Authored by Jacques Lucke (JacquesLucke) on Jan 28 2021, 11:59 PM.

Details

Summary

Implement a volume to mesh node based on T84605.

Contrary to the Volume to Mesh modifier, this node does not have a smooth shading option. This should probably be handled by a separate node.

The actual volume-to-mesh code is shared with the corresponding modifier. To make that possible I extracted the code into a new file in blenkernel.

As of right now, the node can only work with volumes generated by the Points to Volume node. This limitation will be lifted soonish. This is related to T85159.

Diff Detail

Repository
rB Blender
Branch
volume-to-mesh (branched from master)
Build Status
Buildable 12625
Build 12625: arc lint + arc unit

Event Timeline

Tagging to Geometry Nodes so it shows in the project dashboard.

I haven't looked into the code in more depth yet, but it seems like the node could easily share code with the modifier.

@Sebastian Parborg (zeddb) how did you test this?

I plugged a simple volume object (made from a mesh) but I get nothing:

I haven't looked into the code in more depth yet, but it seems like the node could easily share code with the modifier.

I do agree that we should try to share as much code as possible.
However I did it this way as there are a few smaller differences that could lead to messy code if we try to just quickly separate out the code into a generic function.
The code is basically copy pasted with a modifications to make it work with the node API.

So my plan of attack was:

  1. Write the node code
  2. Get feedback that it works as we want
  3. Refactor the node and modifier to use the same "volume -> mesh" boilerplate code.
  4. Commit to master

That sounds ok :)

I wonder if I should take over this patch since you might be working on different projects now?

That sounds ok :)

I wonder if I should take over this patch since you might be working on different projects now?

Please do if you have time! :)

@Sebastian Parborg (zeddb) how did you test this?

I plugged a simple volume object (made from a mesh) but I get nothing:

You are using the object info node. This means that the object is instanced. We can't read any geometry data from instanced objects yet. That is why it is not working.
To try it out, use the "point to volume" node and plug that into this node.

  • code from Parborg
  • refactor
  • Merge branch 'master' into volume-to-mesh
  • fix
  • fix compiling without openvdb
  • change namespace
Jacques Lucke (JacquesLucke) edited the summary of this revision. (Show Details)
  • add grid name input
  • better align mesh with volume
Jacques Lucke (JacquesLucke) edited the summary of this revision. (Show Details)

The code makes sense as far as I can tell, and it works as advertised in my tests. Two comments:

  • We can't change the whether or not the mesh uses smooth shading here. That's too bad, but just highlights that we're going to have to properly deal with that at some point.
  • Maybe this is a good candidate for going in two categories in the add menu? If we follow the logic that the points to volume is in the volume category, the volume to mesh would be in the mesh category.
source/blender/blenkernel/intern/volume_to_mesh.cc
57

else after return

source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc
128–130

To be consistent, both the init and the update functions could move to the top.

141–143

Shouldn't this be in the init function?

We can't change the whether or not the mesh uses smooth shading here.

We could do it in this node. I was just saying that this should not be this nodes responsibility. Also, it is not important for our use case. Besides that, yeah, we have to figure out how to do it in a separate node.

If we follow the logic that the points to volume is in the volume category, the volume to mesh would be in the mesh category.

I see your point, but I don't necessarily agree (although I don't have a strong opinion on that). Currently I think that nodes that are somewhat related to volumes should be in the Volume submenu. That is where I would look. Obviously, putting it in the mesh category or some conversion category would also make sense. This is one node (among many others) that just don't fit into a single category..

We could do it in this node. I was just saying that this should not be this nodes responsibility. Also, it is not important for our use case. Besides that, yeah, we have to figure out how to do it in a separate node.

Agh, another case of not properly reading the patch description. I agree, a smooth shading option in the node is not a proper solution anyway.

I see your point, but I don't necessarily agree (although I don't have a strong opinion on that). Currently I think that nodes that are somewhat related to volumes should be in the Volume submenu. That is where I would look. Obviously, putting it in the mesh category or some conversion category would also make sense. This is one node (among many others) that just don't fit into a single category..

I don't have strong feelings about it either. It's easy to adjust later anyway.

Simon Thommes (simonthommes) requested changes to this revision.Feb 3 2021, 7:34 PM

Mostly looking great! I have some remarks.

  • Small thing: As I understand it, the adaptivity is capped at 100%, then so should the input field be
  • I noticed some issue with the adaptivity parameter that there is a problem with the interpolation. It seems to be dependent on the normal of the surface. Looks like there are issues along x=y=z, even though that should technically be an isotropic problem.

But then, the modifier seems to have the same issue and there the effect is even stronger.
Looks to me like it is something fixable, as for full adaptivity it works perfectly fine.

Example file with both geo-nodes and modifier:

This revision now requires changes to proceed.Feb 3 2021, 7:34 PM
  • slider for adaptivity input (note that you might have to recreate the node for this change to take effect)

Unfortunately, I don't know what is wrong with the adaptivity input. I just forward it to the openvdb mesh-to-volume implementation...

Thank you for the adjustment!

So, if I understand correctly, that means fixing the behaviour of the adaptivity is out of our scope? Or should we create a task to investigate?

In any way it shouldn't be part of this patch, so I'd consider this done.

This revision is now accepted and ready to land.Feb 4 2021, 3:16 PM
  • reorder functions and fix
source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc
141–143

oh, yes