Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

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.