Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question USD loading mesh but missing textures

Discussion in 'Formats & External Tools Previews' started by fusobotic, Oct 28, 2021.

  1. fusobotic

    fusobotic

    Joined:
    Feb 27, 2010
    Posts:
    15
    I'm having trouble getting my usdc file to open correctly. The mesh loads fine but the textures are missing from the materials.

    Here is what I'm using to load at runtime (if there's a better way let me know):
    Code (CSharp):
    1.                 InitUsd.Initialize();
    2.                 var sc = Scene.Open(FullFilename);
    3.                 Debug.Log("Opening usdc: " + FullFilename);
    4.                 if (sc != null)
    5.                 {
    6.                     this.Model = ImportHelpers.ImportSceneAsGameObject(sc, Selection.activeGameObject);
    7.                     sc.Close();
    8.                 } else
    9.                 {
    10.                     Debug.LogError("Could not find usdc file!");
    11.                 }
    Which is loading this:
    upload_2021-10-28_11-55-40.png

    But results in this:
    upload_2021-10-28_11-57-11.png

    I think it has something to do with the material import settings- I'd like to use a USD Lit Shader if possible, but I feel like even so it should at least load the textures.
     
  2. judub

    judub

    Unity Technologies

    Joined:
    Nov 5, 2019
    Posts:
    11
    Hi @fusobotic, the textures are not loaded by default. You need to pass ImportSceneAsGameObject a SceneImportOptions argument with its materialImportMode set to MaterialImportMode.ImportPreviewSurface.

    Code (CSharp):
    1. var importOptions = new SceneImportOptions();
    2. importOptions.materialImportMode = materialImportMode.ImportPreviewSurface;
    3. this.Model = ImportHelpers.ImportSceneAsGameObject(sc, Selection.activeGameObject, importOptions);
     
  3. fusobotic

    fusobotic

    Joined:
    Feb 27, 2010
    Posts:
    15
    That works to make the material URP but the textures still aren't assigning- at least not all of them. Looks like Normal and Metallic are but Albedo isn't. Also it looks like it's copying the textures to the project (in the Assets folder) as the game is running? I don't want it to work this way since I want these to load at runtime from another location locally or from a URL. Is there another, better way to import besides ImportHelpers? Thanks!
     
  4. jeremyco

    jeremyco

    Unity Technologies

    Joined:
    Oct 17, 2018
    Posts:
    38
    Sorry for the delay - there is an active PR to address issues in URP, this should be fixed in the next release.

    The import process isn't likely to change in this release, but I agree this should be configurable.
     
  5. UnityDeveloper09

    UnityDeveloper09

    Joined:
    May 10, 2023
    Posts:
    1
    What is the status on this for USD 3.0? The textures are still not applying to the imported USD. Not through code and not even if unity's USD plugin exports a FBX as a USDZ will not have its textures imported through the USD drop down import option from that same file it just exported.
     
  6. bf_jk

    bf_jk

    Joined:
    Sep 4, 2023
    Posts:
    1
    Hey, why aren't textures imported when importing a USD file? And even when the textures are imported manually and applied to the material on the model, they don't show? Does Unity not remap USD's "st" values to proper "uv" values for rendering textures?