Import USD materials that are not assigned to any object #97195

Closed
opened 2022-04-09 12:16:03 +02:00 by Zhen Dai · 28 comments

System Information
Operating system: macOS-12.3-x86_64-i386-64bit 64 Bits
Graphics card: AMD Radeon Pro 580 OpenGL Engine ATI Technologies Inc. 4.1 ATI-4.8.13

Blender Version
Broken: version: 3.1.2, branch: master, commit date: 2022-03-31 17:40, hash: cc66d1020c
Worked: N/A

Short description of error

Failed to import a simple .usda and .usdc file with only 1 default prim defined (and it is a material).

Exact steps for others to reproduce the error

  • Download a zip file from ambientCG, such as this one: https://ambientcg.com/view?id=PavingStones114 (use 1k-JPG)
  • Unzip it
  • Open Blender and Import the unzipped .usda/.usdc file. (try with "Import USD Preview" on and off)
  • Observe nothing happen, no new material created, no texture imported (it only added a cache file)

However, it is possible to use a third party importer such as: https://github.com/robmcrosby/BlenderUSDZ

  • Install add-on above
  • Renamed the zip file from above steps to .usdz
  • Import it with the add-on
  • The material appears correctly
  • Go to shader editor and reset the UV name and it will render correctly (it was named "st" per the usd file)

I do not see why Blender cannot handle the .usda file natively.

**System Information** Operating system: macOS-12.3-x86_64-i386-64bit 64 Bits Graphics card: AMD Radeon Pro 580 OpenGL Engine ATI Technologies Inc. 4.1 ATI-4.8.13 **Blender Version** Broken: version: 3.1.2, branch: master, commit date: 2022-03-31 17:40, hash: `cc66d1020c` Worked: N/A **Short description of error** Failed to import a simple .usda and .usdc file with only 1 default prim defined (and it is a material). **Exact steps for others to reproduce the error** - Download a zip file from ambientCG, such as this one: https://ambientcg.com/view?id=PavingStones114 (use 1k-JPG) - Unzip it - Open Blender and Import the unzipped .usda/.usdc file. (try with "Import USD Preview" on and off) - Observe nothing happen, no new material created, no texture imported (it only added a cache file) However, it is possible to use a third party importer such as: https://github.com/robmcrosby/BlenderUSDZ - Install add-on above - Renamed the zip file from above steps to .usdz - Import it with the add-on - The material appears correctly - Go to shader editor and reset the UV name and it will render correctly (it was named "st" per the usd file) I do not see why Blender cannot handle the .usda file natively.
Author

Added subscriber: @Zhen-Dai

Added subscriber: @Zhen-Dai
Author

Blender was able to import material if the usda contains a dummy mesh, such as this one: https://ambientcg.com/view?id=PavingStones115A

def Mesh "ambientCG_Dummy_Delete_Me"
{
    int[] faceVertexCounts = []
    int[] faceVertexIndices = []
    rel material:binding = </ambientCG_Material_PavingStones115A_1K_JPG>
    point3f[] points = []
    texCoord2f[] primvars:st = []
}

But it also set st as uv map incorrectly on the material.

(Since there is no vertices in the mesh, the uv map is also empty, setting st will never work anyway, not sure how this should be handled.)

(In the meantime, BlenderUSDZ add-on will hang on this file if imported usdz, so fun time for everyone facing this.)

Blender was able to import material if the usda contains a dummy mesh, such as this one: https://ambientcg.com/view?id=PavingStones115A ``` def Mesh "ambientCG_Dummy_Delete_Me" { int[] faceVertexCounts = [] int[] faceVertexIndices = [] rel material:binding = </ambientCG_Material_PavingStones115A_1K_JPG> point3f[] points = [] texCoord2f[] primvars:st = [] } ``` But it also set `st` as uv map incorrectly on the material. (Since there is no vertices in the mesh, the uv map is also empty, setting `st` will never work anyway, not sure how this should be handled.) (In the meantime, BlenderUSDZ add-on will hang on this file if imported usdz, so fun time for everyone facing this.)
Author

