Image Texture path failed to be imported as absolute after it was set to be relative and vice versa #109561

Closed
opened 2023-06-30 16:58:59 +02:00 by Andrej · 5 comments
Contributor

Blender 3.6

When you create image texture node in shader graph and import texture and save it by relative path

then you cannot import it and save it by absolute path anymore.

Way to reproduce:

  1. Create new .blend and save it.
  2. Go to shader graph and image texture node.
  3. Add texture to Image Texture node with "Open" button. Select some image and make sure "Relative Path" is set to True.
    Use you use the command C.active_object.active_material.node_tree.nodes['Image Texture'].image.filepath to see that it was imported as relative. Output will be like //diffuse.jpg.
    image
  4. Remove the texture
    image
  5. Try to import it again but set "Relative Path" to False.
    Run the command C.active_object.active_material.node_tree.nodes['Image Texture'].image.filepath it will still result in //diffuse.jpg because image was imported by relative path even though we set it to be absolute.
Blender 3.6 When you create image texture node in shader graph and import texture and save it by relative path then you cannot import it and save it by absolute path anymore. Way to reproduce: 1) Create new .blend and save it. 2) Go to shader graph and image texture node. 3) Add texture to Image Texture node with "Open" button. Select some image and make sure "Relative Path" is set to True. Use you use the command `C.active_object.active_material.node_tree.nodes['Image Texture'].image.filepath` to see that it was imported as relative. Output will be like `//diffuse.jpg`. ![image](/attachments/70fb3a9e-5935-4abb-954c-85fcbe768998) 4) Remove the texture ![image](/attachments/65572e69-b042-421d-a20c-b15edcdaf8f6) 5) Try to import it again but set "Relative Path" to False. Run the command ` C.active_object.active_material.node_tree.nodes['Image Texture'].image.filepath` it will still result in `//diffuse.jpg` because image was imported by relative path even though we set it to be absolute.
Andrej added the
Status
Needs Triage
Type
Report
Priority
Normal
labels 2023-06-30 16:59:00 +02:00
Member

I believe this is simply blender doesn't remove datablocks until closing/purging. Try Purging data after unlinking image datablock, then importing?

图片

I believe this is simply blender doesn't remove datablocks until closing/purging. Try Purging data after unlinking image datablock, then importing? ![图片](/attachments/10053e82-f8c5-41d9-bb40-10d1dce9d400)
Author
Contributor

@YimingWu it does work. But shouldn't it always prioritize the "relative path" flag from the dialog window over previous data block settings?

@YimingWu it does work. But shouldn't it always prioritize the "relative path" flag from the dialog window over previous data block settings?
Member

@pablovazquez Can we have a "prefer relative path" option in the user preference?

@pablovazquez Can we have a "prefer relative path" option in the user preference?
Member

Hi, codewise this is expected. If image data-block of same filepath is found in main storage then we use the existing image id.
A quick fix to change the file path will be:

diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 5fe20ab29df..8ad7ec5e0b0 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -1325,6 +1325,9 @@ static Image *image_open_single(Main *bmain,
       }
     }
   }
+  else {
+    STRNCPY(ima->filepath, range->filepath);
+  }

   return ima;
 }
Hi, codewise this is expected. If image data-block of same filepath is found in main storage then we use the existing image id. A quick fix to change the file path will be: ``` diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 5fe20ab29df..8ad7ec5e0b0 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1325,6 +1325,9 @@ static Image *image_open_single(Main *bmain, } } } + else { + STRNCPY(ima->filepath, range->filepath); + } return ima; } ```
Pratik Borhade added
Status
Needs Info from Developers
and removed
Status
Needs Triage
labels 2023-07-03 13:32:18 +02:00
Pratik Borhade self-assigned this 2023-07-03 13:32:26 +02:00
Member

@pablovazquez Can we have a "prefer relative path" option in the user preference?

You mean adding a new preference? I think it should just respect whatever setting is set in the dialog.

> @pablovazquez Can we have a "prefer relative path" option in the user preference? You mean adding a new preference? I think it should just respect whatever setting is set in the dialog.
Blender Bot added
Status
Resolved
and removed
Status
Needs Info from Developers
labels 2023-09-02 07:20:06 +02: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
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#109561
No description provided.