This task lists and details all tasks related to the design of a Sculpt/Vertex painting mode and a attribute edit mode.
Vertex Colors Project Description
By adding the MVertCol datalayer we can reuse the sculpt mode code to support painting functionality inside Blender.
This painting mode is intended to be an artistic painting mode with support for all tools and workflows designed for this task. Texturing, illustration and concept art uses cases fall into this category. This does not mean that other modes with other uses cases should not have brush tools or painting functionality.
This functionality is accesible inside the current Sculpt Mode to support features and workflows that could take advantage of sculpting and painting at the same time, as well as sharing common features instead of implementing a painting and a sculpting version of the same thing.
Implementation of Blender´s main painting brush in Sculpt/Vertex paint
The behavior of this brush is most likely going to be used as a reference to implement 2D and 3D painting. The goal should be to support the same brush presets in all paint modes, so the implementation in the different paint modes should match.
Brush paint properties
Density is a factor that controls how many elements inside the brush radius are going to be painted. This adds extra detail to the stroke without needing to add a texture. Useful for simulating pencils or organic mix brushes.
This works by hashing the pseudorandom values before applying the paint to each element (in this case, hashing the vertex index + brush position). Some other painting apps have the density seed fixed per stroke instead of per sample. We can add an option to support both.
Opacity controls the alpha of the painting color (it is currently called strength in the UI, so it should be renamed for painting modes).
Flow controls how many brush samples are needed to reach the opacity alpha value. This is often explained as “how much paint the brush applies”.
To support that, the PBVH needs extra compositing buffers to mix the paint from the current stroke on top of the original colors.
This controls how much paint is picked from the surface and added to the brush color while painting. This is essential to support proper brush color blending while painting.
Hardness should be the main property to control the brush fall off. The current Falloff panel should be hidden in the UI as an advanced brush option as changing that curve breaks the intended behavior of the brushes.
Furthermore,Hardness is a linear property and it can be mapped to pressure or tilt, which is a basic behavior of any painting software.
As it is implemented now, hardness shifts the falloff interval towards the edges of the brush.
Some features in the sculpt and paint modes are already coded with a hard coded hardness value, so we need to replace it with the brush property.
Procedural tip shape
The functionality of this feature is implemented in brush_test_cube and it is shared with the sculpt Clay Strips brush. It allows to change the brush tip shape between a square and a circle.
Tip shape rotation
The paint brush should support tip rake rotation. The implementation is identical to the clay strip brush.
We can also support locking the initial rotation in screen space. This is useful for creating inking and lineart brushes with non uniform scaled tip shapes. The initial rotation can be controlled by another brush property.
This feature is more important in 2D paint than in 3D paint, so I need to investigate a correct way to implement it.
Tip shape scale
This is achieved by scaling the brush local space matrix. Exposing one axis as a brush property is enough as you should be able to set the rotation.
We can also look at using the brush tip scale to adjust the brush spacing accordingly, but it is not absolutely necessary.
Default brush presets
As the new brush with all the new painting properties is flexible enough to create brushes for different purposes, we may want to ship Blender with a small set of default brushes (like Grease Pencil).
We may need feedback from texture artist and illustrators to design a set that fits most users needs.
Brush input curves
Until we have the functions branch merged and the new brush input system in master, all brushes should come with a default input curve hard coded to get the correct behavior (this is something that was done during the 2.82 development in the sculpt brushes).
As part of this task, it may be needed to add extra flags to map pressure to some of the new attributes, similar to how we are now enabling pressure/size and pressure/strength. This flags won’t let users modify the curves.
After adding the new node based brush input system, all these attributes should be exposed to the node network and users would be able to choose how they want to map them to the pen pressure/tilt
Color Mix Modes
Add all the color mix modes available in Blender to the paint brush. The implementation is straightforward.
Paint Brush UI
We need to decide were to add the new brush properties in the UI. Properties like hardness should be easily accesible, both for sculpting and painting.
We may need to reconsider how the top bar is organized in Sculpt Mode, as currently it does not make much sense. Often the most important properties of the brush are hidden under a popover.
Color smooth brush
Simple color smoothing function, similar to the current mask smooth. It can be included as part of the main paint brush when pressing shift or as a separate tool.
This brush tool should move the vertex colors without displacing the geometry. I need to check how to implement it, but it could be similar to the Slide/Relax brush.
The color filter is a tool that modifies all colors in the sculpt at once taking the sculpt mask into account. The implementation is exactly the same as the current mesh filter, so all extra modifications needed to support this are already in Blender (FilterCache, filter fully masked nodes)
We may consider adding the color fill functionality to the color filter instead of adding a separate fill color operator. The main advantage is that users will be able to control the intensity of the fill in real time, because in sculpt mode the redo panel is not available. We need to add a color property to Sculpt to support this (similar to the Texture or Gravity Object datablock)
Texture color filter
Exact same implementation than the Mesh texture filter but for colors instead of for displacement. This needs a texture datablock to be in Sculpt, similar to the gravity object.
We may want to consider this later as it uses the old Texture datablock and nodes, which is currently deprecated.
Color editing filters
This is the standard set of color editing operations on colors, also available in Cycles/EEVEE and in the compositor. Most of these operators are already coded for MLoopCol and can be easily ported to the color filter.
The gradient tool is almost identical to the color filter. The main differences are the input code (this tool needs the direction of the cursor movement) and the functions that are used to modify the colors.
It includes the basic types of gradients that are supported in most graphic editing software.
It also supports snapping to 90 degree angles and it takes the sculpt mask into account.
Top bar color ramp UI design
If we render the current color ramp template in the top bar in a single row it does not look nice (it usually needs 3 rows). We may want to improve this, but it does not affect the functionality of the feature.
All gradient types work the same, they just use a different geometry operation to determine the gradient (Distance to plane, distance, angle…)
Gradient based on the distance to the initial position
Gradient based in the distance to a plane
Gradient based on the angle difference between the mouse drag vector and the initial position - vertex position vector.
Active vertex color picker
The painting sample_color operator should pick the color of the active vertex and assign in to the brush (or to the UnifiedPaintSettings color)instead of picking the shaded color from the viewport.
This task needs the asset manager in master in order to start.
Brush engine preview generator
This needs the new input system on top of the asset manager in order to start. The idea is to generate brush previews based on the parameters of the new brush engine and use them in the asset manager.
Asset manager global brush palette
After merging the asset manager, all brushes should be accesible from a single place, changing the tool automatically when you select a brush preset.
We need to decide how are we going to store, export and import brushes. This is an asset manager related task.
Import/Export support for the vertex colors layers. We need to check which formats and use cases support this.
In the meanwhile we can use the vertex colors/attributes conversion operators to get the colors in an out or Blender
Sculpt mode integration
This describes different task that can be done to create new tools and workflows that can be done after supporting sculpting and painting in the same mode.
Sculpt + Paint at the same time
This feature is useful when creating concept art. As all the painting functionality shares the same code as sculpt mode, this is easy to support.
We need to add an extra paint capability to the brushes to enable only the sculpt brushes that make sense for painting (for example, it does not make sense that the pose brush applies paint).
We need to add a SCULP\_UNDO\_COORD\_COLOR flag to support storing the undo data for coordinates and colors at the same time. Internally, this is just calling both coord and color store functions in the same node undo push.
Sculpt mask integration
When painting, the sculpt mask and all the tools to edit it (mask filter, mask expand, box and lasso selections) can provide the same functionality as selections in other painting software, so we don’t need to code another selection system for painting.
Mask by color operator
Simple operator that mask all similar colors to the active vertex color.
Mask expand by color
The current mask expand supports two modes (topology and curvature). We can turn this operator property into an enum and add a mask expand color mode that calculates the mask expand factors based on the color differences. After this change, this operator should provide the same functionality of the “magic wand” or “smart selection” in other painting softwares.
Automask by color
The automasking code supports enabling multiple automasking operations. We can create another automasking modes that assigns mask values automatically based on the color difference of the active vertex when the stroke started. This can be useful when sculpting across painted ¨materials¨.
One of the main features of this paint mode is that you can sculpt on models with colors without using UV. This allows to keep the topology dynamic using the remeshers.
Voxel remesh Reprojection
This will add the “Preserver paint colors” option to the Voxel remesher. All vertex colors layers are recreated and colors are transferred using the nearest vertex color from the previous mesh. This is also how the “preserve sculpt mask” option works.
This function can be also added to Quadriflow, but it does not make much sense as Quadriflow is supposed to be used with Multires.
Quadrilfow reprojection to multires
Quadriflow remesh should produces a base mesh with the sculpt detail projected to the appropriate Multires level. This is currently not implemented as the current Multires modifier is not enabled for sculpting.
After enabling Multires and implementing this feature, it should also support vertex color reprojection.
We need to check the status and roadmap of Multires before tackling these tasks. If sculpting multires is not fully functional, it does not make sense to add color features to it.
Multires color data layer
A datalayer needs to be added to support vertex colors in Multires, similar to how the Sculpt Mask works.
This also needs all necessary updates to Multires to support vertex colors in the grids.
Multires level propagation
Color values need to be propagated across levels without creating artifacts.
Multires texture baking
After finishing these task, Sculpt/Vertex paint mode will be a more advance painting more than Texture paint and some users will want to use it as the main painting mode. Until we design and update texture paint to support all these painting features it would be nice to have some baking functionality to be able to work on texture colors by converting them to vertex colors. Sculpt mode can easily work with 17M vertices + duplicates on Multires, so supporting painting a baked 4K texture on vertex colors seems like a reasonable use case.
Workbench vertex color rendering
Sculpt PBVH rendering support for regular meshes (PBVH\_FACES). We also need to add support for PBVH\_GRIDS if we want to support Multires.
Object Mode rendering
Regular workbench vertex color rendering for the rest of the modes. This should be enabled when enabling the vertex color mode in the Shading popover
EEVEE/Cycles vertex color node
Vertex Colors layers should be accesible with the Vertex Color node to render in Cycles/EEVEE.
Vertex colors are stored as floats in scene linear color soace as defined by the OpenColorIO configuration. By default this would be a linear color space with sRGB chromaticities. This is the same color space as for example material colors. That means these colors can be used as is for rendering without any color space transformation.
Note that by convention old vertex colors are stored in scene linear color space with the sRGB transform used for compressing them to bytes. This transform should be considered purely a compression and has no semantic meaning.
Attribute Edit Mode
Attribute Edit is intended to be a mode to modify and visualize any kind of data stored in mesh elements. Some use cases for it could be:
- Editing IDs on face corners to modulate materials in a shader
- Painting velocity vectors on vertices to guide a particle system
- Editing the weights of a rig
- Editing per face colors for low poly models without using textures
- Setting custom values on edges for a motion graphics animation
- Modifying mesh values for procedural modeling
Some of these task could use a brush, but they don’t need a brush with artistic painting functionality. It does not make sense to edit the weights of a rig with a brush with wet paint and density noise.
Furthermore, these task could take advantage of a mode with more control and precision tools than an artistic painting mode, like precise elements selection and data editing, controlled value interpolation…
The plan is to use the current Vertex Paint mode as a base implementation for this mode and start adding all necessary features during multiple releases. It already has quite some work done because most users were using it with these use cases in mind.
This task is not as detailed as the Sculpt/Paint mode, but it should be enough to have an idea of its purpose, use cases and design goal.
Simple brush tools
The current Blender brush functionality is enough to support this kind of painting, if we consider painting changing the values of elements that are inside the cursor radius. We can reuse the current brush code for that.
Value interpolation tool
This tool could produce controllable interpolations of an attribute between two mesh elements following the mesh topology. For example:
- Select the base of a cone and assign the value of one
- Select the top vertex of the cone and assign 0
- Let the tool generate the rest of the values across the cone surface
Mesh elements selection
Attribute paint should provide tools for selecting mesh elements and assign values directly to them. This provides much more control than a brush. This could be useful when working with low poly models, where you want to assign values like armature weights in a precise way.
Mesh element masking
We can support a basic masking functionality for the brush that supports all mesh elements (not only vertices like the Sculpt/Paint mask). This can make easier some painting task.
Data conversion operators
Attribute edit mode should provide a set of conversion tools to convert data between elements and other Blender data layers when possible. For example:
- Convert a per vertex attribute to a per face corner attribute
- Convert a per edge attribute to a vertex attribute averaging the values
- Generate material slots from an ID attribute stored on faces
- Generate an editable 2D vector attribute from an UV layer
Per face corner color data to sculpt/vertex color data
This is a specific case of a conversion operator. Other conversion operators can be added in the future as we support more attribute types.
Internal attribute conversion
We need to identify what element/attribute type conversion combinations are more frequent and design how they can work (usually averaging the values). For example
- Converting an attribute from face corners to faces by averaging the values of all the face corners in the face
- Converting from vertex to edges by averaging the value of the two vertices of the edge
- Converting from vertex to face corners assigning the same vale of the vertex to all the face corners that use that vertex
We could support editing operations with symmetry based on the mesh topology instead of mirroring the XYZ axis.
Attribute data type selection
The use should be able to choose what kind of data he/she wants to edit and in which mesh element that data should be stored. For example
- A float factor stored on faces
- A vector stored on vertices
- A color stored on face corners (Current supported MLoopCol)
All tools should be aware of the data type of the layer and behave accordingly.
It should be possible to import and export meshes with different attributes in mesh elements. We need to check format compatibility.
Attribute edit overlay
As we can make assumptions that the attributes are colors, we need to render a configurable overlay to display the data in an appropriate way.
Attribute rendering mode selector
The attribute rendering overlay should provide and UI to choose which rendering mode the user wants to render the data. This should include tools like a gradient editor, rendering two attributes at the same time, render vectors and randomly generated ID maps.
EEVEE/Cycles attribute node
The current attribute nodes exposes MLoopCol and UVs to the render, which are both loop attributes. We need to investigate how to expose face, vertex and edge values.
I recommend that the main priority for merging and reviewing the patches should be getting the full version of the paint brush to master as soon as possible, even with a temporally incomplete painting workflow. The design decisions on parameters, default values and behavior are really hard to get right, it would me nice to have as much artist feedback as possible. We will continue making changes to the brush during the release cycle to ship Blender with a proper implementation, defaults and presets.
Datalayers and Paint Brush
As it is possible that the design of the brush will be reused for texture painting, this is a critical task. In order to achieve this, these are the task that the first patch should contain:
- MVertCol datalayer and PBVH undo support to implement the brush.
- Paint brush (with all paint properties)
- Workbench vertex color rendering: PBVH color rendering
- Active vertex color picker
In order to create small test projects to test the brush more extensively, it would be also recommended to include:
- Remesh reprojection support
- Workbench object mode rendering: Object mode rendering
- Cycles/EEVEE vertex color node
With that set of features merged, we should be in a good place to start creating vertex paint projects.
Note that the naming (Sculpt vertex colors vs vertex colors) won´t be final when merging this patch. This is to avoid duplicating the length of the patch with a huge name of line changes that won’t make any difference on what we should be doing at that stage.
After merging the first patch, we can create another patch that includes only the renaming of the current code functions and UI. By doing this, we reduce the amount of lines changed in the first patch and we will have more time to decide the final naming of the datalayer to make it less confusing for the users.
- Sculpt Vertex Colors -> Vertex Colors
- Vertex Colors -> Attributes
- Sculpt Vertex Colors -> Sculpt Colors
- Vertex Colors -> Attributes
After this patch, we should have stablished the difference between Painting and Attribute editing described in this patch. Vertex Paint/Vertex colors will became Attribute Edit and it will have the exact same functionality, with is a subset of the Attribute Edit mode.
After merging the two initial patches, we can start merging the rest of the tools, in no particular order.
Gradient and Mesh Filter
The Gradient tool and the mesh filter code is almost identical, so it should be easier to review them at the same time. Also, both share some common code (color data in the filter cache)
Color Smooth Brush
This is just a copy of the regular smooth/mask smooth brush but that works on color data. Should be easy to review and merge.