guc icon indicating copy to clipboard operation
guc copied to clipboard

Issue with vertex colors not displayed after convertion

Open HyperCed opened this issue 10 months ago • 1 comments

Hi, I tried to convert this kind of model with only vertex colors : http://superced.rb38.eu/files/map.B4-UL01.1.glb

The colors was not visible since there is a white emit color instead. I tried without m flag with no success.

I found a way to modify the code and it's working with this patch. I don't know if this is a bug of guc or not.

So I changed that code

void Converter::createMaterialBinding(UsdPrim& prim, const std::string& materialName)
  {
    if (m_params.emitMtlx)
    {
      UsdShadeMaterialBindingAPI::Apply(prim).Bind(
        UsdShadeMaterial::Get(m_stage, makeMtlxMaterialPath(materialName)),
        UsdShadeTokens->fallbackStrength,
        UsdShadeTokens->allPurpose
      );
    }

#ifndef NDEBUG
    if (!TfGetEnvSetting(GUC_DISABLE_PREVIEW_MATERIAL_BINDINGS))
#endif
    {
    
      UsdShadeMaterialBindingAPI::Apply(prim).Bind(
        UsdShadeMaterial::Get(m_stage, makeUsdPreviewSurfaceMaterialPath(materialName)),
        UsdShadeTokens->fallbackStrength,
        m_params.emitMtlx ? UsdShadeTokens->preview : UsdShadeTokens->allPurpose
      );
      
    }
  }

by:

void Converter::createMaterialBinding(UsdPrim& prim, const std::string& materialName)
  {
    if (m_params.emitMtlx)
    {
      UsdShadeMaterialBindingAPI::Apply(prim).Bind(
        UsdShadeMaterial::Get(m_stage, makeMtlxMaterialPath(materialName)),
        UsdShadeTokens->fallbackStrength,
        UsdShadeTokens->allPurpose
      );
    }

#ifndef NDEBUG
    if (!TfGetEnvSetting(GUC_DISABLE_PREVIEW_MATERIAL_BINDINGS))
#endif
    {
    if (m_params.emitMtlx)
    {
      UsdShadeMaterialBindingAPI::Apply(prim).Bind(
        UsdShadeMaterial::Get(m_stage, makeUsdPreviewSurfaceMaterialPath(materialName)),
        UsdShadeTokens->fallbackStrength,
        m_params.emitMtlx ? UsdShadeTokens->preview : UsdShadeTokens->allPurpose
      );
      }
    }
  }

And now, my vertex colors are ok in the usd file !!!

HyperCed avatar Mar 27 '25 11:03 HyperCed

Hello, thanks for the report - and sorry for waiting, I'll have a look at it.

Just a few points:

  • UsdPreviewSurface materials cannot technically support vertex colors
  • MaterialX materials support it, but are not shown in usdview when a preview material is bound
  • if no material if bound, which is perhaps what you are doing here (assuming --emit-mtlx is not given), then usdview will natively display the displayColor primvar, for which guc uses vertex colors

pablode avatar Jun 04 '25 13:06 pablode