HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
hdMtlx.h
Go to the documentation of this file.
1 //
2 // Copyright 2021 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_IMAGING_HD_MTLX_HDMTLX_H
25 #define PXR_IMAGING_HD_MTLX_HDMTLX_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/base/tf/token.h"
29 #include "pxr/imaging/hdMtlx/api.h"
30 #include <memory>
31 #include <set>
32 #include <unordered_map>
33 
34 #include <MaterialXCore/Library.h>
35 
37  class FileSearchPath;
38  using DocumentPtr = std::shared_ptr<class Document>;
40 
42 
43 class SdfPath;
44 class VtValue;
45 struct HdMaterialNetwork2;
46 struct HdMaterialNode2;
48 
49 /// Return the MaterialX search paths. In order, this includes:
50 /// - Paths set in the environment variable 'PXR_MTLX_PLUGIN_SEARCH_PATHS'
51 /// - Paths set in the environment variable 'PXR_MTLX_STDLIB_SEARCH_PATHS'
52 /// - Path to the MaterialX standard library discovered at build time.
54 const MaterialX::FileSearchPath&
56 
57 /// Return a MaterialX document with the stdlibraries loaded using the above
58 /// search paths.
62 
63 /// Converts the HdParameterValue to a string MaterialX can understand
66 HdMtlxConvertToString(VtValue const& hdParameterValue);
67 
68 // Storing MaterialX-Hydra texture and primvar information
71  : mxHdTextureMap(MaterialX::StringMap()), // Mx-Hd texture name mapping
72  hdTextureNodes(std::set<SdfPath>()), // Paths to HdTexture Nodes
73  hdPrimvarNodes(std::set<SdfPath>()) {} // Paths to HdPrimvar nodes
75  std::set<SdfPath> hdTextureNodes;
76  std::set<SdfPath> hdPrimvarNodes;
77 };
78 
79 /// Creates and returns a MaterialX Document from the given HdMaterialNetwork2
80 /// Collecting the hdTextureNodes and hdPrimvarNodes as the network is
81 /// traversed as well as the Texture name mapping between MaterialX and Hydra.
85  HdMaterialNetwork2 const& hdNetwork,
86  HdMaterialNode2 const& hdMaterialXNode,
87  SdfPath const& hdMaterialXNodePath,
88  SdfPath const& materialPath,
89  MaterialX::DocumentPtr const& libraries,
90  HdMtlxTexturePrimvarData *mxHdData = nullptr);
91 
92 /// Implementation that uses the material network interface.
96  HdMaterialNetworkInterface *netInterface,
97  TfToken const& terminalNodeName,
98  TfTokenVector const& terminalNodeConnectionNames,
99  MaterialX::DocumentPtr const& libraries,
100  HdMtlxTexturePrimvarData *mxHdData = nullptr);
101 
103 
104 #endif
HDMTLX_API std::string HdMtlxConvertToString(VtValue const &hdParameterValue)
Converts the HdParameterValue to a string MaterialX can understand.
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
HDMTLX_API const MaterialX::FileSearchPath & HdMtlxSearchPaths()
std::shared_ptr< class Document > DocumentPtr
Definition: hdMtlx.h:38
MaterialX::StringMap mxHdTextureMap
Definition: hdMtlx.h:74
HDMTLX_API MaterialX::DocumentPtr HdMtlxCreateMtlxDocumentFromHdNetwork(HdMaterialNetwork2 const &hdNetwork, HdMaterialNode2 const &hdMaterialXNode, SdfPath const &hdMaterialXNodePath, SdfPath const &materialPath, MaterialX::DocumentPtr const &libraries, HdMtlxTexturePrimvarData *mxHdData=nullptr)
std::set< SdfPath > hdTextureNodes
Definition: hdMtlx.h:75
Definition: token.h:87
HDMTLX_API MaterialX::DocumentPtr HdMtlxCreateMtlxDocumentFromHdMaterialNetworkInterface(HdMaterialNetworkInterface *netInterface, TfToken const &terminalNodeName, TfTokenVector const &terminalNodeConnectionNames, MaterialX::DocumentPtr const &libraries, HdMtlxTexturePrimvarData *mxHdData=nullptr)
Implementation that uses the material network interface.
shared_ptr< Document > DocumentPtr
A shared pointer to a Document.
Definition: Document.h:22
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:457
Definition: path.h:290
std::set< SdfPath > hdPrimvarNodes
Definition: hdMtlx.h:76
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
std::unordered_map< string, string > StringMap
An unordered map with strings as both keys and values.
Definition: Library.h:59
#define MATERIALX_NAMESPACE_END
Definition: Generated.h:26
#define HDMTLX_API
Definition: api.h:40
Definition: value.h:164
HDMTLX_API const MaterialX::DocumentPtr & HdMtlxStdLibraries()