Goal
Sampling colors is implemented in various different ways throughout Blender, each implementation with their own advantages and features.
The goal here is to combine all needed features into an easily accessible operator, with additional options to get other sampling effects.
This operator will then be used for color sampling in sculpt/paint mode and paint mode in the image editor.
The basic implementation in sculpt mode is already usable for now.
Requirements
Existing Features
- Sample Merged (Only available in the keymap options or with the color picker button)
- Add to Palette (Already available via left click)
- Sample Size (Only in the image editor sample tool)
- Live sample values for XY, RGBA, CMGB, HSVL, color (Only in the image editor sample tool)
- Sample Interpolated vs Closest (Automatic for textures. Always picks closest in Weight painting. Not implemented for color attributes. Needs more investigation on what would be most useful.)
Accessibility
The easiest way to access the color sampling should always be with a shortcut.
For now the established default is S. We should follow this wherever possible to stay consistent.
Potentially the best usable way to implement this in the UI is as a button in the color picker instead of an active tool.
The disadvantages of making this an active tool are
- that it doesn't directly relate to any particular color or brush/tool
- it's more intuitive to use as a temporary one-click operation (No needs to keep it active)
Sample other Objects
It's already possible to pick any color of the screen when sampling merged colors.
When sampling the current paint slot of the Canvas this is not the case.
Multi-object workflows are very common so there needs to be an implementation to instantly sample local colors from another object.
Use active Canvas picker mode
One straight forward implementation would be to use the Canvas picker mode of the active object to define which colors will be picked. This mode can be set to:
- Color Attribute
- Image Texture
- Material
Each of the other visible objects will have an active color attribute, image texture and node in the material.
So the desired approach is to look for that data and use it for color sampling other objects whenever the option "Sample Merged" is not used.
Color Sample Overlay
When painting for materials there will be cases where it is not obvious what color will be picked.
For example when picking from a greyscale image texture that is used for roughness, while you see the final material in Eevee with additional colors and procedural roughness textures mixed in.
This color sampling preview would ideally be shown directly on the brush cursor, comparing it side-by-side with the currently set color.