Additional point (but not strictly a bugfix): Blender usd importer could have supported displacement and occlusion map, but it didn't for reasons?

https://graphics.pixar.com/usd/release/spec_usdpreviewsurface.html#preview-surface

Additional point (but not strictly a bugfix): Blender usd importer could have supported `displacement` and `occlusion` map, but it didn't for reasons? https://graphics.pixar.com/usd/release/spec_usdpreviewsurface.html#preview-surface
Member

Added subscribers: @makowalski, @lichtwerk

Added subscribers: @makowalski, @lichtwerk
Member

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

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

This bugtracker will only handle the native importer, so please no reports about third party Addons.

Can confirm the behavior, no materials are created without dummy objects.
(This is a bit in line with other format importers though, not sure if there is any that just imports materials)

So this might be more like a feature request (a good one though), so maybe @makowalski has this on the TODO already? Or wants to keep this as TODO?

This bugtracker will only handle the native importer, so please no reports about third party Addons. Can confirm the behavior, no materials are created without dummy objects. (This is a bit in line with other format importers though, not sure if there is any that **just** imports materials) So this might be more like a feature request (a good one though), so maybe @makowalski has this on the TODO already? Or wants to keep this as TODO?
Philipp Oeser changed title from Blender 3.1 does not import USD material to Blender 3.1 does not import USD material (without a dummy object) 2022-04-11 18:40:32 +02:00

Thanks for reporting this, @zhendai. I agree that this is a good feature request and will investigate. We can probably add an option to import unassigned materials, or something similar.

I'm also investigating importing displacement and occlusion, which can be addressed as a separate task.

Thanks for reporting this, @zhendai. I agree that this is a good feature request and will investigate. We can probably add an option to import unassigned materials, or something similar. I'm also investigating importing `displacement` and `occlusion`, which can be addressed as a separate task.
Michael Kowalski self-assigned this 2022-04-12 03:48:38 +02:00
Author

In #97195#1339447, @makowalski wrote:
Thanks for reporting this, @zhendai. I agree that this is a good feature request and will investigate. We can probably add an option to import unassigned materials, or something similar.

I'm also investigating importing displacement and occlusion, which can be addressed as a separate task.

Thx, recently Node Wrangler add-on added similar support as well:

https://developer.blender.org/D14134

> In #97195#1339447, @makowalski wrote: > Thanks for reporting this, @zhendai. I agree that this is a good feature request and will investigate. We can probably add an option to import unassigned materials, or something similar. > > I'm also investigating importing `displacement` and `occlusion`, which can be addressed as a separate task. Thx, recently Node Wrangler add-on added similar support as well: https://developer.blender.org/D14134
Bastien Montagne changed title from Blender 3.1 does not import USD material (without a dummy object) to Import USD materials that are not assigned to any object 2022-04-13 17:49:38 +02:00

Added subscriber: @codeloadgame

Added subscriber: @codeloadgame

Added subscriber: @Lennart-Demes

Added subscriber: @Lennart-Demes

As the creator of ambientCG I would like to say Thanks! When I initially generated all the 1500+ USD files for the website Blender's USDPreviewSurface support was still very limited in general, so I assumed the feature would follow at some point. It's great to see this issue acknowledged.

To help with testing I have prepared some sample files with and without a dummy object on Google Drive .
I just tested these files in the latest 3.3.0-alpha(blender-3.3.0-alpha+master.dfb8c90324c0-windows.amd64-release) and can confirm that only the version with the dummy object gets the material imported, even when disabling the "visible objects only" checkbox while importing.

There is also a DevTalk thread about this, in case someone wants to discuss this situation and possible solutions there instead.

