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
31PXR_NAMESPACE_OPEN_SCOPE
32
36class HdMaterial : public HdSprim
37{
38public:
39 // change tracking for HdMaterial prim
40 enum DirtyBits : HdDirtyBits {
41 Clean = 0,
42 // XXX: Got to skip varying and force sync bits for now
43 DirtyParams = 1 << 2,
44 DirtyResource = 1 << 3,
45 AllDirty = (DirtyParams | DirtyResource)
46 };
47
48 HD_API
49 ~HdMaterial() override;
50
51protected:
52 HD_API
53 HdMaterial(SdfPath const& id);
54
55private:
56 // Class can not be default constructed or copied.
57 HdMaterial() = delete;
58 HdMaterial(const HdMaterial &) = delete;
59 HdMaterial &operator =(const HdMaterial &) = delete;
60};
61
62
83{
84 SdfPath inputId;
85 TfToken inputName;
86 SdfPath outputId;
87 TfToken outputName;
88};
89
90// VtValue requirements
91HD_API
92bool operator==(const HdMaterialRelationship& lhs,
93 const HdMaterialRelationship& rhs);
94
95
101{
102 SdfPath path;
103 TfToken identifier;
104 std::map<TfToken, VtValue> parameters;
105};
106
107// VtValue requirements
108HD_API
109bool operator==(const HdMaterialNode& lhs, const HdMaterialNode& rhs);
110
111
117{
118 std::vector<HdMaterialRelationship> relationships;
119 std::vector<HdMaterialNode> nodes;
120 TfTokenVector primvars;
121};
122
127{
128 std::map<TfToken, HdMaterialNetwork> map;
129 std::vector<SdfPath> terminals;
130};
131
132
141
147{
148 SdfPath upstreamNode;
149 TfToken upstreamOutputName;
150
151 bool operator==(const HdMaterialConnection2 & rhs) const {
152 return upstreamNode == rhs.upstreamNode
153 && upstreamOutputName == rhs.upstreamOutputName;
154 }
155};
156
164{
165 TfToken nodeTypeId;
166 std::map<TfToken, VtValue> parameters;
167 std::map<TfToken, std::vector<HdMaterialConnection2>> inputConnections;
168};
169
176{
177 std::map<SdfPath, HdMaterialNode2> nodes;
178 std::map<TfToken, HdMaterialConnection2> terminals;
179 TfTokenVector primvars;
180
181 bool operator==(const HdMaterialNetwork2 & rhs) const {
182 return nodes == rhs.nodes
183 && terminals == rhs.terminals
184 && primvars == rhs.primvars;
185 }
186};
187
189HD_API
190HdMaterialNetwork2 HdConvertToHdMaterialNetwork2(
191 const HdMaterialNetworkMap & hdNetworkMap,
192 bool *isVolume = nullptr);
193
194
195// VtValue requirements
196HD_API
197std::ostream& operator<<(std::ostream& out, const HdMaterialNetwork& pv);
198HD_API
199bool operator==(const HdMaterialNetwork& lhs, const HdMaterialNetwork& rhs);
200HD_API
201bool operator!=(const HdMaterialNetwork& lhs, const HdMaterialNetwork& rhs);
202
203HD_API
204std::ostream& operator<<(std::ostream& out,
205 const HdMaterialNetworkMap& pv);
206HD_API
207bool operator==(const HdMaterialNetworkMap& lhs,
208 const HdMaterialNetworkMap& rhs);
209HD_API
210bool operator!=(const HdMaterialNetworkMap& lhs,
211 const HdMaterialNetworkMap& rhs);
212
213// VtValue requirements
214HD_API
215std::ostream& operator<<(std::ostream& out, const HdMaterialNode2& pv);
216HD_API
217bool operator==(const HdMaterialNode2& lhs, const HdMaterialNode2& rhs);
218HD_API
219bool operator!=(const HdMaterialNode2& lhs, const HdMaterialNode2& rhs);
220
221
222PXR_NAMESPACE_CLOSE_SCOPE
223
224#endif // PXR_IMAGING_HD_MATERIAL_H
Hydra Schema for a material object.
Definition: material.h:37
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:147
Container of nodes and top-level terminal connections.
Definition: material.h:176
Describes a material network composed of nodes, primvars, and relationships between the nodes and ter...
Definition: material.h:117
Describes a map from network type to network.
Definition: material.h:127
Describes an instance of a node within a network A node contains a (shader) type identifier,...
Definition: material.h:164
Describes a material node which is made of a path, an identifier and a list of parameters.
Definition: material.h:101
Describes a connection between two nodes in a material.
Definition: material.h:83
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442