Geometry nodes material index attribute not working correctly on generated/instanced geometry #87335

Open
opened 2021-04-09 12:31:18 +02:00 by Simon Thommes · 22 comments
Member

System Information
Operating system: Linux-5.8.0-7630-generic-x86_64-with-glibc2.32 64 Bits
Graphics card: Quadro RTX 6000/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 460.32.03

Blender Version
Broken: version: 2.93.0 Alpha, branch: master, commit date: 2021-04-08 17:19, hash: 1ec9ac2016
FYI, the history on this:
prior to 1a81d268a1 this was working in editmode (but not objectmode)
after 1a81d268a1 no material was shown in the viewport at all
then with 6583fb67c6 we had first material showing again, but setting index was not working in either objectmode nor editmode

Short description of error
changing the material_index attribute does not seem to have an effect on created/instanced data, even though the material index seems to change accurately in the spreadsheet and the material slots are set to Object type. What is especially strange about this is that the issue does not persist for cycles rendering.
geo-nodes_material_index_bug-2021-04-09_12.25.49.mp4
(same for geometry generated with a primitive node)

Exact steps for others to reproduce the error
Original file:
geo-nodes_material_index_viewport.blend

Updated to fields:
geo-nodes_material_index_viewport.blend

**System Information** Operating system: Linux-5.8.0-7630-generic-x86_64-with-glibc2.32 64 Bits Graphics card: Quadro RTX 6000/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 460.32.03 **Blender Version** Broken: version: 2.93.0 Alpha, branch: master, commit date: 2021-04-08 17:19, hash: `1ec9ac2016` FYI, the history on this: prior to 1a81d268a1 this was working in editmode (but not objectmode) after 1a81d268a1 no material was shown in the viewport at all then with 6583fb67c6 we had first material showing again, but setting index was not working in either objectmode nor editmode **Short description of error** changing the material_index attribute does not seem to have an effect on created/instanced data, even though the material index seems to change accurately in the spreadsheet and the material slots are set to `Object` type. What is especially strange about this is that the issue does not persist for cycles rendering. [geo-nodes_material_index_bug-2021-04-09_12.25.49.mp4](https://archive.blender.org/developer/F9926700/geo-nodes_material_index_bug-2021-04-09_12.25.49.mp4) (same for geometry generated with a primitive node) **Exact steps for others to reproduce the error** Original file: [geo-nodes_material_index_viewport.blend](https://archive.blender.org/developer/F9926701/geo-nodes_material_index_viewport.blend) Updated to fields: [geo-nodes_material_index_viewport.blend](https://archive.blender.org/developer/F11777686/geo-nodes_material_index_viewport.blend)
Author
Member

Added subscriber: @SimonThommes

Added subscriber: @SimonThommes

#95417 was marked as duplicate of this issue

#95417 was marked as duplicate of this issue

#87786 was marked as duplicate of this issue

#87786 was marked as duplicate of this issue
Author
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Member

Added subscriber: @JacquesLucke

Added subscriber: @JacquesLucke
Member

Looks like the issue is that the material slots on the mesh and the object are not in sync. The number of material slots on the other object and on the grid mesh is zero. Eevee seems to check the number of materials, while cycles probably handles it differently. Since the number of materials on the mesh is zero, eevee does not look for materials on the object.
A workaround in your demo file is to add some material slots to the icosphere.

This commit fixes a related issue: 3de5fbba3a
Also related: #86737.

Looks like the issue is that the material slots on the mesh and the object are not in sync. The number of material slots on the other object and on the grid mesh is zero. Eevee seems to check the number of materials, while cycles probably handles it differently. Since the number of materials on the mesh is zero, eevee does not look for materials on the object. A workaround in your demo file is to add some material slots to the icosphere. This commit fixes a related issue: 3de5fbba3a Also related: #86737.
Contributor

Added subscriber: @Eary

Added subscriber: @Eary
Contributor

I encountered this problem a few weeks ago, and after discussion with my friends, we came to the conclusion that all we needed to do for solving the problem is this:
image.png

So basically the icosphere needs to have the same amount of slots (even empty slots count) as the geometry node object

EDIT: Ops, I didn't see Jacques' reply, I guess I am just repeating what he said, lol

I encountered this problem a few weeks ago, and after discussion with my friends, we came to the conclusion that all we needed to do for solving the problem is this: ![image.png](https://archive.blender.org/developer/F9926904/image.png) So basically the icosphere needs to have the same amount of slots (even empty slots count) as the geometry node object EDIT: Ops, I didn't see Jacques' reply, I guess I am just repeating what he said, lol

Added subscriber: @vasiln

Added subscriber: @vasiln

Note that this can also interact with instancing a collection. In this case, the workaround doesn't help (in 2.93.3 release.) It appears that the entire collection gets a set of materials that depends on the order that objects were created, or the order of input noodles in any join geometry nodes, or something else:

image.png

Here, it's getting the material of the first created object in the collection, rather than the materials of any other objects. Changing the material index assignment does nothing. I've renamed the first created object to "z" to see if it's alphabetic, but no, it appears to be creation order.

Change the noodles around and you get:

image.png

Now we're getting the material of the referenced object. Again, changing the material index assignment doesn't change anything.

It would be nice if instanced geometry inherited all materials of all instanced objects, as space permitted, so that we could do material assignments, but if that's not possible, choosing materials on the basis of noodle order or creation order is probably not a good way to do it. Creation order is especially poor, since there's no apparent way to change it without starting over from scratch.

Note that the material assignments aren't necessarily getting updated with changes to the geometry nodes, which can confuse some troubleshooting. Sometimes you need to drag some objects around to force recalculation of nodes. It also happens that the geometry nodes show different materials when the node object is in edit vs object mode.

Note that this can also interact with instancing a collection. In this case, the workaround doesn't help (in 2.93.3 release.) It appears that the entire collection gets a set of materials that depends on the order that objects were created, or the order of input noodles in any join geometry nodes, or something else: ![image.png](https://archive.blender.org/developer/F10288001/image.png) Here, it's getting the material of the first created object in the collection, rather than the materials of any other objects. Changing the material index assignment does nothing. I've renamed the first created object to "z" to see if it's alphabetic, but no, it appears to be creation order. Change the noodles around and you get: ![image.png](https://archive.blender.org/developer/F10288003/image.png) Now we're getting the material of the referenced object. Again, changing the material index assignment doesn't change anything. It would be nice if instanced geometry inherited all materials of all instanced objects, as space permitted, so that we could do material assignments, but if that's not possible, choosing materials on the basis of noodle order or creation order is probably not a good way to do it. Creation order is especially poor, since there's no apparent way to change it without starting over from scratch. Note that the material assignments aren't necessarily getting updated with changes to the geometry nodes, which can confuse some troubleshooting. Sometimes you need to drag some objects around to force recalculation of nodes. It also happens that the geometry nodes show different materials when the node object is in edit vs object mode.
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Note that this works in editmode afaics.

Note that this works in editmode afaics.
Philipp Oeser changed title from Geometry nodes material index attribute not working correctly on generated/instanced geometry to Geometry nodes material index attribute not working correctly on generated/instanced geometry (in objectmode, editmode is fine) 2021-08-20 09:44:02 +02:00
Member

Added subscriber: @NahuelBelich

Added subscriber: @NahuelBelich
Member

In #87335#1208813, @lichtwerk wrote:
Note that this works in editmode afaics.

Correction: this is only true for 2.93 LTS, in 3.0, this does not work in either object or editmode

> In #87335#1208813, @lichtwerk wrote: > Note that this works in editmode afaics. Correction: this is only true for 2.93 LTS, in 3.0, this does not work in either object or editmode
Member

FYI, the history on this:
prior to 1a81d268a1 this was working in editmode (but not objectmode)
after 1a81d268a1 no material was shown in the viewport at all
then with 6583fb67c6 we had first material showing again, but setting index was not working in either objectmode nor editmode

FYI, the history on this: prior to 1a81d268a1 this was working in editmode (but not objectmode) after 1a81d268a1 no material was shown in the viewport at all then with 6583fb67c6 we had first material showing again, but setting index was not working in either objectmode nor editmode
Philipp Oeser changed title from Geometry nodes material index attribute not working correctly on generated/instanced geometry (in objectmode, editmode is fine) to Geometry nodes material index attribute not working correctly on generated/instanced geometry 2021-08-20 11:17:45 +02:00
Hans Goudey was assigned by Jacques Lucke 2021-11-22 16:47:09 +01:00
Member

@HooglyBoogly : are we still keeping reports for the "legacy" nodes?

@HooglyBoogly : are we still keeping reports for the "legacy" nodes?

Added subscriber: @crowe

Added subscriber: @crowe

I'd just like to let you know this bug still happens with the new nodes. Set Material Index doesn't affect generated or instanced geometry, nor does the new Named Attribute node from the builds with "material_index" as the attribute—this one will crash Blender.

My guess is that generated/instanced geometry has a separate list of materials which is out of sync with the object's material slots. It's logic is wild and with more materials it can be hard to keep track of.

Examples:

  • 2 material slots (idx 0-1). Initially the problematic geometry will be only able to be index 0.

  1. Add a Set Material node before the Set Material Index. Set the material to any material not used in this object. Now Set Material Index works correctly for indexes 0 and 1, ignoring what's in Set Material to adhere to the object's material slot list.
    geonodes_mindex-tree_01.jpg
    geonodes_mindex_01.jpg
  • 4 material slots (idx 0-3)

  1. Set Material to the last material slot.
  2. Repeat with the second last.
  3. Now do like in the other example, setting it to a material not in this object.
    geonodes_mindex-tree_03.jpg
    geonodes_mindex_03.jpg

As long you don't repeat materials, it works. You can use only materials not in the object, only materials in the object but out of other, or mix them.

Without using Set Material Index to pick the material, you always get the highest index the geometry tree allows. Whether the material it'll be drawn from the object data or the geometry node depends on the number of slots created by geo nodes.
geonodes_mindex-tree_02.jpg
Results...
a) 2 slots x tree with 2 materials not in obj = slot 2 mat
b) 2 slots x 1 material not in obj = slot 1 mat
c) 2 slots x 3 materials not in obj = overwritten by Set Material's mat (idx higher than original slots)
geonodes_mindex_02.jpg

