Page MenuHome

Material preview icons not updating
Closed, ResolvedPublic

Description

when adding multiple materials in Eevee the icons remain grey no matter if I choose different colors or not.
also, the material preview seems to be not working correctly...sometimes shows material, sometimes doesn't.
Thanks,
J.Reed

Event Timeline

I can confirm in Windows that icons keep gray. Not sure if this is done by design or not.

The preview works.

Same here (cycles, eevee, materials defined for OpenGl render engine dont get icons at all...), before digging deeper: @Brecht Van Lommel (brecht): this is not by design, right?

Brecht Van Lommel (brecht) renamed this task from Material Icons All Grey to Material preview icons not updating.Oct 22 2018, 5:33 PM

The icons don't seem to be getting updated at all, they display in colors fine for existing files.

Brecht Van Lommel (brecht) lowered the priority of this task from Needs Triage by Developer to Confirmed, Medium.Oct 22 2018, 5:40 PM

These changes do the trick, but maybe they are totally wrong:

diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index f00b745..0c80568 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -140,8 +140,14 @@ void ED_node_tag_update_id(ID *id)
 	if (ntree->type == NTREE_SHADER) {
 		DEG_id_tag_update(id, 0);
 
-		if (GS(id->name) == ID_MA)
+		if (GS(id->name) == ID_MA) {
+			Material *ma = (Material *)id;
+			PreviewImage *preview = ma->preview;
+			if ((preview->flag[ICON_SIZE_ICON] & PRV_CHANGED) == 0) {
+				preview->flag[ICON_SIZE_ICON] |= PRV_CHANGED;
+			}
 			WM_main_add_notifier(NC_MATERIAL | ND_SHADING, id);
+		}
 		else if (GS(id->name) == ID_LA)
 			WM_main_add_notifier(NC_LAMP | ND_LIGHTING, id);
 		else if (GS(id->name) == ID_WO)
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index a842513..091f551 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -151,6 +151,11 @@ static void rna_Material_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene),
 {
 	Material *ma = ptr->id.data;
 
+	PreviewImage *preview = ma->preview;
+	if ((preview->flag[ICON_SIZE_ICON] & PRV_CHANGED) == 0) {
+		preview->flag[ICON_SIZE_ICON] |= PRV_CHANGED;
+	}
+
 	DEG_id_tag_update(&ma->id, DEG_TAG_COPY_ON_WRITE);
 	WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, ma);
 }

The problem is the icon preview is not set to update. The changes in node_draw.c are for materials using nodes. The changes in rna_material.c for materials not using nodes.

@Brecht Van Lommel (brecht) Could you take a look?

MacOS 10.14.1
5K 27" 2017

I am use SecondLife and OSGRid. Object cube is 6 faces (6 Materials) export to collada .dae then import collada on Blender 2.79b it work few weeks ago.
I follow exactly.

Blender 2.79b render preview it work. I am use 7 Materials then texture each materials.
Blender 2.80 render preview not work.
https://imgur.com/a/jZ1or01
https://imgur.com/a/VLk5uok

File: fancyMailBox.zip (Can help you can found between Blender 2.79b it work but Blender 2.80 not work.)

@Kent Davis (mac4kent) : no need to post here again, your original report was merged and is visible from here to everyone interested.

Really that is great merged I never see that one before. You did great job.

@Antonio Vazquez (antoniov), this is not the right fix. It's setting the preview to be refreshed in two places, but it should be handled in a more generic way. It seems grease pencil is also doing this manual update in RNA which is wrong too.

The depsgraph is supposed to call ED_render_id_flush_update, which will tag the icons to be refreshed. I'll commit a fix.

Actually I need @Sergey Sharybin (sergey)'s help. This is the patch I have: P813.

The problem is that it is refreshing icons everytime the file is loaded, which is a serious performance issue on complex scenes. We need to detect which datablocks have been edited by the users, not all datablocks to be updated by the depsgraph.