Page MenuHome

T90535: Handle material purpose on USD import
ClosedPublic

Authored by Michael Kowalski (makowalski) on Jul 4 2022, 2:28 AM.

Details

Summary

This is a partial fix for T90535. This code was originally reviewed in D13297, but is now split into a separate patch, as suggested by Sybren in that review.

USD allows binding materials generically as well as for a specific purpose:

https://graphics.pixar.com/usd/release/api/class_usd_shade_material_binding_a_p_i.html#details

I.e., purpose may be generic (unspecified) or one of

  • Full: truest representation of the scene
  • Preview: lightweight material for preview

Curently, only generically bound materials, with unspecified purpose (allPurpose), are imported. This issue is preventing preview materials from being imported in the Alab scene.

This patch adds logic to attempt to fall back on importing preview or full materials, in that order, if there is no generic material bound to the mesh.

The issue can be reproduced with the attached file, materialPurposeTest.usda, which contains three meshes, Plane_AllPurposeMtl, Plane_FullMtl and Plane_PreviewMtl, which resolve to materials with purpose allPurpose (Red), Full (Blue) and Preview (Green), respectively. Without this change, only Plane_AllPurposeMtl has a material assigned.

Diff Detail

Repository
rB Blender

Event Timeline

Michael Kowalski (makowalski) requested review of this revision.Jul 4 2022, 2:28 AM
Michael Kowalski (makowalski) created this revision.
Michael Kowalski (makowalski) retitled this revision from USD import: handle material purpose. to T90535: Handle material purpose on USD import.Jul 4 2022, 2:32 AM
Michael Kowalski (makowalski) edited the summary of this revision. (Show Details)

I can confirm the patch works, and imports the otherwise missing materials.

This patch adds logic to attempt to fall back on importing full or preview materials, if a there is no generic material bound to the mesh.

Is this done in that order, i.e. is full preferred over preview? (After checking the code: yes, that's the order)
Since the importer option is labeled "Import USD Preview", the opposite may be more applicable.
In any case, the patch description should be clear about this.

  • Checking for bound USD "preview" materials first.

Thanks for the review and suggestion, @Sybren A. Stüvel (sybren). I updated the code to check for "preview" materials first.

This revision is now accepted and ready to land.Aug 1 2022, 12:50 PM
This revision was automatically updated to reflect the committed changes.