Texture baking fails when using a "material_index" attribute and values assigned to faces refrerence a non-existent material slot #102214

Closed
opened 2022-11-01 19:39:19 +01:00 by kursad k · 15 comments
Member

System Information
Operating system: Windows 11
Graphics card:

Blender Version
Broken: 3.3, 3.4

Short description of error

This thing tries to bake from a non existing material slot, the mesh has a material_index attribute and all faces have it set to 1
{F13841290 size=full}

When the attribute is removed (or set to zero on all faces, OR if you have a second material slot with a valid material) then this works.

Rendering itself seems to ignore the "invalid" material_index (or just falls back to the first existing, havent checked)

image.png

Exact steps for others to reproduce the error

from scratch:

  • defaut cube
  • add GN nodetree
  • add Set Material index node (set to an index of your liking)
  • apply modifier

OR for example:

  • default cube
  • add a second material slot
  • assign some faces to the second material slot (will create the attribute)
  • remove the second material slot again

Original report:
Load the .blend file

Select the object

Select the "BAKE" node

Render Properties -> Bake

The image comes out black

bake_bug_01112022_1321_56.zip

**System Information** Operating system: Windows 11 Graphics card: **Blender Version** Broken: 3.3, 3.4 **Short description of error** This thing tries to bake from a non existing material slot, the mesh has a `material_index` attribute and all faces have it set to 1 {[F13841290](https://archive.blender.org/developer/F13841290/image.png) size=full} When the attribute is removed (or set to zero on all faces, OR if you have a second material slot with a valid material) then this works. Rendering itself seems to ignore the "invalid" `material_index` (or just falls back to the first existing, havent checked) ![image.png](https://archive.blender.org/developer/F13834655/image.png) **Exact steps for others to reproduce the error** from scratch: - defaut cube - add GN nodetree - add Set Material index node (set to an index of your liking) - apply modifier OR for example: - default cube - add a second material slot - assign some faces to the second material slot (will create the attribute) - remove the second material slot again Original report: Load the .blend file Select the object Select the "BAKE" node Render Properties -> Bake The image comes out black [bake_bug_01112022_1321_56.zip](https://archive.blender.org/developer/F13834652/bake_bug_01112022_1321_56.zip)
Author
Member

Added subscriber: @kursadk

Added subscriber: @kursadk
Member

Added subscriber: @PratikPB2123

Added subscriber: @PratikPB2123
Member

Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'

Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'
Member

Thanks for the report. I'm able to redo this. May not be a bug but I'm unable to find the cause. So forwarding reports to developers.

Thanks for the report. I'm able to redo this. May not be a bug but I'm unable to find the cause. So forwarding reports to developers.
Member

Added subscribers: @HooglyBoogly, @brecht, @lichtwerk

Added subscribers: @HooglyBoogly, @brecht, @lichtwerk
Member

This thing tries to bake from a non existing material slot, the mesh has a material_index attribute and all faces have it set to 1
{F13841290 size=full}

When the attribute is removed (or set to zero on all faces, OR if you have a second material slot with a valid material) then this works.

Rendering itself seems to ignore the "invalid" material_index (or just falls back to the first existing, havent checked)

CC @HooglyBoogly
CC @brecht

This thing tries to bake from a non existing material slot, the mesh has a `material_index` attribute and all faces have it set to 1 {[F13841290](https://archive.blender.org/developer/F13841290/image.png) size=full} When the attribute is removed (or set to zero on all faces, OR if you have a second material slot with a valid material) then this works. Rendering itself seems to ignore the "invalid" `material_index` (or just falls back to the first existing, havent checked) CC @HooglyBoogly CC @brecht
Philipp Oeser changed title from Blender fails to bake textures to Texture baking fails when using a "material_index" attribute and values assigned to faces refrerence a non-existent material slot 2022-11-02 13:41:42 +01:00
Author
Member

@lichtwerk Thanks for investigating it. I think the material index is set to 1 because the mesh originally had multiple materials (which was imported as Alembic) and I deleted others and kept only one. I do not know why the material index attr would left a such residue.

@lichtwerk Thanks for investigating it. I think the material index is set to 1 because the mesh originally had multiple materials (which was imported as Alembic) and I deleted others and kept only one. I do not know why the material index attr would left a such residue.

Changed status from 'Needs Developer To Reproduce' to: 'Confirmed'

Changed status from 'Needs Developer To Reproduce' to: 'Confirmed'
Member

@kursadk Is there any chance you could give the specific steps that got the material index attribute into this state? Blender should be able to avoid this, and I think that's probably the best fix for this bug.

@kursadk Is there any chance you could give the specific steps that got the material index attribute into this state? Blender should be able to avoid this, and I think that's probably the best fix for this bug.
Member

@HooglyBoogly, for example :

  • defaut cube
  • add GN nodetree
  • add Set Material index node (set to an index of your liking)
  • apply modifier

OR for example:

  • default cube
  • add a second material slot
  • assign some faces to the second material slot (will create the attribute)
  • remove the second material slot again
@HooglyBoogly, for example : - defaut cube - add GN nodetree - add Set Material index node (set to an index of your liking) - apply modifier OR for example: - default cube - add a second material slot - assign some faces to the second material slot (will create the attribute) - remove the second material slot again

This issue was referenced by dd7a10e5a5

This issue was referenced by dd7a10e5a5f15fac6d0c06f49dc1f2e59637f7ec

This issue was referenced by 1fbb1d8cf6

This issue was referenced by 1fbb1d8cf6ea9badd3361e4c533625f569d14734

I assumed this was a regression given the recent material index changes and versions mentioned in the description, but actually it seems not to be a new issue. So lowering the priority.

I think we should have consistent logic for how to deal with material index that exceeds the number of materials. I'll commit a fix for that.

@HooglyBoogly feel free to re-open if you want to work on ensuring the material indices are always within the range. Doing that for geometry nodes might be inconvenient for users or introduce some performance overhead though, not sure it's worth it.

I assumed this was a regression given the recent material index changes and versions mentioned in the description, but actually it seems not to be a new issue. So lowering the priority. I think we should have consistent logic for how to deal with material index that exceeds the number of materials. I'll commit a fix for that. @HooglyBoogly feel free to re-open if you want to work on ensuring the material indices are always within the range. Doing that for geometry nodes might be inconvenient for users or introduce some performance overhead though, not sure it's worth it.
Member

Thanks Brecht.

I think we should never allow users to write negative indices anywhere. Geometry nodes should already do that.
But positive indices should be allowed, if you want to set them directly anyway. Most higher-level tools should probably be able to avoid creating these dangling indices though. There's probably some room to improve that in various places.

Thanks Brecht. I think we should never allow users to write negative indices anywhere. Geometry nodes should already do that. But positive indices should be allowed, if you want to set them directly anyway. Most higher-level tools should probably be able to avoid creating these dangling indices though. There's probably some room to improve that in various places.

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Brecht Van Lommel self-assigned this 2022-11-09 18:14:21 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
FBX
Interest
Freestyle
Interest
Geometry Nodes
Interest
glTF
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 & 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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
Asset System
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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#102214
No description provided.