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& GetGeometryCode() const;
59
60 HDST_API
61 std::string const& GetDisplacementCode() const;
62
63 HDST_API
64 VtDictionary const& GetMetadata() const;
65
66 HDST_API
67 HdSt_MaterialParamVector const& GetMaterialParams() const;
68
69 // Information necessary to allocate a texture.
70 struct TextureDescriptor
71 {
72 // Name by which the texture will be accessed, i.e., the name
73 // of the accesor for thexture will be HdGet_name(...).
74 // It is generated from the input name the corresponding texture
75 // node is connected to.
76 TfToken name;
77 HdStTextureIdentifier textureId;
78 HdStTextureType type;
79 HdSamplerParameters samplerParameters;
80 // Memory request in bytes.
81 size_t memoryRequest;
82
83 // The texture is not just identified by a file path attribute
84 // on the texture prim but there is special API to texture prim
85 // to obtain the texture.
86 //
87 // This is used for draw targets.
88 bool useTexturePrimToFindTexture;
89 // This is used for draw targets and hashing.
90 SdfPath texturePrim;
91 };
92
93 using TextureDescriptorVector = std::vector<TextureDescriptor>;
94
95 HDST_API
96 TextureDescriptorVector const& GetTextureDescriptors() const;
97
98private:
99 TfToken _materialTag;
100 std::string _fragmentSource;
101 std::string _volumeSource;
102 std::string _geometrySource;
103 std::string _displacementSource;
104 VtDictionary _materialMetadata;
105 HdSt_MaterialParamVector _materialParams;
106 TextureDescriptorVector _textureDescriptors;
107 HioGlslfxSharedPtr _surfaceGfx;
108 size_t _surfaceGfxHash;
109#ifdef PXR_MATERIALX_SUPPORT_ENABLED
110 MaterialX::ShaderPtr _materialXGfx;
111#endif
112};
113
114
115
116PXR_NAMESPACE_CLOSE_SCOPE
117
118#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:43
Describes a map from network type to network.
Definition: material.h:112