SculpTkt - a toolkit for sculptors

About the brush selection… that’s a point I want to improve, in 2.8 the brush selection display is not working, I suppose it has something to do with the tool system. I need to implement my own brush selection interface, probably shortcut driven?.

But the slash, there is something strange, what is your OS and system specs?

Going to try Sculpt Toolkit for Blender 2.8 today.

Out of curiosity: what approach is used by the Voxel Remesh option? The latest Tesselator algorithm? And does it have options, such as smoothing?

no, voxel remesh is just a regular remesh modifier, which is voxel based.
I added a vertex collapsing algorithm to make the topology cleaner but is mainly “vanilla blender”.

1 Like

Windows 10 64bit
AMD Ryzen 5 2600 4.0GHz
16G DDR4 3000hz
GTX 1070ti
1g SSD

Uploaded video to give you a better idea of what I experience on my end. Not sure how to add it where you can view in forum without downloading as you did with your video above.

Blender 2019-03-30 10-23-21-1.m4v (2.0 MB)

This is really weird.
Have you updated your graphic drivers?
Can you try to factory reset blender? sometimes it fixes weird bugs.

I performed the factory reset and still experience the same issue with Slash Cutter.

Which 2.8 build are you using? Maybe I can test with a previous build.

I am using the yesterday’s one with no troubles, aren’t you using the same?

I went into appdata and removed addon from their which fixed the issue with addon appearing in tool bar but still experience the issue with Slash Cutter. I am still troubleshooting on my end.

Can you paste this code in the text editor and tell me if you see something in the viewport?

I just pasted in script editor and selected run script. Is that the correct process?

Slice Boolean function works just fine.

No, I’m sorry that’s just the description, you have to click in the link to see the whole script on github.

Try this:

'''
Created by Jeacom
This is a utility module for drawing lines in the 3D viewport on Blender 2.8
using the GPU Api
The idea is to get rid of messy draw functions and data that is hard to keep track.
This class works directly like a callable draw handler and keeps track of all the geometry data.
'''

__all__ = ["LineRenderer",
           "BLEND",
           "MULTIPLY_BLEND",
           "ADDITIVE_BLEND"]

import bpy
import bgl
import gpu
from gpu_extras.batch import batch_for_shader
from mathutils import Matrix, Vector

# Blend Modes
BLEND = 0
MULTIPLY_BLEND = 1
ADDITIVE_BLEND = 2


class LineRenderer:
    def __init__(self):
        # Useful for rendering in the same space of an object
        self.matrix = Matrix().Identity(4)
        # X-ray mode, draw through solid objects
        self.draw_on_top = False
        # Blend mode to choose, set it to one of the blend constants.
        self.blend_mode = BLEND
        # Width of the lines
        self.line_width = 2.5
        # Handler Placeholder
        self.draw_handler = None

        self._coords = []
        self._colors = []
        self._line_shader = gpu.shader.from_builtin("3D_SMOOTH_COLOR")
        self._line_batch = batch_for_shader(self._line_shader, 'LINES', {"pos": self._coords, "color": self._colors})

    def __call__(self, *args, **kwargs):
        # __call__ Makes this object behave like a function.
        # So you can add it like a draw handler.
        self._draw()

    def setup_handler(self):
        # Utility function to easily add it as a draw handler
        self.draw_handler = bpy.types.SpaceView3D.draw_handler_add(self, (), "WINDOW", "POST_VIEW")

    def remove_handler(self):
        # Utility function to remove the handler
        self.draw_handler = bpy.types.SpaceView3D.draw_handler_remove(self.draw_handler, "WINDOW")

    def update_batch(self):
        # This takes the data rebuilds the shader batch.
        # Call it every time you clear the data or add new lines, otherwize,
        # You wont see changes in the viewport
        coords = [self.matrix @ coord for coord in self._coords]
        self._line_batch = batch_for_shader(self._line_shader, 'LINES', {"pos": coords, "color": self._colors})

    def add_line(self, start, end, color1=(1, 0, 0, 1), color2=None):
        # Simple add_line function, support color gradients,
        # if only color1 is specified, it will be solid color (color1 on both ends)
        # This doesnt render a line, it just adds the vectors and colors to the data
        # so after calling update_batch(), it will be converted in a buffer Object
        self._coords.append(Vector(start))
        self._coords.append(Vector(end))
        self._colors.append(color1)
        if color2 is None:
            self._colors.append(color1)
        else:
            self._colors.append(color2)

    def clear_data(self):
        # just clear all the data
        self._coords.clear()
        self._colors.clear()

    def _start_drawing(self):
        # This handles all the settings of the renderer before starting the draw stuff
        if self.blend_mode == BLEND:
            bgl.glEnable(bgl.GL_BLEND)

        elif self.blend_mode == MULTIPLY_BLEND:
            bgl.glEnable(bgl.GL_BLEND)
            bgl.glBlendFunc(bgl.GL_DST_COLOR, bgl.GL_ZERO)

        elif self.blend_mode == ADDITIVE_BLEND:
            bgl.glEnable(bgl.GL_BLEND)
            bgl.glBlendFunc(bgl.GL_ONE, bgl.GL_ONE)

        if self.draw_on_top:
            bgl.glDisable(bgl.GL_DEPTH_TEST)

        bgl.glLineWidth(self.line_width)

    def _stop_drawing(self):
        # just reset some OpenGL stuff to not interfere with other drawings in the viewport
        # its not absolutely necessary but makes it safer.
        bgl.glDisable(bgl.GL_BLEND)
        bgl.glLineWidth(1)
        if self.draw_on_top:
            bgl.glEnable(bgl.GL_DEPTH_TEST)

    def _draw(self):
        # This should be called by __call__,
        # just regular routines for rendering in the viewport as a draw_handler
        self._start_drawing()
        batch = self._line_batch
        self._line_shader.bind()
        batch.draw(self._line_shader)
        self._stop_drawing()

