Page MenuHome

2D workspace Bugs
Open, Confirmed, MediumPublic

Description

System Information
Operating system: Windows 10 (64 bit) OS build 17134.591
Graphics card: Graphics Chipset AMD Radeon(TM) R4 Graphics

Blender Version
Broken: Blender 2.80 Beta Windows 64 bit March 09, 01:09:33 - a0f2923fd821

Short description of error
1# Pen settings and material properties tabs disappeared


2# An anonymous blank material comes out

Exact steps for others to reproduce the error
From 2D animation default file, switch fill tool to draw tool and the pen properties will disappear. It'll only reappear once again when I reopen the .blend file.

Details

Type
Bug

Event Timeline

Sebastian Parborg (zeddb) triaged this task as Needs Information from User priority.Mar 9 2019, 1:38 PM

In the future, please only report one issue per ticket.

In this case the first issue is a duplicate, so no need to report it again: T59445

I can see the second issue in your file, but you do not describe how you got it in the first place.
If I open up the default 2D animation file, that blank material is not there.

How did you managed to get the blank material?

@Sebastian Parborg (zeddb) I don't know exactly. But I am filling colour to my art and play around with the "Grey" and "Red" materials properties and press "+" button to add another material then weirdly it occurs.

@Hanafi A. Hassan (HanafiHikari) could you provide a step by step guide?

Like this:

  1. Open the default 2D animation file
  2. Draw a stroke
  3. Change the material color
  4. Add a new material with the + button
  5. Notice that a empty material is added
Sebastian Parborg (zeddb) raised the priority of this task from Needs Information from User to Needs Triage by Developer.Mar 9 2019, 2:32 PM

Please check rBba4d07cc5c74e42445a59bf1e77587cbf4a83482 to see if it fixed the material issue.

Fixed the "hidden" problem for me, but it (not sure if it was caused by your commit) behaves weird:
Step by step repro:

  • File -> Load Factory Settings
  • File -> New -> 2D Animation
  • with the already selected 'Black' material click at the 'Add a new material' button, 'Black.001' appears in-place of 'Black'


  • draw a line
  • by hovering the pointer over the material panel the old material 'Black' magically appears in a new slot at the bottom of the slot list:

No, it's not magic.... I guess the current brush has assigned the "old" material, so when you draw a new stroke with this brush, the system check if the material is assigned to the objet, and add it if necessary.

Verify what material are you using in the current brush and verify also if the material is pinned to the brush.

Verify what material are you using in the current brush and verify also if the material is pinned to the brush.

It feels magic ;-)
I wrote the minimal example repro with a start from the factory settings, so you can verify everything yourself.
I believe the material setting is currently weird/broken. See e.g. at the 12 in the screenshot …

The 'Add a new material' button in theory is a 'Replace with duplicate' button.

The 12 is likely caused by loading the .blend file. I can reproduce this with Grease Pencil -> Blank.

Here is one possible solution. Keeping the 'magic' in sync with the properties panel (immediately, instead of after the next stroke):

diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index d1bed15872d..c622d850e07 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -530,6 +530,13 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
 		Material *new_ma = NULL;
 		BKE_id_copy_ex(bmain, &ma->id, (ID **)&new_ma, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS);
 		ma = new_ma;
+
+		if (ob != NULL && ob->type == OB_GPENCIL) {
+			assign_material(CTX_data_main(C), ob, new_ma, *give_totcolp(ob) + 1, 0);
+
+			WM_event_add_notifier(C, NC_MATERIAL | NA_ADDED, new_ma);
+			return OPERATOR_FINISHED;
+		}
 	}
 	else {
 		const char *name = DATA_("Material");

Another solution is to replicate the behviour of other objects.

diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index d1bed15872d..03a54e1c40b 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -60,6 +60,7 @@
 #include "BKE_texture.h"
 #include "BKE_workspace.h"
 #include "BKE_world.h"
+#include "BKE_brush.h"
 
 #include "DEG_depsgraph.h"
 #include "DEG_depsgraph_build.h"
@@ -530,6 +531,10 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
 		Material *new_ma = NULL;
 		BKE_id_copy_ex(bmain, &ma->id, (ID **)&new_ma, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS);
 		ma = new_ma;
+
+		if (ob != NULL && ob->type == OB_GPENCIL) {
+			BKE_brush_update_material(bmain, new_ma, NULL);
+		}
 	}
 	else {
 		const char *name = DATA_("Material");

I don't really know which one is the intended behaviour.

Edit:
Now I think the new material copy should be placed in a new slot. Without the material brush pin also set as current?

Is the pin option intentionally not present in the active tool settings?
Brush switching via the active tool settings is also not synchronized properly with the top bar. The brush name in top bar changes only after drawing in the viewport.

If you don't look at or hide the top bar (me), the GP materials panel is currently misleading, sorry for my confusion.

Thanks @matc (matc) for your code. I have committed one of your solutions (credits to you). The good one is update the brush using BKE_brush_update.

I have seen there are still some problems with the user number for the autocreated materials. I will take a look on that too.

Bastien Montagne (mont29) triaged this task as Confirmed, Medium priority.

@Matias Mendiola (mendio) Can you verify the template design? it looks there are enough screen space in the example above.