Improvements for sculpt drawing

Example of multiple materials drawing correctly in sculpt mode (click to embiggen)

Recently I’ve been committing some improvements to the sculpt PBVH drawing code. None of these changes affect the fancier drawing modes — GLSL and all that is still not accelerated by the PBVH when sculpting. However, there are still some performance and feature improvements.

The most noticeable change is pictured at right: materials and shading mode (smooth/flat faces) are now drawn correctly in sculpt mode. Previously, the material and shading mode were set once for each PBVHNode (each of which typically contains thousands of polygons.) This is still the case, but now PBVHNodes are split until all the faces they contain (whether mesh or multires faces) all share the same material and shading mode.

Another recent change involves building VBOs for multires meshes. This is done by mapping a vertex buffer as write-only and copying multires grids (containing coordinate and normal data) into the buffer. There was a small bug in this code though: when sculpting on a flat-shaded model, the normals in the buffer were updated in a way that read¬†from the buffer before writing to it. This is an invalid operation for a write-only buffer, and while most drivers won’t crash if you do it, I found that on my particular drivers (Gallium/Radeon) it makes a huge difference in performance. (This was on the order of seconds for dense meshes.)

Finally, improvements have been made to use better normals for flat shading. The results should in general look quite close to non-sculpt normals, with the exception of non-multires with VBO.

9 thoughts on “Improvements for sculpt drawing”

  1. awesome, can you update your path again after these mods, as your sculpt 02 batch is broken, thanks.

  2. Thanks again for the patches nicholas. I finally got a chance to really sit down and play with the tools for a solid 4 hours or so. It is sooooo nice to be able to open/close a mouth without pulling the nose around!

    Workflow suggestions:
    1. Maybe it’s me flipping between Z and Blender that is messing with me, but it would be nice if we had a tool like the ‘shift smooth’ for masking. I keep trying to mask by just holding control down and of course it does not work. It feels slow having to jump over to ‘m’ mask, then switch brushes again. Maybe a keyhold on m that auto reverts back to the current brush you are using?

    2. You are right, clear mask needs a shortcut.
    3. Maybe I am missing something, but is there a way to move a sculpted part of the mesh to another spot? For instance, I sculpted an ear. It was perfect, then I realized it was way too far off the side of the head. I tried masking the ear, inverting, then moving the ear closer with the grab brush, but it completely distorts it while moving it. Do I just need to work with my brush falloffs more and zoom way out?

    4. Ok, now onto things really probably not related to your patch but since I’m on usability. Would be nice to have a way to jump between objects quickly. Doing the object mode->new object->sculpt mode jump is really slow.

    1. Hi,

      1. The keymap for mask is definitely still up for discussion. If you want, you should already be able to set up the keymaps to use ALT to temporarily toggle masking, just like smooth uses SHIFT. The reason I didn’t do this by default is the (in my opinion unfortunate) tendency for Linux DEs to use ALT as a window-management key, e.g. for moving or resizing windows.

      Also, not sure if you are aware or not, but the MKEY shortcut for the mask brush is a toggle; pressing it while the mask brush is already selected should return you to whatever brush you previously had selected.

      3. Yep, changing the brush falloff to a straight line at the top of the graph and using a big brush should allow you to move something with minimal distortion. This workflow could certainly be improved though. Now that we have masks, I wonder if we couldn’t implement standard G/S/R semantics, maybe even allow using the transform manipulator.

      4. Indeed some other modes allow this, e.g. weight paint. Not sure why we don’t allow for sculpt… might be you can fix this by adding a new RMB keymap for sculpt mode? You can also set up a key to toggle sculpt mode, just like VKEY does for vertex paint. Then at least it’s as simple as keypress, RMB select, same keypress.

      Thanks for the feedback :)

      1. I did not realize the ‘m’ toggle – thanks for that and the alt key idea – I do jump between linux and win, but I actually rebound the linux alt shortcut to the windows key, so I forget about that restriction.

        I really really really like the idea of having g/s/r type stuff in sculpt mode!

        Thanks for the other tips!

      2. So I’m getting some other weird stuff happening after some extended use. Hard to reproduce stuff, mostly with undo. Occasionally undo will just stop working. If you leave the sculpt mode and return it appears to come back, but you can’t undo what you initially wanted to before you left sculpt mode. Also, I occasionally ran into an issue where my undo just made my whole mesh disapear. I panicked and quickly hit redo to get the mesh back, but realized I could not do the undo I wanted for fear of losing the whole mesh. I know these will be hard to track down, Really I would suggest just making a head sculpt and really try and refine it while undoing stokes you don’t want a lot and you will encounter the issue. If I notice any patterns or reproducible occurrences I’ll forward you a blend. I know issues like this are hard to hunt down.

  3. Woohoo, Sculpting improvements! Can’t wait till Blender is comparable to Sculptris/Zbrush in basic sculpting features so I never have to boot up Windows again :-) Thanks for you work!

Leave a Reply

Your email address will not be published. Required fields are marked *