Image data not properly duplicated in node_shader_utils.py #81834

Closed
opened 2020-10-19 10:58:51 +02:00 by TZ · 10 comments

System Information
Operating system: Windows 10
Graphics card: NVIDIA Quadpro P4000

Blender Version
Broken: 2.90.1

Short description of error
There seems to be a bug in [node_shader_utils.py ]], possibly introduced in [ https:*developer.blender.org/rBd89b65cc91a63544168b5330ba1a288f5c826e15 | this commit . Around line 700, in the image property setter, the third if statement compares is_data again, instead of the colorspace name:

    @_set_check
    def image_set(self, image):
        if self.colorspace_is_data is not ...:
            if image.colorspace_settings.is_data != self.colorspace_is_data and image.users >= 1:
                image = image.copy()
            image.colorspace_settings.is_data = self.colorspace_is_data
        if self.colorspace_name is not ...:
            if image.colorspace_settings.is_data != self.colorspace_is_data and image.users >= 1: // Should this not compare names?
                image = image.copy()
            image.colorspace_settings.name = self.colorspace_name
        self.node_image.image = image

Exact steps for others to reproduce the error
Run the script below:

import bpy
from bpy_extras.node_shader_utils import PrincipledBSDFWrapper
from bpy_extras.image_utils import load_image

# load an image
blender_image = load_image('c:\\tmp\\image.png', check_existing=True)
blender_material = bpy.data.materials.new(name='Material_1')
blender_principled = PrincipledBSDFWrapper(blender_material, is_readonly=False)
blender_principled.specular_texture.image = blender_image
blender_material2 = bpy.data.materials.new(name='Material_2')
blender_principled2 = PrincipledBSDFWrapper(blender_material, is_readonly=False)
blender_principled2.specular_texture.image = blender_image
**System Information** Operating system: Windows 10 Graphics card: NVIDIA Quadpro P4000 **Blender Version** Broken: 2.90.1 **Short description of error** There seems to be a bug in [node_shader_utils.py ]], possibly introduced in [[ https:*developer.blender.org/rBd89b65cc91a63544168b5330ba1a288f5c826e15 | this commit ](https:*developer.blender.org/diffusion/B/browse/master/release/scripts/modules/bpy_extras/node_shader_utils.py). Around line 700, in the image property setter, the third if statement compares is_data again, instead of the colorspace name: ``` @_set_check def image_set(self, image): if self.colorspace_is_data is not ...: if image.colorspace_settings.is_data != self.colorspace_is_data and image.users >= 1: image = image.copy() image.colorspace_settings.is_data = self.colorspace_is_data if self.colorspace_name is not ...: if image.colorspace_settings.is_data != self.colorspace_is_data and image.users >= 1: // Should this not compare names? image = image.copy() image.colorspace_settings.name = self.colorspace_name self.node_image.image = image ``` **Exact steps for others to reproduce the error** Run the script below: ``` import bpy from bpy_extras.node_shader_utils import PrincipledBSDFWrapper from bpy_extras.image_utils import load_image # load an image blender_image = load_image('c:\\tmp\\image.png', check_existing=True) blender_material = bpy.data.materials.new(name='Material_1') blender_principled = PrincipledBSDFWrapper(blender_material, is_readonly=False) blender_principled.specular_texture.image = blender_image blender_material2 = bpy.data.materials.new(name='Material_2') blender_principled2 = PrincipledBSDFWrapper(blender_material, is_readonly=False) blender_principled2.specular_texture.image = blender_image ```
Author

Added subscriber: @ttass

Added subscriber: @ttass
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'
Member

I think you are right, just to make sure:
Could you throw together a simple example that exposes this bug?

I think you are right, just to make sure: Could you throw together a simple example that exposes this bug?
Author

Assuming there is a file image.png located in C:/tmp, this will result in two images being created:

from bpy_extras.node_shader_utils import PrincipledBSDFWrapper
from bpy_extras.image_utils import load_image
import bpy
# load an image
blender_image = load_image('c:\\tmp\\image.png', check_existing=True)
blender_material = bpy.data.materials.new(name='Material_1')
blender_principled = PrincipledBSDFWrapper(blender_material, is_readonly=False)
blender_principled.specular_texture.image = blender_image
blender_material2 = bpy.data.materials.new(name='Material_2')
blender_principled2 = PrincipledBSDFWrapper(blender_material, is_readonly=False)
blender_principled2.specular_texture.image = blender_image
Assuming there is a file image.png located in C:/tmp, this will result in two images being created: ``` from bpy_extras.node_shader_utils import PrincipledBSDFWrapper from bpy_extras.image_utils import load_image import bpy # load an image blender_image = load_image('c:\\tmp\\image.png', check_existing=True) blender_material = bpy.data.materials.new(name='Material_1') blender_principled = PrincipledBSDFWrapper(blender_material, is_readonly=False) blender_principled.specular_texture.image = blender_image blender_material2 = bpy.data.materials.new(name='Material_2') blender_principled2 = PrincipledBSDFWrapper(blender_material, is_readonly=False) blender_principled2.specular_texture.image = blender_image ```

Changed status from 'Needs User Info' to: 'Confirmed'

Changed status from 'Needs User Info' to: 'Confirmed'

Added subscriber: @Meda

Added subscriber: @Meda

Can this be a good first issue? I am new to open-source and would like to take this up.

Can this be a good first issue? I am new to open-source and would like to take this up.

This issue was referenced by 4b7b4efd5b

This issue was referenced by 4b7b4efd5be6c2c06f6f257c07f429aede7ddc0f

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Campbell Barton self-assigned this 2021-01-27 08:19:52 +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
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#81834
No description provided.