TexturePaint -> Texture Slot can not be selected #62209

Closed
opened 2019-03-05 12:18:06 +01:00 by Andreas Esau · 11 comments
Member

System Information
Operating system: Windows

Blender Version
Broken:
(example: 2.80, 1df6a98b17, blender2.8, 2019-03-05)
Worked: (7d792976e1)

Short description of error
As soon as a Material uses node groups with ImageTexture Nodes, those image textures cannot be selected from the TextureSlot Dropdown.
Also please refer to my comment here:
https://developer.blender.org/rBda1323d1c95095feff98e8aa054d73fd323c363d#221015

Exact steps for others to reproduce the error
Create Suzanne. Go into Texture Paint Tab. Create two texture slots. -> selection works.
Open Shader Editor. Group those 2 textures into a new group. -> selection doesn't work.
BlenderTexturePaintSlotBug.blend

**System Information** Operating system: Windows **Blender Version** Broken: (example: 2.80, 1df6a98b17, blender2.8, 2019-03-05) Worked: (7d792976e100) **Short description of error** As soon as a Material uses node groups with ImageTexture Nodes, those image textures cannot be selected from the TextureSlot Dropdown. Also please refer to my comment here: https://developer.blender.org/rBda1323d1c95095feff98e8aa054d73fd323c363d#221015 **Exact steps for others to reproduce the error** Create Suzanne. Go into Texture Paint Tab. Create two texture slots. -> selection works. Open Shader Editor. Group those 2 textures into a new group. -> selection doesn't work. [BlenderTexturePaintSlotBug.blend](https://archive.blender.org/developer/F6765504/BlenderTexturePaintSlotBug.blend)
Author
Member

Added subscriber: @ndee

Added subscriber: @ndee

studio/blender-studio#62219 was marked as duplicate of this issue

studio/blender-studio#62219 was marked as duplicate of this issue
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Confirmed, checking...

Confirmed, checking...

Added subscriber: @JulienKaspar

Added subscriber: @JulienKaspar

Added subscriber: @brecht

Added subscriber: @brecht

Recent changes uncovered an old issue here. The active paint slot index depends on the order of nodes, while ED_node_sort changes that order based on selection and active state, to ensure selected and active nodes always draw on top.

Recent changes uncovered an old issue here. The active paint slot index depends on the order of nodes, while `ED_node_sort` changes that order based on selection and active state, to ensure selected and active nodes always draw on top.
Member

could be wrong, but another thing [I think] is that the node is not actually set active when changing active_paint_slot_index (when inside a group)?, which is something the code seems to rely on
[patch below will let me select one of the slots inside the group... on the other hand this was working before @brecht 's commit, so might be utter nonsense, will check more tomorrow...]
P921: T62209_snippet



diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index ca0e58a0f5a..6d9d17ba935 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -135,6 +135,20 @@ static void rna_Material_texpaint_begin(CollectionPropertyIterator *iter, Pointe
 	rna_iterator_array_begin(iter, (void *)ma->texpaintslot, sizeof(TexPaintSlot), ma->tot_slots, 0, NULL);
 }
 
+void set_node_active_recursive(bNodeTree *nodetree, Material *ma, int *index)
+{
+	for (bNode *node = nodetree->nodes.first; node; node = node->next) {
+		if (node->typeinfo->nclass == NODE_CLASS_TEXTURE && node->typeinfo->type == SH_NODE_TEX_IMAGE && node->id) {
+			if ((*index)++ == ma->paint_active_slot) {
+				nodeSetActive(ma->nodetree, node);
+				break;
+			}
+		}
+		else if (node->type == NODE_GROUP) {
+			set_node_active_recursive((bNodeTree *)node->id, ma, index);
+		}
+	}
+}
 
 static void rna_Material_active_paint_texture_index_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 {
@@ -142,17 +156,8 @@ static void rna_Material_active_paint_texture_index_update(Main *bmain, Scene *s
 	Material *ma = ptr->id.data;
 
 	if (ma->use_nodes && ma->nodetree) {
-		struct bNode *node;
 		int index = 0;
-		for (node = ma->nodetree->nodes.first; node; node = node->next) {
-			if (node->typeinfo->nclass == NODE_CLASS_TEXTURE && node->typeinfo->type == SH_NODE_TEX_IMAGE && node->id) {
-				if (index++ == ma->paint_active_slot) {
-					break;
-				}
-			}
-		}
-		if (node)
-			nodeSetActive(ma->nodetree, node);
+		set_node_active_recursive(ma->nodetree, ma, &index);
 	}
 
 	if (ma->texpaintslot) {
could be wrong, but another thing [I think] is that the node is not actually set active when changing active_paint_slot_index (when inside a group)?, which is something the code seems to rely on [patch below will let me select one of the slots inside the group... on the other hand this was working before @brecht 's commit, so might be utter nonsense, will check more tomorrow...] [P921: T62209_snippet](https://archive.blender.org/developer/P921.txt) ``` diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index ca0e58a0f5a..6d9d17ba935 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -135,6 +135,20 @@ static void rna_Material_texpaint_begin(CollectionPropertyIterator *iter, Pointe rna_iterator_array_begin(iter, (void *)ma->texpaintslot, sizeof(TexPaintSlot), ma->tot_slots, 0, NULL); } +void set_node_active_recursive(bNodeTree *nodetree, Material *ma, int *index) +{ + for (bNode *node = nodetree->nodes.first; node; node = node->next) { + if (node->typeinfo->nclass == NODE_CLASS_TEXTURE && node->typeinfo->type == SH_NODE_TEX_IMAGE && node->id) { + if ((*index)++ == ma->paint_active_slot) { + nodeSetActive(ma->nodetree, node); + break; + } + } + else if (node->type == NODE_GROUP) { + set_node_active_recursive((bNodeTree *)node->id, ma, index); + } + } +} static void rna_Material_active_paint_texture_index_update(Main *bmain, Scene *scene, PointerRNA *ptr) { @@ -142,17 +156,8 @@ static void rna_Material_active_paint_texture_index_update(Main *bmain, Scene *s Material *ma = ptr->id.data; if (ma->use_nodes && ma->nodetree) { - struct bNode *node; int index = 0; - for (node = ma->nodetree->nodes.first; node; node = node->next) { - if (node->typeinfo->nclass == NODE_CLASS_TEXTURE && node->typeinfo->type == SH_NODE_TEX_IMAGE && node->id) { - if (index++ == ma->paint_active_slot) { - break; - } - } - } - if (node) - nodeSetActive(ma->nodetree, node); + set_node_active_recursive(ma->nodetree, ma, &index); } if (ma->texpaintslot) { ```

That indeed needs to be solved as well. The patch seems fine to commit to solve the most immediate problem.

It does not solve the entire issue but those bugs may go back to 2.7, I can look at that later with lower priority.

That indeed needs to be solved as well. The patch seems fine to commit to solve the most immediate problem. It does not solve the entire issue but those bugs may go back to 2.7, I can look at that later with lower priority.

This issue was referenced by a261d6f2d3

This issue was referenced by a261d6f2d3feb80efb51b27aa7cae56ea6c4c57d

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
4 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#62209
No description provided.