Пример #1
0
/*static*/
SdfPath
UsdImaging_MaterialNetworkStrategy::GetBinding(UsdShadeMaterial const& material)
{
    TF_DEBUG(USDIMAGING_SHADERS).Msg("\t Look: %s\n", 
        material.GetPath().GetText());

    // ---------------------------------------------------------------------- //
    // Shading networks - riLook:bxdf
    // ---------------------------------------------------------------------- //
    if (UsdRelationship matRel = 
        UsdRiMaterialAPI(material).GetBxdfOutput().GetRel()) {

        TF_DEBUG(USDIMAGING_SHADERS).Msg("\t LookRel: %s\n", 
                    matRel.GetPath().GetText());
        return material.GetPath();
    }

    return SdfPath::EmptyPath();
}
Пример #2
0
/*static*/
SdfPath
UsdImaging_MaterialStrategy::GetBinding(UsdShadeMaterial const& material)
{
    TF_DEBUG(USDIMAGING_SHADERS).Msg("\t Look: %s\n", 
        material.GetPath().GetText());

    // ---------------------------------------------------------------------- //
    // Hydra-only shader style - displayLook:bxdf
    // ---------------------------------------------------------------------- //
    if (UsdRelationship matRel = UsdHydraLookAPI(material).GetBxdfRel()) {
        TF_DEBUG(USDIMAGING_SHADERS).Msg("\t LookRel: %s\n", 
                    matRel.GetPath().GetText());

        UsdShadeShader shader(
            UsdImaging_MaterialStrategy::GetTargetedShader(
                material.GetPrim(), 
                matRel));

        if (shader) {
            TF_DEBUG(USDIMAGING_SHADERS).Msg("\t UsdShade binding found: %s\n", 
                    shader.GetPath().GetText());
            return shader.GetPath();
        }
    }

    // ---------------------------------------------------------------------- //
    // Deprecated shader style - hydraLook:Surface
    // ---------------------------------------------------------------------- //
    TfToken hdSurf("hydraLook:surface");
    TfToken surfType("HydraPbsSurface");

    if (UsdRelationship matRel = material.GetPrim().GetRelationship(hdSurf)) {
        TF_DEBUG(USDIMAGING_SHADERS).Msg("\t LookRel: %s\n", 
                    matRel.GetPath().GetText());

        if (UsdPrim shader = 
            UsdImaging_MaterialStrategy::GetTargetedShader(
                material.GetPrim(), 
                matRel)) {

            if (TF_VERIFY(shader.GetTypeName() == surfType)) {
                TF_DEBUG(USDIMAGING_SHADERS).Msg(
                        "\t Deprecated binding found: %s\n", 
                        shader.GetPath().GetText());
                return shader.GetPath();
            }
        }
    }

    return SdfPath::EmptyPath();
}