Dynamic Topology Sculpting

Past couple months I’ve been working on implementing dynamic-topology sculpting for Blender. The implementation is based off the paper Freestyle: Sculpting meshes with self-adaptive topology by Lucian Stãnculescua, Raphaëlle Chainea, and Marie-Paule Canic. It’s getting stable enough to where people might find it fun to play with, so I thought I’d talk a bit about the tool and its current status.

High-level Overview

The dynamic topology tool allows sculpt mode to change the topology of the mesh as you sculpt. It operates on triangles, so you have to convert quads to triangles before using it. The mesh is updated as you sculpt (during the stroke, not just at the end of a stroke.) The tool places restrictions on the lengths of triangle edges to ensure that the topology stays “nice” for sculpting (no long skinny triangles.) The triangle density is constant across the mesh; there’s no way currently to make the tool give more triangles in a particular area.

The paper uses three basic operations to update the mesh: collapsing long edges, subdividing short edges, and merging close vertices. All three of these operations are implemented, but vertex-merge is currently disabled, as it’s too crashy to use right now. These operations require adjacency data that is not normally present in Blender’s mesh representation. The paper recommends storing the three triangles adjacent to each triangle, as well as a single adjacent face for each vertex. This is enough to quickly calculate the 1-ring for vertices as needed. To make adding and removing vertices/faces easy, they’re stored in linked lists rather than the usual mesh arrays.

Implementation Notes

Most of the code lives in blenlib/dyntopo.c and blenlib/pbvh.c.

The linked-list representation is a bit similar to EditMesh, but smaller, simpler, and easier to integrate with the PBVH. The PBVH is the spatial data structure used in sculpt mode for making fast searches for which vertices to update and partial redraw. Ordinarily the PBVH contains arrays of mesh-element indices; these arrays are built just once when you enter sculpt mode. For dynamic topology sculpt, list bases for the vertices and faces were added to the PBVH nodes. At the end of each stroke, any modified nodes are checked to see if the number of faces they contain has grown too large, and if so they are split. (Empty nodes should also be collapsed, but I haven’t gotten around to that yet.)

Only CMake build system has been updated, but you could easily update scons too if you prefer that.

Usage is pretty simple: create a mesh, convert to all-triangles, enter sculpt mode, and click the “Dynamic Topology” button. Note that only the “simple” brushes work right now. Fancy things like smooth and grab will crash. Sculpting on a non-dynamic topology mesh will crash. Undo is disabled. Lots of other things I’ve forgotten about will also probably crash. Have fun!

40 comments

Wait wait… Why is this so great-looking and Unlimited Clay so abandoned? What’s the relation between the two? The ability to punch holes through the mesh like in the video is so far ahead of both UC and Sculptris.

I know UC was on hold due to Bmesh/performance issues, but then this shows up and it looks really good! Great work indeed, almost too good to believe Does dynamic Topology Sculpting suffer from the same performance issues? Does Bmesh integration affect this at all? Assuming both UC and Dynamic Topology Sculpting are complete, will they have to be unified into a single tool/option? So many questions!

This code is independent of unlimited clay. I don’t know if Farsthary plans on continuing that project for Blender or not. (Note that this project is not any more or less “official” than unlimited clay.)

This project is also quite independent of BMesh. As noted in the post, it uses its own internal representation that is not dependent on EditMesh (and EditMesh will be replaced by BMesh.)

Last message from Raul (Farsthary) to the developer list: “the patch is more like spagetty code and for internal development, I use all of those hacks in order to get a working system first, and only
then start reworking/redisigning into a readable form.”

We are still very eager to get things work, but first step would be a developer proposing it to be more or less ready for review and integration.

Hi Nicholas! Great, excellent news, I just saw this post after sending you a message to blender dev mailing list, I think you are very close to get what UC was initially intended for, so I will be more than honored if I can point you out few advices to help you save some time since I have face the same issues you are facing now

You rock Nico! Thank you for making this possible in Blender and not waiting for Farsthary’s implementation- it has been more than half a year and he has not released any code . Honestly it looks like he is
1.Putting most of his time where he gets paid- the unlimited clay implementation in 3d COAT
2.waiting for B-mesh to hit stable

I dont see a reason for anyone to be unhappy with this beautiful work here. Two implementations of unlimited clay are better than one. Even more so- this is a combination of the work of three people,rather than one- its better documented and open than Farsthary’s attempt.

That said, I cant wait to see the farsthary unlimited clay modifier in Bmesh, if its ever out. The last thing missing now for me is having the skin modifier and this in one build- up at graphical.

Imagine using the skin modifier, combined with shrinkwrap for doing retopology on body

honestly, farsthary is doing an amazing job, see above his comment in this post Oct 18, 2011.
Talk about the motive why farsthary pause the UC, “Putting most of his time where he gets paid”, please… no need. is not of our business.
Lets support the developers, the efforts they make, giving positive comments, testing their work, sharing, giving “open” suggestions not ultimate them, giving material support by donating.
It’s not that simple like rub a hand in a lamp.
Positive support to Nicholas.(lets focus our attention in Nicholas)
Positive support to farsthary.(he has a blog where can talk about UC)
Positive support to all developers.

I have been playing with the windows build all morining and have to say I’m thrilled with it! From out of the blue, a great sculpting tool that is pretty useable already. When the kinks are ironed out, it will be a mighty asset to recommend Blender. I have updated my zbrush but for all its fanfare, this excites me more.

Not to be negative. But I’ve seen a lot of amazing tools developed/tested (ptex, skin modifier, remesh, etc.) and never make it into trunk. Most of us can’t use branches other then for a quick play and test. Will this tool make it into trunk or is it another fun experiment that will never see the light of day?

All complaining aside this looks like an excellent tool and would definitely be a useful.

Looks good!
Nicholas, you’ve lately been working on some truly amazing projects: Ptex, Remesh and the Skin modifier. All of these have amazing potential, but seem to be half finished. I hope you can find a way to finish these up.

Blender development seems to cause a large number of fantastic work uncommitted and abandoned. I hope that doesn’t happen to things like the Skin modifier.

Hello! First of all, I would like to say thanks to Jonathan for this awoseme, much needed tutorial, I have been looking for something like this for years. That and the fact that blender is way easier to navigate than I expected, have helped me, in days, realize a project I was holding back for a long time. Secondly, I do have a little situation I could use some help with: when I produced the spheres for the eyeballs, it sort of did it in a way that the program sees all meshes as one (the body and the eyeballs). This posses a little problem for selecting parts that overlap each other. I have come as far as this video goes and I have been able to navigate around it, but I fear this may pose a problem in the future, maybe because I shouldn’t have done it this way in the first place. Can I separate and make it into another object, or something? All the advice is appreciated in advance. Thanks again and I wish much success to J. W. and all of us aspiring artist.

Whats going on here in blender, you see many new features such as this one and yet they are never released?.
I would love to see improvements to sculpting such as masking and layers which was both in Google summer code, but then abandon ship what gives ?.