Loading...
Searching...
No Matches
material.h
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the Apache License, Version 2.0 (the "Apache License")
5// with the following modification; you may not use this file except in
6// compliance with the Apache License and the following modification to it:
7// Section 6. Trademarks. is deleted and replaced with:
8//
9// 6. Trademarks. This License does not grant permission to use the trade
10// names, trademarks, service marks, or product names of the Licensor
11// and its affiliates, except as required to comply with Section 4(c) of
12// the License and to reproduce the content of the NOTICE file.
13//
14// You may obtain a copy of the Apache License at
15//
16// http://www.apache.org/licenses/LICENSE-2.0
17//
18// Unless required by applicable law or agreed to in writing, software
19// distributed under the Apache License with the above modification is
20// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21// KIND, either express or implied. See the Apache License for the specific
22// language governing permissions and limitations under the Apache License.
23//
24#ifndef PXR_IMAGING_HD_MATERIAL_H
25#define PXR_IMAGING_HD_MATERIAL_H
26
27#include "pxr/pxr.h"
28#include "pxr/imaging/hd/api.h"
29#include "pxr/imaging/hd/sprim.h"
30#include "pxr/imaging/hd/types.h"
31#include "pxr/usd/sdr/declare.h"
32
33PXR_NAMESPACE_OPEN_SCOPE
34
38class HdMaterial : public HdSprim
39{
40public:
41 // change tracking for HdMaterial prim
42 enum DirtyBits : HdDirtyBits {
43 Clean = 0,
44 // XXX: Got to skip varying and force sync bits for now
45 DirtyParams = 1 << 2,
46 DirtyResource = 1 << 3,
47 AllDirty = (DirtyParams | DirtyResource)
48 };
49
50 HD_API
51 ~HdMaterial() override;
52
53protected:
54 HD_API
55 HdMaterial(SdfPath const& id);
56
57private:
58 // Class can not be default constructed or copied.
59 HdMaterial() = delete;
60 HdMaterial(const HdMaterial &) = delete;
61 HdMaterial &operator =(const HdMaterial &) = delete;
62};
63
64
85{
86 SdfPath inputId;
87 TfToken inputName;
88 SdfPath outputId;
89 TfToken outputName;
90};
91
92// VtValue requirements
93HD_API
94bool operator==(const HdMaterialRelationship& lhs,
95 const HdMaterialRelationship& rhs);
96
97
103{
104 SdfPath path;
105 TfToken identifier;
106 std::map<TfToken, VtValue> parameters;
107};
108
109// VtValue requirements
110HD_API
111bool operator==(const HdMaterialNode& lhs, const HdMaterialNode& rhs);
112
113
119{
120 std::vector<HdMaterialRelationship> relationships;
121 std::vector<HdMaterialNode> nodes;
122 TfTokenVector primvars;
123};
124
129{
130 std::map<TfToken, HdMaterialNetwork> map;
131 std::vector<SdfPath> terminals;
132};
133
134
143
149{
150 SdfPath upstreamNode;
151 TfToken upstreamOutputName;
152
153 bool operator==(const HdMaterialConnection2 & rhs) const {
154 return upstreamNode == rhs.upstreamNode
155 && upstreamOutputName == rhs.upstreamOutputName;
156 }
157};
158
166{
167 TfToken nodeTypeId;
168 std::map<TfToken, VtValue> parameters;
169 std::map<TfToken, std::vector<HdMaterialConnection2>> inputConnections;
170};
171
178{
179 std::map<SdfPath, HdMaterialNode2> nodes;
180 std::map<TfToken, HdMaterialConnection2> terminals;
181 TfTokenVector primvars;
182
183 bool operator==(const HdMaterialNetwork2 & rhs) const {
184 return nodes == rhs.nodes
185 && terminals == rhs.terminals
186 && primvars == rhs.primvars;
187 }
188};
189
191HD_API
192HdMaterialNetwork2 HdConvertToHdMaterialNetwork2(
193 const HdMaterialNetworkMap & hdNetworkMap,
194 bool *isVolume = nullptr);
195
198HD_API
199HdSamplerParameters HdGetSamplerParameters(
200 const SdfPath& nodePath,
201 const HdMaterialNode2& node,
202 const SdrShaderNodeConstPtr& sdrNode);
203
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:39
Collection of standard parameters such as wrap modes to sample a texture.
Definition: types.h:127
Sprim (state prim) is a base class of managing state for non-drawable scene entity (e....
Definition: sprim.h:52
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:291
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
HdMaterialNetwork2.
Definition: material.h:149
Container of nodes and top-level terminal connections.
Definition: material.h:178
Describes a material network composed of nodes, primvars, and relationships between the nodes and ter...
Definition: material.h:119
Describes a map from network type to network.
Definition: material.h:129
Describes an instance of a node within a network A node contains a (shader) type identifier,...
Definition: material.h:166
Describes a material node which is made of a path, an identifier and a list of parameters.
Definition: material.h:103
Describes a connection between two nodes in a material.
Definition: material.h:85
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:457