CesiumGS / cesium-omniverse

Bringing the 3D geospatial ecosystem to Omniverse
https://cesium.com/platform/cesium-for-omniverse/
Apache License 2.0
55 stars 7 forks source link

Custom tileset materials display as grey when loaded from USD #607

Open r-veenstra opened 8 months ago

r-veenstra commented 8 months ago

Custom tileset materials appear to not be displaying correctly when loaded from a USD, despite working when initially created prior to saving.

Reproduction steps

Reproduced in:

USD Composer 2023.2.2-prod.2 https://github.com/CesiumGS/cesium-omniverse/tree/1eadd69a744d347c2c1218c6f6b936cead0b0cd5

lilleyse commented 8 months ago

This seems to be a recent regression. I can't reproduce in USD Composer 2023.2.1 Beta.

lilleyse commented 7 months ago

Based on some early debugging materialHasCesiumNodes can't find any connection attributes and so it doesn't try to apply styling. Sill investigating why the connection attributes aren't there.

105.1.2 on the left, 105.1 on the right

image

ferry-building-2.zip

lilleyse commented 7 months ago

After some more investigation, this seems to be an issue with Fabric material population.

When I create something in material graph and print the stage I see this:

Prim: /World/Looks/OmniPBR (12583425)
  Attributes:
    Attribute: outputs:mdl:volume
      Type: token
      Value: 
    Attribute: outputs:mdl:displacement
      Type: token
      Value: 
    Attribute: outputs:mdl:surface
      Type: token
      Value: 
    Attribute: outputs:mdl:volume
      Type: connection
      Value: Path: /World/Looks/OmniPBR/Shader, Attribute Name: out
    Attribute: outputs:mdl:displacement
      Type: connection
      Value: Path: /World/Looks/OmniPBR/Shader, Attribute Name: out
    Attribute: outputs:mdl:surface
      Type: connection
      Value: Path: /World/Looks/OmniPBR/Shader, Attribute Name: out
    Attribute: Material
      Type: tag (primTypeName)
    Attribute: UsdTyped
      Type: tag (ancestorPrimTypeName)
    Attribute: NodeGraph
      Type: tag (ancestorPrimTypeName)
    Attribute: TfType::_Root
      Type: tag (ancestorPrimTypeName)
    Attribute: UsdSchemaBase
      Type: tag (ancestorPrimTypeName)

However, when I save the project and reload the .usda I see this:

Prim: /World/Looks/OmniPBR (12584705)
  Attributes:
    Attribute: Material
      Type: tag (primTypeName)
    Attribute: NodeGraph
      Type: tag (ancestorPrimTypeName)
    Attribute: UsdSchemaBase
      Type: tag (ancestorPrimTypeName)
    Attribute: UsdTyped
      Type: tag (ancestorPrimTypeName)
    Attribute: TfType::_Root
      Type: tag (ancestorPrimTypeName)

The connection attributes are missing and this is causing problems for how we apply materials to tiles.

What this means is that we can create materials and assign them to tilesets in the same session, and that all works. But if we reload projects it doesn't work.

lilleyse commented 7 months ago

A workaround is to assign the material to some other object on the stage. Then it will populate correctly on reload. Note the _materialSource attribute.

Prim: /World/Looks/Material (59393)
  Attributes:
    Attribute: _materialSource
      Type: rel
      Value: [38913]
    Attribute: Material
      Type: tag (primTypeName)
    Attribute: MergedMaterial
      Type: tag (primTypeName)
    Attribute: UsdTyped
      Type: tag (ancestorPrimTypeName)
    Attribute: NodeGraph
      Type: tag (ancestorPrimTypeName)
    Attribute: UsdSchemaBase
      Type: tag (ancestorPrimTypeName)
    Attribute: TfType::_Root
      Type: tag (ancestorPrimTypeName)

image

tileset-material-workaround.zip (this works once https://github.com/CesiumGS/cesium-omniverse/pull/644 is merged)

A proper fix is being worked on where it populates from anything with a MaterialBindingAPI, which includes CesiumTilesetPrim. Until then we have this kind of awkward work around.