All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
material.h
1//
2// Copyright 2016 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_MATERIAL_H
8#define PXR_IMAGING_HD_MATERIAL_H
9
10#include "pxr/pxr.h"
11#include "pxr/imaging/hd/api.h"
12#include "pxr/imaging/hd/sprim.h"
13#include "pxr/imaging/hd/types.h"
14#include "pxr/usd/sdr/declare.h"
15
16PXR_NAMESPACE_OPEN_SCOPE
17
21class HdMaterial : public HdSprim
22{
23public:
24 // change tracking for HdMaterial prim
25 enum DirtyBits : HdDirtyBits {
26 Clean = 0,
27 // XXX: Got to skip varying and force sync bits for now
28 DirtyParams = 1 << 2,
29 DirtyResource = 1 << 3,
30 AllDirty = (DirtyParams | DirtyResource)
31 };
32
33 HD_API
34 ~HdMaterial() override;
35
36protected:
37 HD_API
38 HdMaterial(SdfPath const& id);
39
40private:
41 // Class can not be default constructed or copied.
42 HdMaterial() = delete;
43 HdMaterial(const HdMaterial &) = delete;
44 HdMaterial &operator =(const HdMaterial &) = delete;
45};
46
47
68{
69 SdfPath inputId;
70 TfToken inputName;
71 SdfPath outputId;
72 TfToken outputName;
73};
74
75// VtValue requirements
76HD_API
77bool operator==(const HdMaterialRelationship& lhs,
78 const HdMaterialRelationship& rhs);
79
80
86{
87 SdfPath path;
88 TfToken identifier;
89 std::map<TfToken, VtValue> parameters;
90};
91
92// VtValue requirements
93HD_API
94bool operator==(const HdMaterialNode& lhs, const HdMaterialNode& rhs);
95
96
102{
103 std::vector<HdMaterialRelationship> relationships;
104 std::vector<HdMaterialNode> nodes;
105 TfTokenVector primvars;
106};
107
112{
113 std::map<TfToken, HdMaterialNetwork> map;
114 std::vector<SdfPath> terminals;
115};
116
117
126
132{
133 SdfPath upstreamNode;
134 TfToken upstreamOutputName;
135
136 bool operator==(const HdMaterialConnection2 & rhs) const {
137 return upstreamNode == rhs.upstreamNode
138 && upstreamOutputName == rhs.upstreamOutputName;
139 }
140};
141
149{
150 TfToken nodeTypeId;
151 std::map<TfToken, VtValue> parameters;
152 std::map<TfToken, std::vector<HdMaterialConnection2>> inputConnections;
153};
154
161{
162 std::map<SdfPath, HdMaterialNode2> nodes;
163 std::map<TfToken, HdMaterialConnection2> terminals;
164 TfTokenVector primvars;
165
166 bool operator==(const HdMaterialNetwork2 & rhs) const {
167 return nodes == rhs.nodes
168 && terminals == rhs.terminals
169 && primvars == rhs.primvars;
170 }
171};
172
174HD_API
175HdMaterialNetwork2 HdConvertToHdMaterialNetwork2(
176 const HdMaterialNetworkMap & hdNetworkMap,
177 bool *isVolume = nullptr);
178
181HD_API
182HdSamplerParameters HdGetSamplerParameters(
183 const HdMaterialNode2& node,
184 const SdrShaderNodeConstPtr& sdrNode,
185 const SdfPath& nodePath = SdfPath::EmptyPath());
186
192HD_API
193HdSamplerParameters HdGetSamplerParameters(
194 const TfToken& nodeTypeId,
195 const std::map<TfToken, VtValue>& parameters,
196 const SdfPath& nodePath = SdfPath::EmptyPath());
197
198// VtValue requirements
199HD_API
200std::ostream& operator<<(std::ostream& out, const HdMaterialNetwork& pv);
201HD_API
202bool operator==(const HdMaterialNetwork& lhs, const HdMaterialNetwork& rhs);
203HD_API
204bool operator!=(const HdMaterialNetwork& lhs, const HdMaterialNetwork& rhs);
205
206HD_API
207std::ostream& operator<<(std::ostream& out,
208 const HdMaterialNetworkMap& pv);
209HD_API
210bool operator==(const HdMaterialNetworkMap& lhs,
211 const HdMaterialNetworkMap& rhs);
212HD_API
213bool operator!=(const HdMaterialNetworkMap& lhs,
214 const HdMaterialNetworkMap& rhs);
215
216// VtValue requirements
217HD_API
218std::ostream& operator<<(std::ostream& out, const HdMaterialNode2& pv);
219HD_API
220bool operator==(const HdMaterialNode2& lhs, const HdMaterialNode2& rhs);
221HD_API
222bool operator!=(const HdMaterialNode2& lhs, const HdMaterialNode2& rhs);
223
224
225PXR_NAMESPACE_CLOSE_SCOPE
226
227#endif // PXR_IMAGING_HD_MATERIAL_H
Hydra Schema for a material object.
Definition: material.h:22
Collection of standard parameters such as wrap modes to sample a texture.
Definition: types.h:110
Sprim (state prim) is a base class of managing state for non-drawable scene entity (e....
Definition: sprim.h:35
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
static SDF_API const SdfPath & EmptyPath()
The empty path value, equivalent to SdfPath().
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
HdMaterialNetwork2.
Definition: material.h:132
Container of nodes and top-level terminal connections.
Definition: material.h:161
Describes a material network composed of nodes, primvars, and relationships between the nodes and ter...
Definition: material.h:102
Describes a map from network type to network.
Definition: material.h:112
Describes an instance of a node within a network A node contains a (shader) type identifier,...
Definition: material.h:149
Describes a material node which is made of a path, an identifier and a list of parameters.
Definition: material.h:86
Describes a connection between two nodes in a material.
Definition: material.h:68
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440