As the creator of ambientCG I would like to say Thanks! When I initially generated all the 1500+ USD files for the website Blender's USDPreviewSurface support was still very limited in general, so I assumed the feature would follow at some point. It's great to see this issue acknowledged. To help with testing I have prepared some sample files with and without a dummy object on [Google Drive ](https://drive.google.com/drive/folders/1QPWUCsE7DTLsGeTZvEr5D6CvlOLiTkFA?usp=sharing). I just tested these files in the latest 3.3.0-alpha(blender-3.3.0-alpha+master.dfb8c90324c0-windows.amd64-release) and can confirm that only the version with the dummy object gets the material imported, even when disabling the "visible objects only" checkbox while importing. There is also a [DevTalk thread ](https://devtalk.blender.org/t/importing-a-material-from-a-usda-file-without-importing-any-geometry/23320) about this, in case someone wants to discuss this situation and possible solutions there instead.

Thank you so much for the feedback, @struffel. Indeed, importing unassigned materials is a desirable feature, as I noted above, and I'm about to start work on this. Your files will serve as a good test case, so thank you for providing them!

Thank you so much for the feedback, @struffel. Indeed, importing unassigned materials is a desirable feature, as I noted above, and I'm about to start work on this. Your files will serve as a good test case, so thank you for providing them!

Hi, it's been a while. Has there been any recent activity regarding this topic, maybe in one of the daily/bleeding edge builds?

Hi, it's been a while. Has there been any recent activity regarding this topic, maybe in one of the daily/bleeding edge builds?

In #97195#1401492, @Lennart-Demes wrote:
Hi, it's been a while. Has there been any recent activity regarding this topic, maybe in one of the daily/bleeding edge builds?

Hi @Lennart-Demes This task was partly blocked by unrelated refactoring of the USD material import code, which is now done. I'll be working on the "unassigned materials" import topic next.

> In #97195#1401492, @Lennart-Demes wrote: > Hi, it's been a while. Has there been any recent activity regarding this topic, maybe in one of the daily/bleeding edge builds? Hi @Lennart-Demes This task was partly blocked by unrelated refactoring of the USD material import code, which is now done. I'll be working on the "unassigned materials" import topic next.

@Zhen-Dai @Lennart-Demes I've implemented this feature and it's available for you to test in the tmp_usd_import_unbound_mtls experimental build available from the experimental builds downloads page:

https://builder.blender.org/download/experimental/

There is a new Unbound Materials toggle to enable importing unassigned materials, which is off by default. You will probably need to rename the mesh UV set to match what's expected by the material, usually st.

I will create an official patch for this later today. Please let me know if you have feedback or encounter issues.

image.png

@Zhen-Dai @Lennart-Demes I've implemented this feature and it's available for you to test in the `tmp_usd_import_unbound_mtls` experimental build available from the experimental builds downloads page: https://builder.blender.org/download/experimental/ There is a new `Unbound Materials` toggle to enable importing unassigned materials, which is off by default. You will probably need to rename the mesh UV set to match what's expected by the material, usually `st`. I will create an official patch for this later today. Please let me know if you have feedback or encounter issues. ![image.png](https://archive.blender.org/developer/F13623230/image.png)
Author

Thx Michael! Downloading now, I will test it out this Friday.

Thx Michael! Downloading now, I will test it out this Friday.

Super exciting! I'll test it out tomorrow!

Super exciting! I'll test it out tomorrow!

Okay, looks good to me! All the materials are getting imported.

The thing with the UV map name is a bit annoying of course but I don't see a way of dealing with that without creating issues elsewhere (I could rename my UV maps to Blender's 'UVMap' default name instead of 'st' but that would break stuff for other people).

Okay, looks good to me! All the materials are getting imported. The thing with the UV map name is a bit annoying of course but I don't see a way of dealing with that without creating issues elsewhere (I could rename my UV maps to Blender's 'UVMap' default name instead of 'st' but that would break stuff for other people).

In #97195#1429474, @Lennart-Demes wrote:
Okay, looks good to me! All the materials are getting imported.

