OpenVDB remesh

Hi.
Then I must be doing something wrong, or I have not understood your explanation. Should the addon work with default cube with triangulated faces?

I get this error:

Traceback (most recent call last):
  File "/home/yafu/.config/blender/2.79/scripts/addons/vdb_remesh.py", line 165, in execute
    self.adaptivity, self.only_quads, self.voxel_size, self.blur)
  File "/home/yafu/.config/blender/2.79/scripts/addons/vdb_remesh.py", line 72, in vdb_remesh
    grid = vdb.FloatGrid.createLevelSetFromPolygons(verts, tris=tris, transform=vtransform)
Boost.Python.ArgumentError: Python argument types in
    FloatGrid.createLevelSetFromPolygons(numpy.ndarray)
did not match C++ signature:
    createLevelSetFromPolygons(boost::python::api::object points, boost::python::api::object triangles=None, boost::python::api::object quads=None, boost::python::api::object transform=None, boost::python::api::object halfWidth=3.0)

location: <unknown location>:-1

The same with dyntopo meshes.

Addon works with default cube.

Edit:
Ok, I’m stupid :slight_smile: . I have missed “Pure triangle mesh” part you said. So now I’m trying to figure out what exactly “make faces” is, to see if I can make the addon work with dyntopo meshes

@YAFU: Alt-J, tris to quads. The mesh needs to have some tris and some quads and no ngons. It’s just a quality of life issue once I get to it it should be easy to fix.

@ambi . Oh, ok, I can see. Thank you.

@brothermechanic, your link give a message as Invalid Attachment.

Don’t worry
This is image


How about native system openvdb with numpy support?

@brother: You don’t have to use the included PyOpenVDB binary if you don’t want to (delete pyopenvdb.so in the modules folder). You just need to have a version of PyOpenVDB that has all the functionality the addon uses and one that is compiled with Numpy support turned on. It also needs to be somewhere Python can find it.

UPDATE: Added project to surface option to project the remeshed object back to the original surface. Bugfix: All meshes should be now remeshable (including those with ngons).

This looks sooo amazeballs, great to see someone work on this, well done ambi!
Looking forward to see how far you can take this!

I’m trying to make it on Os X, and it’s really bloody. I’ve thought using brew would give advantages, but I’ll get back to compile everything on place. That accounts for boost, boost_python, and so on directly from source…
By the way, Blender can be built with openvdb support if you enable the cmake option while you build from source; but it doesn’t have boost-python…
About numpy: what version you used, exactly? I’m not sure if use the one who is in Blender or else…
I have to check the docs again.

@kabu: On Linux I just focused on building OpenVDB and PyOpenVDB first using the system provided libraries for Python 3. When the pyopenvdb.so was built I went to that folder and ran Python 3 and typed “import pyopenvdb”. Once that started working, I simply copied the pyopenvdb.so to the Blender addon folder. Also on Windows I’m not using any of the Blender libraries, as they are not really compiled with right flags and have some things missing.

It seems to work!

Really I do not know how to compare addon vs modifier speed. Also I guess that Modifier has the advantage to be written in C and be better integrated with blender. But in case using OpenVDB for this have many advantages, How complicated would it be to use this for a new modifier and write this in C for Blender?

UPDATE: Got it working on Windows 64-bit. Instructions on Gumroad. Also price change as it required a lot of hard work to get it working. I’ll fix all the minor things later. I need some rest right now. :spin:

Here’s 10 codes for the quick: https://gumroad.com/l/jqLNZ/blenderartists

The .py is also up at https://github.com/amb/blender-scripts/blob/master/vdb_remesh.py

@YAFU: It’s wouldn’t be that much faster as most of the processing is inside OpenVDB and the data is transferred through Numpy arrays.

edit: There’s currently a bug that you need to apply transform (rotation, translation, etc) for the project to surface feature work properly. I’ll fix it tomorrow.


Works fine on Win7 64-bit Pro, 2.79, nice work! Are UVs preserved after remeshing?

@polygonsoul: Thanks! That’s definitely an interesting idea but no, UVs are not preserved at the moment.

I would think that you are familiar with this Houdini sneak peek https://vimeo.com/239828144,
just in case not, around 01:50 min they show their polygon reduction tool with UV conservation,
pretty neat as the all the other tools they show.

UPDATE: Fixed missing transform bug and added relative (to the object bounding box) voxel size.

@polygonsoul: Yeah that’s more of a decimate, not a full rebuild of topology. Still pretty cool.

Ah ok, did not know that these are technically different things, thanks for info!

Still no luck on Os X. This is by far one of the toughest build I’ve ever did (and I did a lot of them).
I’ll try again next week…

@kabu: Yeah, on Windows I pretty much compiled everything from source (except Python) using cmake. Dependencies -> OpenVDB shared libs -> OpenVDB Python module -> PyOpenVDB with Numpy 1.13, in order of milestones. A lot of tweaking configuration files and source code to get it running. Boost 1.66, c-blosc-1.14.3, glew-2.1.0, ilmbase-2.2.1, openexr-2.2.1, tbb2017, zlib-1.2.11.

On Linux it was 100x easier. Just configure it to run Python module with Numpy and make -j8.

:yes: Thank you for the windows stuff. Confirmed working on Windows 7sp1 with Blender 2.79b.
Would it be possible to make it animatable?

Win version works fine on my Win7 x64 sp1 and blender 2.79

And a little road test


Now I just wonder how the result could be if that addon turn into a modifier which you left at bottom of booleans list…