omni/connect/core/MaterialAlgo.h
File members: omni/connect/core/MaterialAlgo.h
// SPDX-FileCopyrightText: Copyright (c) 2022-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
//
// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
// property and proprietary rights in and to this material, related
// documentation and any modifications thereto. Any use, reproduction,
// disclosure or distribution of this material and related documentation
// without an express license agreement from NVIDIA CORPORATION or
// its affiliates is strictly prohibited.
#pragma once
#include "Api.h"
#include <carb/cpp/Optional.h>
#include <pxr/base/gf/vec3f.h>
#include <pxr/usd/usd/prim.h>
#include <pxr/usd/usdShade/material.h>
#include <pxr/usd/usdShade/shader.h>
namespace omni::connect::core
{
// clang-format off
enum class ColorSpace
{
eAuto,
eRaw,
eSrgb,
};
// clang-format on
OMNICONNECTCORE_API pxr::GfVec3f sRgbToLinear(const pxr::GfVec3f& color);
OMNICONNECTCORE_API pxr::GfVec3f linearToSrgb(const pxr::GfVec3f& color);
OMNICONNECTCORE_API pxr::UsdShadeMaterial createMaterial(pxr::UsdPrim parent, const std::string& name);
OMNICONNECTCORE_API pxr::UsdShadeShader createMdlShader(
pxr::UsdShadeMaterial& material,
const std::string& name,
const pxr::SdfAssetPath& mdlPath,
const pxr::TfToken& module,
bool connectMaterialOutputs = true
);
OMNICONNECTCORE_API pxr::UsdShadeInput createMdlShaderInput(
pxr::UsdShadeMaterial& material,
const pxr::TfToken& name,
const pxr::VtValue& value,
const pxr::SdfValueTypeName& typeName,
carb::cpp::optional<const ColorSpace> colorSpace = carb::cpp::nullopt
);
OMNICONNECTCORE_API void bindMaterial(pxr::UsdPrim prim, const pxr::UsdShadeMaterial& material);
OMNICONNECTCORE_API pxr::UsdShadeShader computeEffectiveMdlSurfaceShader(const pxr::UsdShadeMaterial& material);
OMNICONNECTCORE_API pxr::UsdShadeShader computeEffectivePreviewSurfaceShader(const pxr::UsdShadeMaterial& material);
OMNICONNECTCORE_API pxr::UsdShadeMaterial defineOmniPbrMaterial(
pxr::UsdStagePtr stage,
const pxr::SdfPath& path,
const pxr::GfVec3f& color,
const float opacity = 1.0f,
const float roughness = 0.5f,
const float metallic = 0.0f
);
OMNICONNECTCORE_API pxr::UsdShadeMaterial defineOmniPbrMaterial(
pxr::UsdPrim parent,
const std::string& name,
const pxr::GfVec3f& color,
const float opacity = 1.0f,
const float roughness = 0.5f,
const float metallic = 0.0f
);
OMNICONNECTCORE_API bool addDiffuseTextureToPbrMaterial(pxr::UsdShadeMaterial& material, const pxr::SdfAssetPath& texturePath);
OMNICONNECTCORE_API bool addNormalTextureToPbrMaterial(pxr::UsdShadeMaterial& material, const pxr::SdfAssetPath& texturePath);
OMNICONNECTCORE_API bool addOrmTextureToPbrMaterial(pxr::UsdShadeMaterial& material, const pxr::SdfAssetPath& texturePath);
OMNICONNECTCORE_API bool addRoughnessTextureToPbrMaterial(pxr::UsdShadeMaterial& material, const pxr::SdfAssetPath& texturePath);
OMNICONNECTCORE_API bool addMetallicTextureToPbrMaterial(pxr::UsdShadeMaterial& material, const pxr::SdfAssetPath& texturePath);
OMNICONNECTCORE_API bool addOpacityTextureToPbrMaterial(pxr::UsdShadeMaterial& material, const pxr::SdfAssetPath& texturePath);
OMNICONNECTCORE_API pxr::UsdShadeMaterial defineOmniGlassMaterial(
pxr::UsdStagePtr stage,
const pxr::SdfPath& path,
const pxr::GfVec3f& color,
const float indexOfRefraction = 1.491f
);
OMNICONNECTCORE_API pxr::UsdShadeMaterial defineOmniGlassMaterial(
pxr::UsdPrim parent,
const std::string& name,
const pxr::GfVec3f& color,
const float indexOfRefraction = 1.491f
);
} // namespace omni::connect::core