Brush Properties #100137
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
7 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#100137
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Blender needs a more generic way to store brush properties. This is needed to simplify code and to support the more advanced brush systems found in other graphics software. Krita's brush editor, for example, lets users add input dynamics to each brush property (for example, users can map pen pressure to size, tilt to squish, etc) and with custom input curves. A generic property system is also needed for the planned node-based brush engine.
A proof of concept has been implemented in temp-sculpt-brush-channel. This task documents how it works.
Brush Properties
NOTE: the word "channel" shall be renamed to "property."
A brush channel (
BrushChannel
) is a float, int, color, curve, enum, bitmask, etc. It can be driven by input mappings (e.g. pen pressure) withcustom input curves. Channels are stored in channel sets (
BrushChannelSet
) and are looked up by name.Brush channels do not store property values themselves but instead wrap RNA properties.
UX Design
Channel Dynamics
Input dynamics works in a similar way to Krita. Here is the rather bad UX I came up with in sculpt-dev:
Property Lists
Brush properties will be assigned to three different lists: Workspace settings, the menu header and right-click context menu.
This will happens in a special Brush Editor Mode:
The icons on the left control property visibility.
Property Categories
Brush properties can be grouped into categories (which are currently hard-coded):
Technical Design
Property Types
Channel Inheritance
Unified brush properties are stored in ToolSettings.unified_channels. Properties are flagged in unified mode with BRUSH_CHANNEL_FORCE_INHERIT (possibly to be renamed to BRUSH_CHANNEL_UNIFIED).
Note that each input mapping inside of a brush channel can also be set to unified independently, this is useful if e.g. you want a brush to have it's own radius but still use the scene pen pressure input mapping.
In addition bitmasks can be set to OR with the parent (scene defaults) value. This is needed for the automasking settings.
Compile-time Name Checking
Brush settings identifiers are simple C strings. The C API is designed to catch typos at compiler time. It does this by generating a bunch of global string variables like so:
Important API functions are then wrapped in a series of
BRUSHSET_XXX
macros (todo: find better preset thanBRUSHSET_
). So to lookup a channel you might do:The C++ API works a bit differently;
BrushChannelSetIF
has one accessor method per brush channel.I tried to get compile-time string validation of channel names to work but failed (at least in C++17),
so I ended up using macros to create accessor methods instead.
No ID pointers
Aside from textures (the implementation of which incomplete), no ID pointers are allowed in BrushChannels. This is so we can link in brushes from an asset file as library overrides without weird edge cases or performance degradations on file IO.
This decision may be revisited later.
Property Storage
The existing RNA properties are reused for local brush properties. Unified properties are stored as
IDProperty
copes of theBrush
RNA properties inToolSettings.unified_properties
.C++
NOTE: not yet ported to
temp-sculpt-brush-channel
.The current API implementation in sculpt-dev is mostly implemented in C, which has led to some code messiness. The process of switching the implementation to C++ has begun; the existing C API will be (mostly) kept, but it will wrap a C++ one.
The C++ API works by wrapping the C DNA structs, so e.g.
BrushChannel
has aBrushChannelIF
C++ wrapper class ("IF" just stances for "Interface"; suggestions for better names are welcome). The C++ API is quite a bit cleaner (and clearer), and uses templates:Core data structures:
Added subscriber: @JosephEagar
Added subscriber: @tiagoffcruz
Added subscriber: @TheRedWaxPolice
Added subscriber: @GeorgiaPacific
Added subscriber: @mod_moder
If brushes become more modular in general, that sounds very good.
I've had a lot of problems trying to use my graphics tablet so I don't have much experience with it, but I'm not sure how I could do such complex adjustments like in sai or crit.
About compile-time name checking: I'm not sure why this is needed? Are you getting a reference to a build-time structure, or are you reporting a compile-time type for builder?
If data can be queried at runtime, then attributes have an example of a lookup with validation at runtime (like
inline GAttributeReader lookup
).Or maybe it's related to code generation, then maybe this part is more deeply hidden and if, let's say, I make a new brush with this system, then I will not know about such a deep part.
Compile-time name checking is to ensure you don't accidentally ask for the
sze
attribute instead ofsize
.Yes, and more generally when you call BLI_Assert, since strings are not variable names and may depend on how the program runtime
Although again, it depends on your plans for using it, I only see a comparison with accessing named data
In general, the error is there, which is not so difficult to notice, on the other hand, string checking on build limits scaling and increases build time (?)
The name checking is done in C so there's no build penalty.
Changed status from 'Needs Triage' to: 'Confirmed'
Added subscriber: @Nika-Kutsniashvili