Loading...
Searching...
No Matches
hdMtlx.h
1//
2// Copyright 2026 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef EXT_RMANPKG_PLUGIN_RENDERMAN_PLUGIN_HD_PRMAN_PXR_IMAGING_HD_MTLX_HDMTLX_H
8#define EXT_RMANPKG_PLUGIN_RENDERMAN_PLUGIN_HD_PRMAN_PXR_IMAGING_HD_MTLX_HDMTLX_H
9
10// XXX: Delete this file after hdPrman drops support for USD versions
11// older than 2608. There are bugfixes in 2608 which we want in our
12// build.
13
14#include "pxr/pxr.h"
15#if PXR_VERSION >= 2608
16#include <pxr/imaging/hdMtlx/hdMtlx.h> // IWYU pragma: export
17#else
18
19#include "pxr/base/tf/token.h"
20#include "pxr/imaging/hdMtlx/api.h"
21#include <map>
22#include <memory>
23#include <set>
24#include <unordered_map>
25
26#include <MaterialXCore/Library.h>
27
28MATERIALX_NAMESPACE_BEGIN
29 class FileSearchPath;
30 using DocumentPtr = std::shared_ptr<class Document>;
31 using NodeDefPtr = std::shared_ptr<class NodeDef>;
32MATERIALX_NAMESPACE_END
33
34PXR_NAMESPACE_OPEN_SCOPE
35
36#define HdMtlxSearchPaths HdMtlxPrmanSearchPaths
37#define HdMtlxStdLibraries HdMtlxPrmanStdLibraries
38#define HdMtlxCreateNameFromPath HdMtlxPrmanCreateNameFromPath
39#define HdMtlxCreateMtlxDocumentFromHdMaterialNetworkInterface HdMtlxPrmanCreateMtlxDocumentFromHdMaterialNetworkInterface
40#define HdMtlxGetNodeDef HdMtlxPrmanGetNodeDef
41#define HdMtlxGetNodeDefName HdMtlxPrmanGetNodeDefName
42#define HdMtlxGetMxTerminalName HdMtlxPrmanGetMxTerminalName
43
44class SdfPath;
45class VtValue;
47struct HdMaterialNode2;
49
54HDMTLX_API
55const MaterialX::FileSearchPath&
56HdMtlxPrmanSearchPaths();
57
60HDMTLX_API
61const MaterialX::DocumentPtr&
62HdMtlxPrmanStdLibraries();
63
65HDMTLX_API
66std::string
67HdMtlxPrmanConvertToString(VtValue const& hdParameterValue);
68
69// Storing MaterialX-Hydra texture and primvar information
70struct HdMtlxTexturePrimvarData {
71 HdMtlxTexturePrimvarData() = default;
72 using TextureMap = std::map<std::string, std::set<std::string>>;
73 TextureMap mxHdTextureMap; // Mx-Hd texture name mapping
74 std::set<SdfPath> hdTextureNodes; // Paths to HdTexture Nodes
75 std::set<SdfPath> hdPrimvarNodes; // Paths to HdPrimvar nodes
76};
77
78HDMTLX_API
79std::string
80HdMtlxPrmanCreateNameFromPath(SdfPath const& path);
81
87HDMTLX_API
88MaterialX::NodeDefPtr
89HdMtlxPrmanGetNodeDef(
90 TfToken const& hdNodeType,
91 MaterialX::DocumentPtr const& mxDoc=nullptr);
92
95HDMTLX_API
96std::string
97HdMtlxPrmanGetNodeDefName(std::string const& prevMxNodeDefName);
98
101HDMTLX_API
102std::string
103HdMtlxPrmanGetMxTerminalName(
104 HdMaterialNetworkInterface *netInterface,
105 TfToken const& hdTerminalNodeName);
106
109HDMTLX_API
110std::string
111HdMtlxPrmanGetMxTerminalName(std::string const& mxTerminalType);
112
116HDMTLX_API
117MaterialX::DocumentPtr
118HdMtlxPrmanCreateMtlxDocumentFromHdNetwork(
119 HdMaterialNetwork2 const& hdNetwork,
120 HdMaterialNode2 const& hdMaterialXNode,
121 SdfPath const& hdMaterialXNodePath,
122 SdfPath const& materialPath,
123 MaterialX::DocumentPtr const& libraries,
124 HdMtlxTexturePrimvarData *mxHdData = nullptr);
125
127HDMTLX_API
128MaterialX::DocumentPtr
129HdMtlxPrmanCreateMtlxDocumentFromHdMaterialNetworkInterface(
131 TfToken const& terminalNodeName,
132 TfTokenVector const& terminalNodeConnectionNames,
133 MaterialX::DocumentPtr const& libraries,
134 HdMtlxTexturePrimvarData *mxHdData = nullptr);
135
136PXR_NAMESPACE_CLOSE_SCOPE
137
138#endif // PXR_VERSION >= 2608
139
140#endif // EXT_RMANPKG_PLUGIN_RENDERMAN_PLUGIN_HD_PRMAN_PXR_IMAGING_HD_MTLX_HDMTLX_H
Abstract interface for querying and mutating a material network.
A path value used to locate objects in layers or scenegraphs.
Definition path.h:281
Token for efficient comparison, assignment, and hashing of known strings.
Definition token.h:71
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition value.h:90
Container of nodes and top-level terminal connections.
Definition material.h:166
Describes an instance of a node within a network A node contains a (shader) type identifier,...
Definition material.h:154
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
std::vector< TfToken > TfTokenVector
Convenience types.
Definition token.h:440