Loading...
Searching...
No Matches
hdMtlx.h
1//
2// Copyright 2021 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_IMAGING_HD_MTLX_HDMTLX_H
8#define PXR_IMAGING_HD_MTLX_HDMTLX_H
9
10#include "pxr/pxr.h"
11#include "pxr/base/tf/token.h"
12#include "pxr/imaging/hdMtlx/api.h"
13#include <memory>
14#include <set>
15#include <unordered_map>
16
17#include <MaterialXCore/Library.h>
18
19MATERIALX_NAMESPACE_BEGIN
20 class FileSearchPath;
21 using DocumentPtr = std::shared_ptr<class Document>;
22 using NodeDefPtr = std::shared_ptr<class NodeDef>;
23MATERIALX_NAMESPACE_END
24
25PXR_NAMESPACE_OPEN_SCOPE
26
27class SdfPath;
28class VtValue;
30struct HdMaterialNode2;
32
37HDMTLX_API
38const MaterialX::FileSearchPath&
39HdMtlxSearchPaths();
40
43HDMTLX_API
44const MaterialX::DocumentPtr&
45HdMtlxStdLibraries();
46
48HDMTLX_API
49std::string
50HdMtlxConvertToString(VtValue const& hdParameterValue);
51
52// Storing MaterialX-Hydra texture and primvar information
53struct HdMtlxTexturePrimvarData {
54 HdMtlxTexturePrimvarData() = default;
55 using TextureMap = std::map<std::string, std::set<std::string>>;
56 TextureMap mxHdTextureMap; // Mx-Hd texture name mapping
57 std::set<SdfPath> hdTextureNodes; // Paths to HdTexture Nodes
58 std::set<SdfPath> hdPrimvarNodes; // Paths to HdPrimvar nodes
59};
60
61HDMTLX_API
62std::string
63HdMtlxCreateNameFromPath(SdfPath const& path);
64
70HDMTLX_API
71MaterialX::NodeDefPtr
72HdMtlxGetNodeDef(
73 TfToken const& hdNodeType,
74 MaterialX::DocumentPtr const& mxDoc=nullptr);
75
78HDMTLX_API
79std::string
80HdMtlxGetNodeDefName(std::string const& prevMxNodeDefName);
81
84HDMTLX_API
85std::string
86HdMtlxGetMxTerminalName(
87 HdMaterialNetworkInterface *netInterface,
88 TfToken const& hdTerminalNodeName);
89
92HDMTLX_API
93std::string
94HdMtlxGetMxTerminalName(std::string const& mxTerminalType);
95
99HDMTLX_API
100MaterialX::DocumentPtr
101HdMtlxCreateMtlxDocumentFromHdNetwork(
102 HdMaterialNetwork2 const& hdNetwork,
103 HdMaterialNode2 const& hdMaterialXNode,
104 SdfPath const& hdMaterialXNodePath,
105 SdfPath const& materialPath,
106 MaterialX::DocumentPtr const& libraries,
107 HdMtlxTexturePrimvarData *mxHdData = nullptr);
108
110HDMTLX_API
111MaterialX::DocumentPtr
112HdMtlxCreateMtlxDocumentFromHdMaterialNetworkInterface(
113 HdMaterialNetworkInterface *netInterface,
114 TfToken const& terminalNodeName,
115 TfTokenVector const& terminalNodeConnectionNames,
116 MaterialX::DocumentPtr const& libraries,
117 HdMtlxTexturePrimvarData *mxHdData = nullptr);
118
119PXR_NAMESPACE_CLOSE_SCOPE
120
121#endif
Abstract interface for querying and mutating a material network.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
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