USD image assets paths are not resolved in a cross platform manner #97362

Closed
opened 2022-04-15 18:34:45 +02:00 by Jamie Cope · 23 comments

USD files exported with image assets on Windows can't be loaded on Linux and vice versa. The same happens with Windows and MacOS.

Original Report

System Information
Operating system: Windows-10-10.0.19044-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 3080 Laptop GPU/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 466.42

Blender Version
Broken: version: 3.1.2, branch: master, commit date: 2022-03-31 17:40, hash: cc66d1020c
Worked: (newest version of Blender that worked as expected)

Short description of error

USD Exporter is using back slashes for texture paths. When zipped to a usdz, this causes MacOS/Quicklook to fail loading the texture. If forward slashes are used, loading works as expected.

Exact steps for others to reproduce the error

  • Add a diffuse texture to default cube

  • Export as usda with textures and relative texture paths

  • Zip usda and texture folder to usdz (no compression)

  • Try to preview with Quicklook - no texture

  • Redo above steps but edit usda to use forward slashes before zipping and preview works as expected with texture.

USD files exported with image assets on Windows can't be loaded on Linux and vice versa. The same happens with Windows and MacOS. **Original Report** **System Information** Operating system: Windows-10-10.0.19044-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 3080 Laptop GPU/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 466.42 **Blender Version** Broken: version: 3.1.2, branch: master, commit date: 2022-03-31 17:40, hash: `cc66d1020c` Worked: (newest version of Blender that worked as expected) **Short description of error** USD Exporter is using back slashes for texture paths. When zipped to a usdz, this causes MacOS/Quicklook to fail loading the texture. If forward slashes are used, loading works as expected. **Exact steps for others to reproduce the error** - Add a diffuse texture to default cube - Export as usda with textures and relative texture paths - Zip usda and texture folder to usdz (no compression) - Try to preview with Quicklook - no texture - Redo above steps but edit usda to use forward slashes before zipping and preview works as expected with texture.
Author

Added subscriber: @copeg

Added subscriber: @copeg
Member

Added subscriber: @PratikPB2123

Added subscriber: @PratikPB2123
Member

Added subscriber: @OmarEmaraDev

Added subscriber: @OmarEmaraDev
Member

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

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

Can you attach a small sample file with back slashes for us to debug this better?

Can you attach a small sample file with back slashes for us to debug this better?
Author

usd_test.zip

Sure, here is the default cube with a texture exported as .usda along with the textures folder and texture.