if __name__ == "__main__":
    # Simple example, run it on blender's text editor.

    # create a new instance of the class
    renderer = LineRenderer()
    # add lines to ir
    renderer.add_line((10,0,0), (-10,0,0), color1=(1,0,0,1), color2=(0,0,1,1))
    renderer.add_line((0,0,0), (0,0,5), color1=(0,1,0,1), color2=(0,1,1,1))
    # enable X ray mode/see through objects and set Blend mode to Additive
    renderer.draw_on_top = True
    renderer.blend_mode = ADDITIVE_BLEND
    # set line width to 5
    renderer.line_width = 5
    # Important, update batch always when adding
    # new lines, otherwize they wont render.
    renderer.update_batch()
    # setup draw handler, optionally, you can call bpy.SpaceView3D.draw_handler_add()
    renderer.setup_handler()

You made an addon for a 3d app that is called “Blender” that is coded in “C” and scripted in “Python” (which by the way is not even named after the snake but the Monty Pythons)

I don’t think you should be worried whether the name is bad or not. All the above prove that names are irrelevant , its usability that matters.

2 Likes

Seeing some progress. After running script I noticed the axis are colored. I am able to get two or three slices in before it stops working again. If I make a new object I am able to get a few slices before it stops working again.

Well the important thing is that the colored lines are drawn, which means it must be a bug with the 2D viweport shaders, so I will rewrite the drawer to work in 3d space.

Blender 2019-03-30 13-07-10-1.m4v (2.4 MB)

In this video you can see the first two slices work just fine. Slice line is visible as well. On the third and fourth attempt nothing happens after drawing slice. During that time I am not able to interact or pan around object.

Hope this helps you.

Hi @jeacom,

Just tried Sculpt Toolkit and I really like it. I’ll buy it from Blender Market today.

Some feedback:

  • Overall I think it’s a very convenient and useful addition for sculpting in Blender. :+1:
  • I miss the relatively new 2D Falloff option in the Sculpt Mode options.
  • If you could implement Topology Rake as a switch in stead of a factor, that’d be great (switched on = full factor of 1). Additionally, a global Topology Rake toggle for all brushes would also be very welcome. I use the function most of the time.
  • The headers of the drop-down menus are overlapped by the menus, so you have to move your pointer away from a menu header to access the next one (unless you go to a header at the left side of the current one).
  • Ideally, I’d love to be able to set the delay time for a drop-down menu to appear. In my case I’d love to see them unfold instantly.
  • Would it be possible to add the Sculpt brush Falloff curve?
  • Being able to determine a depth for the Slash Cutter would be great, so you can create partial cutouts / indents.
  • Shape options for the Slash Cutter would also be very nice (square, circle, ellipse, ngon).
  • It’d also be great if you could determine the Sculpt Toolkit shortcut key in the Preferences.
  • The Add Mask Deform option is a bit different than I expected. In a Sculpt Toolkit video I saw a custom manipulator, slightly similar to the ZBrush Transform Gizmo. But in the 2.8 version there’s two Empty objects you have to select and manipulate separately.
  • I really like the three-step mask extract option. :+1:
  • Mask Tools has a great option to use the Loop Tools Relax function on the borders of an extracted mask, resulting in smooth borders. It’d be very cool to also have that in Sculpt Toolkit.
  • Additionally, creating smooth-bordered inward / outward extrusions from masks would also be very welcome.
  • I’d love more mask options, such as expand / shrink mask, smooth / sharpen mask, cavity masking and saving / loading masks as vertex groups, vertex weights or vertex color channels.
  • A last, very minor aesthetic note: the Slash Cutter has a little typo: it now reads “Slash Cuter”. It’s a cute function, that’s true. :wink:

Thanks for your great work!

One more thing: I get a persistent error when I try Split Mask. The error report mentions line 138 and line 157. Error type: internal error.

Tanks for your feedback @Metin_Seven.

I’ll work on those suggestions and fix these problems, some are a little easy, so I’ll start from there, right after I fix slash cutter for @EdDiesel

about the drop downs time, its under user preferences.

1 Like

Great, thanks!

Thanks. I thought you were using a custom timing.

Does this alpha version for 2.8 contain the ‘bone’ primitive in the envelopes (the primitive for beginning a shape from scratch)? I am not finding it.