Files
test2/source/blender/editors/io
Jesse Yurkovich 80cf6b99c3 USD: Provide Import option for Material Purpose
USD has the concept of material "purposes" which allows different
materials to be associated for a prim and gives special meaning to them.
These are somewhat similar to display purposes, which we already allow
to be chosen, but are distinct concepts. This PR adds an option for
Import allowing the user to chose which material purpose to load.

Blender currently attempts to load purposes automatically. It starts
with "allPurpose" and then moves to "preview" and "full" in that order.
This behavior is now changed and the automated search is removed to
instead give the user control which purpose to load. Additionally, USD
already has its own fallback behavior during material resolution[1]:
- When given "full" it will first check "full" and fallback to
  "allPurpose" if not found. An additional, Blender-specific fallback
  to "preview" is also implemented here upon request.
- When given "preview" it will first check "preview" and fallback to
  "allPurpose" if not found
- When given "allPurpose", it will only check "allPurpose"

I have opt'd to keep this behavior directly as-is to not introduce
differences that may surprise those already familiar with USD elsewhere.

Additionally, I've set Blender's default import purpose to "full" to
ensure we're loading in the highest quality assets first. Though this
has the obvious risk that "full" assets tend to be quite heavy. We can
change to "preview" if this proves too problematic later.

This does not change how Blender exports materials. Blender always uses
the "allPurpose" binding when writing its USD files.

--------
[1] USD docs:
https://openusd.org/release/api/class_usd_shade_material_binding_a_p_i.html#details
https://openusd.org/release/api/class_usd_shade_material_binding_a_p_i.html#UsdShadeMaterialBindingAPI_MaterialResolution

Pull Request: https://projects.blender.org/blender/blender/pulls/128206
2024-10-03 20:16:27 +02:00
..