Texture node editor header is not in sync with edited texture when used with node materials #39868

Closed
opened 2014-04-23 23:02:42 +02:00 by Willi · 13 comments

System Information
Win 7/64, AMD HD 6850

Blender Version
since 2.63

Short description of error
see title

Exact steps for others to reproduce the error
Open TxtNodeEditor.blend (including UI).
Description of the scene: The default cube/mesh has two materials:

  • Material.001 is a normal material (no nodes)
  • Material.002 is a node material. It contains a material node referencing Material.003.

Steps:

  • In the material properties panel, select Material.001
  • Switch to the texture properties panel: It has two textures assigned.

Select Texture.001 and Texture.002 alternatively: The Texture nodes editor correctly switches between the two node textures. This is labeld in the bottom left of the window. In addition, in the header, the combobox shows the currently selected texture. If you select the 3rd texture slot which is still empty, the header correctly shows no current texture.

So far, so good. Now, what does not work in opposite:

  • In the material properties panel, select Material.002
  • In the material nodes editor, select the material node

In the properties window, switch to the texture panel: It has two textures assigned. As you see at the top of the window: "Cube -> Material.002 -> Material.003", so we should be working with the texture slots of Material.003 now. Problem: This does not work identically to working with the texture slots of Material.001 as we did above regarding the header of the texture nodes window: It does not display and manage the texture of the currently selected texture slot of Material.003. Instead it is (probably) managing the textures of the superordinated Material.002. In any case the header is not in sync with the content of the correctly displayed nodes in the window.