The thing with the UV map name is a bit annoying of course but I don't see a way of dealing with that without creating issues elsewhere (I could rename my UV maps to Blender's 'UVMap' default name instead of 'st' but that would break stuff for other people).

Thanks so much for testing, @Lennart-Demes!

As for the UV map name issue, we could add an option to automatically rename the maps on import into Blender. E.g., a checkbox to rename st to UVMap, or more generally, some sort of UI to specify how USD primvars should be renamed when converting to Blender attributes. But this will require some thought and discussion, so it should probably be handled in a separate patch.

> In #97195#1429474, @Lennart-Demes wrote: > Okay, looks good to me! All the materials are getting imported. > > The thing with the UV map name is a bit annoying of course but I don't see a way of dealing with that without creating issues elsewhere (I could rename my UV maps to Blender's 'UVMap' default name instead of 'st' but that would break stuff for other people). Thanks so much for testing, @Lennart-Demes! As for the UV map name issue, we could add an option to automatically rename the maps on import into Blender. E.g., a checkbox to rename `st` to `UVMap`, or more generally, some sort of UI to specify how USD primvars should be renamed when converting to Blender attributes. But this will require some thought and discussion, so it should probably be handled in a separate patch.

Hi again, this feature hasn't made the jump into the official 3.4 release, has it? Is it possible to say with which official release the new material import will be shipped?

Hi again, this feature hasn't made the jump into the official 3.4 release, has it? Is it possible to say with which official release the new material import will be shipped?

In #97195#1456280, @Lennart-Demes wrote:
Hi again, this feature hasn't made the jump into the official 3.4 release, has it? Is it possible to say with which official release the new material import will be shipped?

Hi Lennart. Sorry for the late reply. I'm still addressing some issues raised in the patch review and I hope to have a revision for this some time next week. Therefore, this feature has not been merged into 3.4, but I believe it will ready for 3.5, barring any unexpected issues in subsequent reviews.

> In #97195#1456280, @Lennart-Demes wrote: > Hi again, this feature hasn't made the jump into the official 3.4 release, has it? Is it possible to say with which official release the new material import will be shipped? Hi Lennart. Sorry for the late reply. I'm still addressing some issues raised in the patch review and I hope to have a revision for this some time next week. Therefore, this feature has not been merged into 3.4, but I believe it will ready for 3.5, barring any unexpected issues in subsequent reviews.

Hi @Lennart-Demes and @zhendai. Just FYI, I submitted a revision to the patch based on the reviews. I also created a patch build for this latest version. If you want to try it, please go to

https://builder.blender.org/download/patch/

and look for the D16172 build. Note that the USD import option for this feature is now called Import All Materials.

Hi @Lennart-Demes and @zhendai. Just FYI, I submitted a revision to the patch based on the reviews. I also created a patch build for this latest version. If you want to try it, please go to https://builder.blender.org/download/patch/ and look for the [D16172](https://archive.blender.org/developer/D16172) build. Note that the USD import option for this feature is now called `Import All Materials`.

Looks good to me! I tried the usda and usdc files of these materials:

ambientCG.com/a/PavingStones036 (base case)
ambientCG.com/a/ManholeCover004 (metalness and opacity)
ambientCG.com/a/Lava005 (emission)

and they all worked as expected.

Looks good to me! I tried the usda and usdc files of these materials: ambientCG.com/a/PavingStones036 (base case) ambientCG.com/a/ManholeCover004 (metalness and opacity) ambientCG.com/a/Lava005 (emission) and they all worked as expected.

Thanks for testing, @Lennart-Demes!

Thanks for testing, @Lennart-Demes!
Member

Added subscriber: @GregZaal

Added subscriber: @GregZaal

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

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

@Zhen-Dai @Lennart-Demes This change has landed in master and should be available in the next alpha build.

@Zhen-Dai @Lennart-Demes This change has landed in master and should be available in the next alpha build.

That's amazing! Thank you!

That's amazing! Thank you!
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#97195
No description provided.