Loading...
Searching...
No Matches
materialNetwork.h
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"
13#include "pxr/imaging/hd/material.h"
14#include "pxr/imaging/hdSt/textureIdentifier.h"
16
17#ifdef PXR_MATERIALX_SUPPORT_ENABLED
18#include <MaterialXGenShader/Shader.h>
19#endif
20
21PXR_NAMESPACE_OPEN_SCOPE
22
24using HioGlslfxSharedPtr = std::shared_ptr<class HioGlslfx>;
25using HdSt_MaterialParamVector = std::vector<class HdSt_MaterialParam>;
26
32{
33public:
34 HDST_API
36
37 HDST_API
39
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
64 HdSt_MaterialParamVector const& GetMaterialParams() const;
65
66 // Information necessary to allocate a texture.
67 struct TextureDescriptor
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.
73 TfToken name;
74 HdStTextureIdentifier textureId;
75 HdStTextureType type;
76 HdSamplerParameters samplerParameters;
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.
85 bool useTexturePrimToFindTexture;
86 // This is used for draw targets and hashing.
87 SdfPath texturePrim;
88 };
89
90 using TextureDescriptorVector = std::vector<TextureDescriptor>;
91
92 HDST_API
93 TextureDescriptorVector const& GetTextureDescriptors() const;
94
95private:
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
112PXR_NAMESPACE_CLOSE_SCOPE
113
114#endif
Collection of standard parameters such as wrap modes to sample a texture.
Definition: types.h:110
Helps HdStMaterial process a Hydra material network into shader source code and parameters values.
HDST_API void ProcessMaterialNetwork(SdfPath const &materialId, HdMaterialNetworkMap const &hdNetworkMap, HdStResourceRegistry *resourceRegistry)
Process a material network topology and extract all the information we need from it.
A central registry of all GPU resources.
Class to identify a texture file or a texture within the texture file (e.g., a frame in a movie).
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
A map with string keys and VtValue values.
Definition: dictionary.h:52
Describes a map from network type to network.
Definition: material.h:116