Loading...
Searching...
No Matches
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"
16
17PXR_NAMESPACE_OPEN_SCOPE
18
22class HdMaterial : public HdSprim
23{
24public:
25 // change tracking for HdMaterial prim
26 enum DirtyBits : HdDirtyBits {
27 Clean = 0,
28 // XXX: Got to skip varying and force sync bits for now
29 DirtyParams = 1 << 2,
30 DirtyResource = 1 << 3,
31 DirtySurface = 1 << 4,
32 DirtyDisplacement = 1 << 5,
33 DirtyVolume = 1 << 6,
34 AllDirty = (DirtyParams | DirtyResource | DirtySurface | DirtyDisplacement | DirtyVolume)
35 };
36
37 HD_API
38 ~HdMaterial() override;
39
40protected:
41 HD_API
42 HdMaterial(SdfPath const& id);
43
44private:
45 // Class can not be default constructed or copied.
46 HdMaterial() = delete;
47 HdMaterial(const HdMaterial &) = delete;
48 HdMaterial &operator =(const HdMaterial &) = delete;
49};
50
51
72{
73 SdfPath inputId;
74 TfToken inputName;
75 SdfPath outputId;
76 TfToken outputName;
77};
78
79// VtValue requirements
80HD_API
81bool operator==(const HdMaterialRelationship& lhs,
82 const HdMaterialRelationship& rhs);
83
84
90{
91 SdfPath path;
92 TfToken identifier;
93 std::map<TfToken, VtValue> parameters;
94};
95
96// VtValue requirements
97HD_API
98bool operator==(const HdMaterialNode& lhs, const HdMaterialNode& rhs);
99
100
106{
107 std::vector<HdMaterialRelationship> relationships;
108 std::vector<HdMaterialNode> nodes;
109 TfTokenVector primvars;
110};
111
116{
117 std::map<TfToken, HdMaterialNetwork> map;
118 std::vector<SdfPath> terminals;
119 VtDictionary config;
120};
121
122
131
137{
138 SdfPath upstreamNode;
139 TfToken upstreamOutputName;
140
141 bool operator==(const HdMaterialConnection2 & rhs) const {
142 return upstreamNode == rhs.upstreamNode
143 && upstreamOutputName == rhs.upstreamOutputName;
144 }
145};
146
154{
155 TfToken nodeTypeId;
156 std::map<TfToken, VtValue> parameters;
157 std::map<TfToken, std::vector<HdMaterialConnection2>> inputConnections;
158};
159
166{
167 std::map<SdfPath, HdMaterialNode2> nodes;
168 std::map<TfToken, HdMaterialConnection2> terminals;
169 TfTokenVector primvars;
170 VtDictionary config;
171
172 bool operator==(const HdMaterialNetwork2 & rhs) const {
173 return nodes == rhs.nodes
174 && terminals == rhs.terminals
175 && primvars == rhs.primvars
176 && config == rhs.config;
177 }
178};
179
181HD_API
182HdMaterialNetwork2 HdConvertToHdMaterialNetwork2(
183 const HdMaterialNetworkMap & hdNetworkMap,
184 bool *isVolume = nullptr);
185
188HD_API
189HdSamplerParameters HdGetSamplerParameters(
190 const HdMaterialNode2& node,
191 const SdrShaderNodeConstPtr& sdrNode,
192 const SdfPath& nodePath = SdfPath::EmptyPath());
193
199HD_API
200HdSamplerParameters HdGetSamplerParameters(
201 const TfToken& nodeTypeId,
202 const std::map<TfToken, VtValue>& parameters,
203 const SdfPath& nodePath = SdfPath::EmptyPath());
204
205// VtValue requirements
206HD_API
207std::ostream& operator<<(std::ostream& out, const HdMaterialNetwork& pv);
208HD_API
209bool operator==(const HdMaterialNetwork& lhs, const HdMaterialNetwork& rhs);
210HD_API
211bool operator!=(const HdMaterialNetwork& lhs, const HdMaterialNetwork& rhs);
212
213HD_API
214std::ostream& operator<<(std::ostream& out,
215 const HdMaterialNetworkMap& pv);
216HD_API
217bool operator==(const HdMaterialNetworkMap& lhs,
218 const HdMaterialNetworkMap& rhs);
219HD_API
220bool operator!=(const HdMaterialNetworkMap& lhs,
221 const HdMaterialNetworkMap& rhs);
222
223// VtValue requirements
224HD_API
225std::ostream& operator<<(std::ostream& out, const HdMaterialNode2& pv);
226HD_API
227bool operator==(const HdMaterialNode2& lhs, const HdMaterialNode2& rhs);
228HD_API
229bool operator!=(const HdMaterialNode2& lhs, const HdMaterialNode2& rhs);
230
231
232PXR_NAMESPACE_CLOSE_SCOPE
233
234#endif // PXR_IMAGING_HD_MATERIAL_H
Hydra Schema for a material object.
Definition: material.h:23
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
A map with string keys and VtValue values.
Definition: dictionary.h:52
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
HdMaterialNetwork2.
Definition: material.h:137
Container of nodes and top-level terminal connections.
Definition: material.h:166
Describes a material network composed of nodes, primvars, and relationships between the nodes and ter...
Definition: material.h:106
Describes a map from network type to network.
Definition: material.h:116
Describes an instance of a node within a network A node contains a (shader) type identifier,...
Definition: material.h:154
Describes a material node which is made of a path, an identifier and a list of parameters.
Definition: material.h:90
Describes a connection between two nodes in a material.
Definition: material.h:72
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440