Page MenuHome

GPencil: New Eyedropper tool for Material creation.
ClosedPublic

Authored by Antonio Vazquez (antoniov) on Sep 5 2019, 12:45 PM.

Details

Summary

This patch is only for the eyedropper to create materials.

Options:
Click: Create Stroke Material
Shift+Click: Create Fill Material.
Shift+Ctrl+Click: Create Stroke and Fill Material.

Toolbar:

Old Demo of first design:
https://youtu.be/U15N7gwVOJQ

Diff Detail

Repository
rB Blender
Branch
temp-gpecil-eyedropper
Build Status
Buildable 4834
Build 4834: arc lint + arc unit

Event Timeline

Please, if you can, review before the 2.81 "cut" date.

  • GPencil: Add status text.
  • GPencil: Basic functionality to remove Modifiers and VFX with R key to get "raw" colors.
  • GPencil: Add new simplify for Tint Color. Required to get raw colors.
-Add LBM+Ctrl to Simplify
Remove unneeded tag.
Brecht Van Lommel (brecht) requested changes to this revision.Sep 9 2019, 5:32 PM

The whole raw mode kind of seems like a workaround for trying to use the display buffer for picking materials, rather than the selection drawing system.

If you did selection buffer drawing with a unique ID per material you could pick that material regardless of any blending or tints, and disambiguate materials with the same colors.

release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
1377

I think it would make sense to have "Raw Mode" as a tool setting, otherwise it's quite hidden.

source/blender/editors/interface/interface_eyedropper_gpencil_color.c
78

This text could be modified to indicate when raw mode is on/off? Now it's unclear to me.

81

This message only appears after moving the mouse a little bit, it should appear immediately (call from eyedropper_gpencil_init instead?).

85

Could you deduplicate this code with rna_GPencil_update and name it something like ED_gpencil_simplify_update?

131

Only call this if scene->r.simplify_gpencil != eye->saved_simplify.

It's quite expensive to reevaluate all objects, and this should only be done when it's really needed.

145–146

Could remove col variable and just use eye->color directly in code below.

156

This could use a comment explaining that grease pencil colors are in display space, and that this conversion is needed to undo the conversion to linear performed by eyedropper_color_sample_fl.

174

Use same notifiers as when modifying actol in RNA.

Here that means:

NC_MATERIAL | ND_SHADING_LINKS
NC_SPACE | ND_SPACE_VIEW3D
196

Use same update as similar code elsewhere. In this case:

WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, &ob->id);
WM_main_add_notifier(NC_MATERIAL | ND_SHADING_LINKS, NULL);
DEG_relations_tag_update(bmain);
215

New Grease Pencil Material created -> Add Grease Pencil Material

221

This value is not used anywhere.

230

Can just pass eye->color directly without intermediate col variable.

241

eyedropper_gpencil_rawmode_set -> eyedropper_gpencil_rawmode_toggle

253

Depsgraph tag only the scene here and send notifier for redraw, not all objects.

265

Comment looks out of place.

270

No need to add break; after return.

286

is_undo is never set, is this code needed or unfinished?

318–319

This seems wrong. You press R to enter the eye dropper in raw mode, then release R key and it disables raw mode, while the modal operator keeps running?

395

Add description explaining what Raw Mode is.

This revision now requires changes to proceed.Sep 9 2019, 5:32 PM

If you did selection buffer drawing with a unique ID per material you could pick that material regardless of any blending or tints, and disambiguate materials with the same colors.

I have no idea of how this works. If you can give me any advice, info or where to look for examples, I can go for that. I think this is the best solution. If you cannot give info, maybe Clément or Germano can help me here.

Antonio Vazquez (antoniov) planned changes to this revision.Sep 10 2019, 11:15 AM

As the best solution is to use the select code, we need a full review of the workflow of the tool. This makes impossible to put in 2.81, so we move to 2.82.

I'm not very familiar with the new selection code. But to me it seems like a lot of the pieces are there.

Grease pencil has code for drawing strokes for selection in object mode and other objects types have code that would work similar to selecting strokes in a grease pencil object (e.g. selecting bones for multiple armatures in pose mode).

So to me it seems quite possible to write some function that gives you the grease pencil object + stroke under the cursor.

CC @Germano Cavalcante (mano-wii) for advice.

Matias Mendiola (mendio) requested changes to this revision.Sep 10 2019, 1:02 PM

The eyedropper tool should works in two ways:

  1. To pick a color under the cursor and use as for the creation of new materials (not only when it is over Gpencil objects)
  2. To get the material of the stroke under de cursor (only from a Gpencil Objetc)

For number 2 we have the problem that right now the selection code in Grease Pencil can't select when it's over filled strokes, it works only over the strokes or a surronding area
If we fix this problem with selection, it will solve also our problem picking the right material with the eyedropper tool.

For the Raw mode we have two ways: Show a tool properties on the header to activate base colors only or a new overlays setting.

@Matias Mendiola (mendio) With the select technique all these issues (fill área, raw mode, etc.) must be solved.

I'm not very familiar with the new selection code. But to me it seems like a lot of the pieces are there.
Grease pencil has code for drawing strokes for selection in object mode and other objects types have code that would work similar to selecting strokes in a grease pencil object (e.g. selecting bones for multiple armatures in pose mode).
So to me it seems quite possible to write some function that gives you the grease pencil object + stroke under the cursor.
CC @Germano Cavalcante (mano-wii) for advice.

Currently for paint modes in meshes, eyedropper uses a selection code that draws ids per face.
Grease Pencil does not support this type of selection. Its selection is made by occlusion queries, that is, the code checks whether any pixels within the selection threshold have passed the depth test between drawing calls.
I'm not sure how efficient the occlusion queries solution is.

If the choice is to implement a solution using the select engine, just add support for Grease Pencil objects there.
(I can do it depending on what is decided).

GPencil: Eyedropper for creating materials (task T69720)

Cleanup code not related to this patch.
Antonio Vazquez (antoniov) retitled this revision from GPencil: New Eyedropper tool to GPencil: New Eyedropper tool for Material creation..Sep 10 2019, 5:55 PM
Brecht Van Lommel (brecht) added inline comments.
source/blender/editors/interface/interface_eyedropper_gpencil_color.c
118–121

Follow comment style:

/* Convert from linear rgb space to display space because grease pencil colors are in display
 * space, and this conversion is needed to undo the conversion to linear performed by
 * eyedropper_color_sample_fl. */
  • Cleanup: Clang format for comments
This revision was not accepted when it landed; it landed in state Needs Review.Fri, Oct 11, 1:33 PM
This revision was automatically updated to reflect the committed changes.