[usd_test.zip](https://archive.blender.org/developer/F13102973/usd_test.zip) Sure, here is the default cube with a texture exported as .usda along with the textures folder and texture.
Member

So apparently I can't import that file back into Blender on Linux or Mac due to the Windows-like paths. So that's different already a problem.

WARNING: Couldn't resolve image asset '@.\textures\scene-image-medium.jpg@' for Texture Image node.

The question is, can UNIX-like paths import into Blender on Windows?
Can you try that? Does the edited usda with forward slashes import back into Blender on Windows for you?

                asset inputs:file = @./textures/scene-image-medium.jpg@
So apparently I can't import that file back into Blender on Linux or Mac due to the Windows-like paths. So that's different already a problem. ``` WARNING: Couldn't resolve image asset '@.\textures\scene-image-medium.jpg@' for Texture Image node. ``` The question is, can UNIX-like paths import into Blender on Windows? Can you try that? Does the edited usda with forward slashes import back into Blender on Windows for you? ``` asset inputs:file = @./textures/scene-image-medium.jpg@ ```
Author

I'm not getting any errors importing that file with either forward or backslashes on Windows, but either way it also doesn't seem to import the texture.

I'm not getting any errors importing that file with either forward or backslashes on Windows, but either way it also doesn't seem to import the texture.
Member

Just to double check, did you enable Import USD Preview when importing? Because otherwise textures will not be imported I think.
Also, is there any error in the console after importing?

Just to double check, did you enable Import USD Preview when importing? Because otherwise textures will not be imported I think. Also, is there any error in the console after importing?
Author

Yes, I enabled Import USD Preview in both cases, but other than that just the default options.

I don't see any errors, but get 4 instances of this warning after import:

Warning (secondary thread): in GetType at line 385 of E:\db19\build\S\VS1564R\build\usd\src\external_usd\pxr\base\vt\value.cpp -- Returning unknown type for VtValue with unregistered C++ type pxr_half::half

Yes, I enabled Import USD Preview in both cases, but other than that just the default options. I don't see any errors, but get 4 instances of this warning after import: Warning (secondary thread): in GetType at line 385 of E:\db19\build\S\VS1564R\build\usd\src\external_usd\pxr\base\vt\value.cpp -- Returning unknown type for VtValue with unregistered C++ type pxr_half::half
Member

Here is what I found so far. USD assets can have any path format, including Windows or UNIX paths, however, the importing application will have to support resolving that format, from the documentation:

In general, Ar does not impose any requirements or restrictions on the format of an asset path or resolved path. Users are free to use whatever path syntax they want as long as they are supported by their underlying resolver implementations.

There is a default resolver in USD, which I guess is used by Blender by default, in that resolver, we see:

    // Ensure we are using forward slashes and not back slashes.
    std::string forwardPath = anchorPath;
    std::replace(forwardPath.begin(), forwardPath.end(), '\\', '/');

Moreover, on Windows TfNormPath is called to also replace backward slashes with forward slashes and lower case drive specifiers. So the default resolver will eventually produce a UNIX path which Blender can accept.

So I suspect Quicklook is at fault here, maybe it uses a custom resolver that doesn't do this normalization? Have you tried contacting their support about this?


For the other issue, that is, textures are not importing at all no matter how the paths are constructed, can you open a separate report for it?

Here is what I found so far. USD assets can have any path format, including Windows or UNIX paths, however, the importing application will have to support resolving that format, from the [documentation](https://graphics.pixar.com/usd/release/api/ar_page_front.html#ar_paths): > In general, Ar does not impose any requirements or restrictions on the format of an asset path or resolved path. Users are free to use whatever path syntax they want as long as they are supported by their underlying resolver implementations. There is a default resolver in USD, which I guess is used by Blender by default, in that resolver, [we see](https://github.com/PixarAnimationStudios/USD/blob/release/pxr/usd/ar/defaultResolver_v2.cpp#L78): ``` // Ensure we are using forward slashes and not back slashes. std::string forwardPath = anchorPath; std::replace(forwardPath.begin(), forwardPath.end(), '\\', '/'); ``` Moreover, on Windows `TfNormPath` is called to also replace backward slashes with forward slashes and lower case drive specifiers. So the default resolver will eventually produce a UNIX path which Blender can accept. So I suspect Quicklook is at fault here, maybe it uses a custom resolver that doesn't do this normalization? Have you tried contacting their support about this? --- For the other issue, that is, textures are not importing at all no matter how the paths are constructed, can you open a separate report for it?
Author

Based on the your quote from the spec, yes it seems like Quicklook should handle those paths. I have not contacted them, but can try. It's odd though because USD files produced with other tools work fine, so they must all be using forward slashes.

That being said, it still seems inconsistent that the importer is ensuring forward slashes when resolving but the exporter is using backslashes (or maybe it's platform dependent?) - the other internal file structure paths look to use forward slashes regardless.

Also, shouldn't that resolver solve your "WARNING: Couldn't resolve image asset '@.\textures\scene-image-medium.jpg@' for Texture Image node." issue?

Based on the your quote from the spec, yes it seems like Quicklook should handle those paths. I have not contacted them, but can try. It's odd though because USD files produced with other tools work fine, so they must all be using forward slashes. That being said, it still seems inconsistent that the importer is ensuring forward slashes when resolving but the exporter is using backslashes (or maybe it's platform dependent?) - the other internal file structure paths look to use forward slashes regardless. Also, shouldn't that resolver solve your "WARNING: Couldn't resolve image asset '@.\textures\scene-image-medium.jpg@' for Texture Image node." issue?
Member

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

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

The exporter seems to just the path as is, so it is platform dependent, while the importer should do the normalization and resolution.

You are right, we should expect it to resolve correctly in my case, but apparently the path is read as an empty string, so something is wrong somewhere.

The exporter seems to just the path as is, so it is platform dependent, while the importer should do the normalization and resolution. You are right, we should expect it to resolve correctly in my case, but apparently the path is read as an empty string, so something is wrong somewhere.
Member

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

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

Setting this to confirmed as path resolution doesn't seem to be working in a cross platform manner. I tried to investigate this myself, but a more experience developer should look into this instead.

Setting this to confirmed as path resolution doesn't seem to be working in a cross platform manner. I tried to investigate this myself, but a more experience developer should look into this instead.
Omar Emara changed title from USD export texture path formatting causes problems on MacOS to USD image assets paths are not resolved in a cross platform manner 2022-06-08 09:56:32 +02:00
Member

Added subscribers: @makowalski, @lichtwerk

Added subscribers: @makowalski, @lichtwerk
Member
CC @makowalski

Thanks for investigating this, @OmarSquircleArt. I believe the solution is to ensure that relative paths have forward slashes when exporting USD from Blender. I will take this task and will work on a fix in the next couple of days.

The forward slashes should work when importing back on Windows. It didn't work for this example because of the material-name collision issue, being addressed here:

https://developer.blender.org/D14869

Because of this issue, the material wouldn't load, regardless of whether forward or back slashes are used. If I rename Material to Material2 in that USDA, the materials load fine with the forward slashes on Windows.

Thanks for investigating this, @OmarSquircleArt. I believe the solution is to ensure that relative paths have forward slashes when exporting USD from Blender. I will take this task and will work on a fix in the next couple of days. The forward slashes should work when importing back on Windows. It didn't work for this example because of the material-name collision issue, being addressed here: https://developer.blender.org/D14869 Because of this issue, the material wouldn't load, regardless of whether forward or back slashes are used. If I rename `Material` to `Material2` in that USDA, the materials load fine with the forward slashes on Windows.
Michael Kowalski self-assigned this 2022-06-08 16:31:36 +02:00

This issue was referenced by add1da52ad

This issue was referenced by add1da52ad783e33e8abb0a790ddc97dd89dab92

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'

@copeg Hi Jamie. The fix is committed. Please let me know if there are remaining issues with regard to the texture paths.

@copeg Hi Jamie. The fix is committed. Please let me know if there are remaining issues with regard to the texture paths.
Author

Excellent! Thanks so much Michael.

Excellent! Thanks so much Michael.
Bastien Montagne added this to the Pipeline, Assets & IO project 2023-02-09 15:40:49 +01:00
Bastien Montagne removed this from the Pipeline, Assets & IO project 2023-02-10 12:49:29 +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#97362
No description provided.