I'd just like to let you know this bug still happens with the new nodes. **Set Material Index** doesn't affect generated or instanced geometry, nor does the new **Named Attribute** node from the builds with "material_index" as the attribute—this one will crash Blender. My guess is that generated/instanced geometry has a separate list of materials which is out of sync with the object's material slots. It's logic is wild and with more materials it can be hard to keep track of. Examples: - > 2 material slots (idx 0-1). Initially the problematic geometry will be only able to be index 0. 1. Add a **Set Material** node before the **Set Material Index**. Set the material to *any* material not used in this object. ***Now Set Material Index works correctly for indexes 0 and 1***, ignoring what's in **Set Material** to adhere to the object's material slot list. ![geonodes_mindex-tree_01.jpg](https://archive.blender.org/developer/F13058577/geonodes_mindex-tree_01.jpg) ![geonodes_mindex_01.jpg](https://archive.blender.org/developer/F13058569/geonodes_mindex_01.jpg) - > 4 material slots (idx 0-3) 1. **Set Material** to the last material slot. 2. Repeat with the second last. 3. Now do like in the other example, setting it to a material not in this object. ![geonodes_mindex-tree_03.jpg](https://archive.blender.org/developer/F13058579/geonodes_mindex-tree_03.jpg) ![geonodes_mindex_03.jpg](https://archive.blender.org/developer/F13058573/geonodes_mindex_03.jpg) As long you don't repeat materials, it works. You can use only materials not in the object, only materials in the object but out of other, or mix them. Without using **Set Material Index** to pick the material, you always get the highest index the geometry tree allows. Whether the material it'll be drawn from the object data or the geometry node depends on the number of slots created by geo nodes. ![geonodes_mindex-tree_02.jpg](https://archive.blender.org/developer/F13058587/geonodes_mindex-tree_02.jpg) Results... a) 2 slots x tree with 2 materials not in obj = slot 2 mat b) 2 slots x 1 material not in obj = slot 1 mat c) 2 slots x 3 materials not in obj = overwritten by Set Material's mat (idx higher than original slots) ![geonodes_mindex_02.jpg](https://archive.blender.org/developer/F13058588/geonodes_mindex_02.jpg)

Added subscribers: @Erindale, @PratikPB2123

Added subscribers: @Erindale, @PratikPB2123

Added subscriber: @Shiki-1

Added subscriber: @Shiki-1

Added subscriber: @Yevtushenko-Oleksandr

Added subscriber: @Yevtushenko-Oleksandr
Hans Goudey removed their assignment 2022-10-17 19:40:00 +02:00
Member

Added subscriber: @HooglyBoogly

Added subscriber: @HooglyBoogly
Philipp Oeser removed the
Interest
Nodes & Physics
label 2023-02-10 08:44:53 +01:00
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
11 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#87335
No description provided.