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 /// Converts the HdParameterValue to a string MaterialX can understand
60 HdMtlxConvertToString(VtValue const& hdParameterValue);
61 
62 // Storing MaterialX-Hydra texture and primvar information
65  : mxHdTextureMap(MaterialX::StringMap()), // Mx-Hd texture name mapping
66  hdTextureNodes(std::set<SdfPath>()), // Paths to HdTexture Nodes
67  hdPrimvarNodes(std::set<SdfPath>()) {} // Paths to HdPrimvar nodes
69  std::set<SdfPath> hdTextureNodes;
70  std::set<SdfPath> hdPrimvarNodes;
71 };
72 
73 /// Creates and returns a MaterialX Document from the given HdMaterialNetwork2
74 /// Collecting the hdTextureNodes and hdPrimvarNodes as the network is
75 /// traversed as well as the Texture name mapping between MaterialX and Hydra.
79  HdMaterialNetwork2 const& hdNetwork,
80  HdMaterialNode2 const& hdMaterialXNode,
81  SdfPath const& hdMaterialXNodePath,
82  SdfPath const& materialPath,
83  MaterialX::DocumentPtr const& libraries,
84  HdMtlxTexturePrimvarData *mxHdData = nullptr);
85 
86 /// Implementation that uses the material network interface.
90  HdMaterialNetworkInterface *netInterface,
91  TfToken const& terminalNodeName,
92  TfTokenVector const& terminalNodeConnectionNames,
93  MaterialX::DocumentPtr const& libraries,
94  HdMtlxTexturePrimvarData *mxHdData = nullptr);
95 
97 
98 #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:68
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:69
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:442
Definition: path.h:291
std::set< SdfPath > hdPrimvarNodes
Definition: hdMtlx.h:70
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
#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:167