**System Information** Win 7/64, AMD HD 6850 **Blender Version** since 2.63 **Short description of error** see title **Exact steps for others to reproduce the error** Open [TxtNodeEditor.blend](https://archive.blender.org/developer/F85761/TxtNodeEditor.blend) (including UI). Description of the scene: The default cube/mesh has two materials: - Material.001 is a normal material (no nodes) - Material.002 is a node material. It contains a material node referencing Material.003. Steps: - In the material properties panel, select Material.001 - Switch to the texture properties panel: It has two textures assigned. # Select Texture.001 and Texture.002 alternatively: The Texture nodes editor correctly switches between the two node textures. This is labeld in the bottom left of the window. In addition, in the header, the combobox shows the currently selected texture. If you select the 3rd texture slot which is still empty, the header correctly shows no current texture. So far, so good. Now, what does not work in opposite: - In the material properties panel, select Material.002 - In the material nodes editor, select the material node # In the properties window, switch to the texture panel: It has two textures assigned. As you see at the top of the window: "Cube -> Material.002 -> Material.003", so we should be working with the texture slots of Material.003 now. Problem: This does *not* work identically to working with the texture slots of Material.001 as we did above regarding the header of the texture nodes window: It does not display and manage the texture of the currently selected texture slot of Material.003. Instead it is (probably) managing the textures of the superordinated Material.002. In any case the header is not in sync with the content of the correctly displayed nodes in the window.
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @willi-2

Added subscriber: @willi-2
Author

Pictures say more than words...:
Bild_311.JPG
The marked combo is what I'm talking about. I expect Texture.003 to be selected there like it is shown and labeled in the window, and selecting a different texture in that combo should assign it to the selected texture slot of Material.003

Pictures say more than words...: ![Bild_311.JPG](https://archive.blender.org/developer/F85763/Bild_311.JPG) The marked combo is what I'm talking about. I expect Texture.003 to be selected there like it is shown and labeled in the window, and selecting a different texture in that combo should assign it to the selected texture slot of Material.003

Added subscriber: @mont29

Added subscriber: @mont29
Member

Added subscriber: @LukasTonne

Added subscriber: @LukasTonne
Member

This is because of the convoluted nesting of materials and textures in nodes vs. plain stacks ...

What is displayed in the header is the texture's material's "active_texture" property. In the case of a "classic" stack-based material this is the texture slot (which works fine). But for node materials it instead uses the active node and then if that is a texture node displays that node's texture reference ... So without having a texture node selected in the material nodes it won't show a texture in the header either, and will never use the stack ...

I'm not yet sure how to properly disentangle this mess, it's a creepy web of legacy design issues.

This is because of the convoluted nesting of materials and textures in nodes vs. plain stacks ... What is displayed in the header is the texture's material's "active_texture" property. In the case of a "classic" stack-based material this is the texture slot (which works fine). But for node materials it instead uses the active node and then **if** that is a texture node displays that node's texture reference ... So without having a texture node selected in the material nodes it won't show a texture in the header either, and will never use the stack ... I'm not yet sure how to properly disentangle this mess, it's a creepy web of legacy design issues.
Lukas Tönne was assigned by Sergey Sharybin 2014-04-28 10:11:58 +02:00

Added subscriber: @Sergey

Added subscriber: @Sergey

Consider this a TODO then?

Consider this a TODO then?
Member

Have been looking into this and found a lot of bad stuff under the surface ...

The Material.active_texture property, which is displayed in the texture nodes header, has inconsistent behavior:

*# get checks if nodes are used, then looks up the active node and its texture pointer, otherwise returns the stack texture slot (correct)
*# set checks if nodes are used, but if it cannot find an active texture node it will fall back to setting the active texture stack slot! This is not transparent and confusing to users.
*# editable does the same as set: if nodes are used and no active texture node is found, it will return true anyway, assuming a texture slot will be set instead. This means that the tex node header button does not get grayed out, which would at least indicate there is something missing (no active tex node).

What's more: The function for looking up the active texture node (nodeGetActiveID) only returns a node if the texture is actually non-NULL (https://developer.blender.org/diffusion/B/browse/master/source/blender/blenkernel/intern/node.c$2352). What this means is that active_texture can never work properly for setting a texture node's texture pointer for the first time!

It all goes totally nuts if you consider nesting of materials inside material nodes, mixing stack- and node-based materials/textures etc. I don't even dare think about what impossible cases could come up here ...

Have been looking into this and found a lot of bad stuff under the surface ... # The Material.active_texture property, which is displayed in the texture nodes header, has inconsistent behavior: *# `get` checks if nodes are used, then looks up the active node and its texture pointer, otherwise returns the stack texture slot (correct) *# `set` checks if nodes are used, but if it cannot find an active texture node it will fall back to setting the active texture stack slot! This is not transparent and confusing to users. *# `editable` does the same as `set`: if nodes are used and no active texture node is found, it will return true anyway, assuming a texture slot will be set instead. This means that the tex node header button does not get grayed out, which would at least indicate there is something missing (no active tex node). What's more: The function for looking up the active texture node (`nodeGetActiveID`) only returns a node if the texture *is actually non-NULL* (https://developer.blender.org/diffusion/B/browse/master/source/blender/blenkernel/intern/node.c$2352). What this means is that active_texture can never work properly for setting a texture node's texture pointer for the first time! It all goes totally nuts if you consider nesting of materials inside material nodes, mixing stack- and node-based materials/textures etc. I don't even dare think about what impossible cases could come up here ...

@LukasTonne, do you need some help here?

@LukasTonne, do you need some help here?
Member

@Sergey i was going to unify the get/set/editable behavior, such that if use_nodes is true, it would never even look at the stack slots (so that a material is either nodes or stack, not some weird mixture). However this could easily break some cases, this stuff is used in so many places.

And then i found out about the nodeGetActiveID and realized this couldn't even work the way i expected it to ...

So atm i'm thinking "never ever touch this, it will break more than it could fix". If you have a clear idea of how this should work, be my guest and give it a shot.

@Sergey i was going to unify the get/set/editable behavior, such that if use_nodes is true, it would never even look at the stack slots (so that a material is either nodes or stack, not some weird mixture). However this could easily break some cases, this stuff is used in so many places. And then i found out about the `nodeGetActiveID` and realized this couldn't even work the way i expected it to ... So atm i'm thinking "never ever touch this, it will break more than it could fix". If you have a clear idea of how this should work, be my guest and give it a shot.
Member

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Member

Closing as archived, this area of the code is too encrusted with old hacks and fragile use cases to justify breaking it for a non-showstopper ...

Closing as archived, this area of the code is too encrusted with old hacks and fragile use cases to justify breaking it for a non-showstopper ...
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#39868
No description provided.