HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
materialNetwork.h
Go to the documentation of this file.
1 //
2 // Copyright 2019 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_ST_MATERIAL_NETWORK_H
8 #define PXR_IMAGING_HD_ST_MATERIAL_NETWORK_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hdSt/api.h"
12 #include "pxr/imaging/hdSt/enums.h"
15 #include "pxr/base/vt/dictionary.h"
16 
17 #ifdef PXR_MATERIALX_SUPPORT_ENABLED
19 #endif
20 
22 
24 using HioGlslfxSharedPtr = std::shared_ptr<class HioGlslfx>;
25 using HdSt_MaterialParamVector = std::vector<class HdSt_MaterialParam>;
26 
27 /// \class HdStMaterialNetwork
28 ///
29 /// Helps HdStMaterial process a Hydra material network into shader source code
30 /// and parameters values.
32 {
33 public:
34  HDST_API
36 
37  HDST_API
39 
40  /// Process a material network topology and extract all the information we
41  /// need from it.
42  HDST_API
44  SdfPath const& materialId,
45  HdMaterialNetworkMap const& hdNetworkMap,
46  HdStResourceRegistry *resourceRegistry);
47 
48  HDST_API
49  TfToken const& GetMaterialTag() const;
50 
51  HDST_API
52  std::string const& GetFragmentCode() const;
53 
54  HDST_API
55  std::string const& GetVolumeCode() const;
56 
57  HDST_API
58  std::string const& GetDisplacementCode() const;
59 
60  HDST_API
61  VtDictionary const& GetMetadata() const;
62 
63  HDST_API
65 
66  // Information necessary to allocate a texture.
68  {
69  // Name by which the texture will be accessed, i.e., the name
70  // of the accesor for thexture will be HdGet_name(...).
71  // It is generated from the input name the corresponding texture
72  // node is connected to.
77  // Memory request in bytes.
78  size_t memoryRequest;
79 
80  // The texture is not just identified by a file path attribute
81  // on the texture prim but there is special API to texture prim
82  // to obtain the texture.
83  //
84  // This is used for draw targets.
86  // This is used for draw targets and hashing.
88  };
89 
90  using TextureDescriptorVector = std::vector<TextureDescriptor>;
91 
92  HDST_API
94 
95 private:
96  TfToken _materialTag;
97  std::string _fragmentSource;
98  std::string _volumeSource;
99  std::string _displacementSource;
100  VtDictionary _materialMetadata;
101  HdSt_MaterialParamVector _materialParams;
102  TextureDescriptorVector _textureDescriptors;
103  HioGlslfxSharedPtr _surfaceGfx;
104  size_t _surfaceGfxHash;
105 #ifdef PXR_MATERIALX_SUPPORT_ENABLED
106  MaterialX::ShaderPtr _materialXGfx;
107 #endif
108 };
109 
110 
111 
113 
114 #endif
HDST_API void ProcessMaterialNetwork(SdfPath const &materialId, HdMaterialNetworkMap const &hdNetworkMap, HdStResourceRegistry *resourceRegistry)
HDST_API VtDictionary const & GetMetadata() const
HDST_API TextureDescriptorVector const & GetTextureDescriptors() const
HDST_API ~HdStMaterialNetwork()
HDST_API std::string const & GetFragmentCode() const
Definition: token.h:70
HDST_API HdSt_MaterialParamVector const & GetMaterialParams() const
HDST_API std::string const & GetVolumeCode() const
Definition: path.h:273
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
HDST_API std::string const & GetDisplacementCode() const
#define HDST_API
Definition: api.h:23
HDST_API HdStMaterialNetwork()
std::shared_ptr< class HioGlslfx > HioGlslfxSharedPtr
Definition: glslfxShader.h:17
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HdStTextureType
Definition: enums.h:30
shared_ptr< Shader > ShaderPtr
Shared pointer to a Shader.
Definition: Library.h:33
HDST_API TfToken const & GetMaterialTag() const
std::vector< TextureDescriptor > TextureDescriptorVector
std::vector< class HdSt_MaterialParam > HdSt_MaterialParamVector