Material preview icons not updating #57316

Closed
opened 2018-10-20 03:48:25 +02:00 by John Reed · 17 comments

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

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
Author

Added subscriber: @JohnReed

Added subscriber: @JohnReed

#57555 was marked as duplicate of this issue

#57555 was marked as duplicate of this issue

Added subscriber: @antoniov

Added subscriber: @antoniov

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

image.png

The preview works.

I can confirm in Windows that icons keep gray. Not sure if this is done by design or not. ![image.png](https://archive.blender.org/developer/F5151784/image.png) The preview works.
Member

Added subscribers: @brecht, @lichtwerk

Added subscribers: @brecht, @lichtwerk
Member

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

Same here (cycles, eevee, materials defined for OpenGl render engine dont get icons at all...), before digging deeper: @brecht: this is not by design, right?
Brecht Van Lommel changed title from Material Icons All Grey to Material preview icons not updating 2018-10-22 17:33:55 +02:00

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

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

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 Could you take a look?

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 Could you take a look?
Member

Added subscriber: @Kent-Davis

Added subscriber: @Kent-Davis

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.)
fancyMailBox.zip

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.) [fancyMailBox.zip](https://archive.blender.org/developer/F5322262/fancyMailBox.zip)
Member

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

@Kent-Davis : 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.

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

@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.

@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.

Added subscriber: @Sergey

Added subscriber: @Sergey

Actually I need @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.

Actually I need @Sergey's help. This is the patch I have: [P813](https://archive.blender.org/developer/P813.txt). 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.

This issue was referenced by 3e5483ffe1

This issue was referenced by 3e5483ffe10567731e3e84bb6f9ccc6ba1cdbce8

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
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
6 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#57316
No description provided.