HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
materialSchema.h
Go to the documentation of this file.
1 //
2 // Copyright 2023 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 ////////////////////////////////////////////////////////////////////////
8 
9 /* ************************************************************************** */
10 /* ** ** */
11 /* ** This file is generated by a script. ** */
12 /* ** ** */
13 /* ** Do not edit it directly (unless it is within a CUSTOM CODE section)! ** */
14 /* ** Edit hdSchemaDefs.py instead to make changes. ** */
15 /* ** ** */
16 /* ************************************************************************** */
17 
18 #ifndef PXR_IMAGING_HD_MATERIAL_SCHEMA_H
19 #define PXR_IMAGING_HD_MATERIAL_SCHEMA_H
20 
21 /// \file
22 
23 #include "pxr/imaging/hd/api.h"
25 
26 #include "pxr/imaging/hd/schema.h"
27 
28 // --(BEGIN CUSTOM CODE: Includes)--
29 // --(END CUSTOM CODE: Includes)--
30 
32 
33 // --(BEGIN CUSTOM CODE: Declares)--
34 // --(END CUSTOM CODE: Declares)--
35 
36 #define HD_MATERIAL_SCHEMA_TOKENS \
37  (material) \
38  ((universalRenderContext, "")) \
39  ((_universalRenderContextToken, "universalRenderContext")) \
40  ((all, "__all")) \
41  (terminals) \
42  (surface) \
43  (displacement) \
44  (volume) \
45 
46 TF_DECLARE_PUBLIC_TOKENS(HdMaterialSchemaTokens, HD_API,
48 
49 //-----------------------------------------------------------------------------
50 
51 
52 /// \class HdMaterialSchema
53 ///
54 /// The Material schema is a container schema that provides the correct
55 /// material definition per render context.
56 ///
57 /// For example, a material may specify several render contexts like the
58 /// universalRenderContext (""), Renderman ("ri"), Storm ("glslfx"), etc. Each
59 /// render context will then provide the specific definition for the renderer,
60 /// which is defined by the MaterialNetwork schema. The universalRenderContext
61 /// applies to all renderers.
62 ///
63 /// See "Custom Code: Schema Methods" section for ASCII art diagram.
64 ///
65 class HdMaterialSchema : public HdSchema
66 {
67 public:
68  /// \name Schema retrieval
69  /// @{
70 
71  HdMaterialSchema(HdContainerDataSourceHandle container)
72  : HdSchema(container) {}
73 
74  /// Retrieves a container data source with the schema's default name token
75  /// "material" from the parent container and constructs a
76  /// HdMaterialSchema instance.
77  /// Because the requested container data source may not exist, the result
78  /// should be checked with IsDefined() or a bool comparison before use.
79  HD_API
81  const HdContainerDataSourceHandle &fromParentContainer);
82 
83  /// @}
84 
85 // --(BEGIN CUSTOM CODE: Schema Methods)--
86 
87  /// \name ASCII Art Diagram
88  /// @{
89 
90  /// The following diagram depicts an example scene index prim
91  /// "Plastic_Material". "Plastic_Material" is a scene index prim that has
92  /// multiple container data sources, like 'material' (HdMaterialSchema) and
93  /// 'materialOverride' (HdMaterialOverrideSchema). "Plastic_Material" as a
94  /// scene index prim also has a scene index prim type, which is type
95  /// 'material'. (See HdPrimTypeTokens).
96 
97  /// Note the following:
98  /// 1. The data flows from left to right.
99  /// 2. The lines between "materialOverride" and "interfaceMappings"
100  /// are not true connections and are not backed by the
101  /// MaterialConnection schema. Each item within "materialOverride"
102  /// and "interfaceMappings" is loosely coupled by their matching
103  /// names.
104  /// 3. The connections in the diagram are drawn with an 'o' to indicate
105  /// the source where the connection was authored, and these
106  /// connections are backed by the MaterialConnection schema.
107 
108  /// +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
109  /// | |
110  /// | "Plastic_Material" [scene index prim name] |
111  /// | |
112  /// | +-----------------------------------+ +--------------------------------------------------------------------------------------------------------------------------------------------------------+ |
113  /// | | materialOverride | | material | |
114  /// | | +------------------------------+ | | +--------------------------------------------------------------------------------------------------------------------------------------------------+ | |
115  /// | | | interfaceValues | | | | ri [materialNetwork for Renderman render context] | | |
116  /// | | | | | | | +-----------------------+ +--------------------------------------------------------------------------------+ +-------------------+ | | |
117  /// | | | *globalVal = 0.2-------------+-+----+ | | |interface [parameters] | | nodes | |terminals | | | |
118  /// | | | | | | | | | | | +--------------------+ | | | | | |
119  /// | | | *globalSpecularKface = 0.666-+-+-+ +-+--+--+-+*globalVal o-----------+---+ | |"Color_Manipulate" | | +-+-o*surface | | | |
120  /// | | | | | | | | | | | | |[materialNode] | | | | | | | |
121  /// | | +------------------------------+ | +--+-+--+--+-+*globalSpecularKface o-+-+ | | | | | | | | | | |
122  /// | | | | | | | | +---+-+-*adjustVal *out+----+ | | +-------------------+ | | |
123  /// | +-----------------------------------+ | | +-----------------------+ | | | | | | | | | | |
124  /// | | | | | | +--------------------+ | +-----------------------+ +--------------------+ | | | | |
125  /// | | | | | | | |"MaterialLayer" | |"PxrSurface" | | | | | |
126  /// | | | | | | | |[materialNode] | |[materialNode] | | | | | |
127  /// | | | | | | | | | | | | | | | |
128  /// | | | +-+---+---------------------------+--+--*specularKface *out+--+-o*materialIn *out+-+-+ | | |
129  /// | | | | | | | | | | | | | |
130  /// | | | | | | | *diffuseK = 0.12 | | | | | | |
131  /// | | | | | +----------------------+ | | | +--------------------+ | | | |
132  /// | | | | | |"Color_RetargetLayer" | | | | | | | |
133  /// | | | | | |[materialNode] | +--+-o*someInput_A | | | | |
134  /// | | | | | | | | | | | | |
135  /// | | | +---+-+-*valRemapAmount *out+-----+-o*someInput_B | | | | |
136  /// | | | | | | | | | | | |
137  /// | | | | +----------------------+ +-----------------------+ | | | |
138  /// | | | | | | | |
139  /// | | | | | | | |
140  /// | | | | | | | |
141  /// | | | | | | | |
142  /// | | | +--------------------------------------------------------------------------------+ | | |
143  /// | | | | | |
144  /// | | +--------------------------------------------------------------------------------------------------------------------------------------------------+ | |
145  /// | | | |
146  /// | +--------------------------------------------------------------------------------------------------------------------------------------------------------+ |
147  /// | |
148  /// +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
149 
150  /// @}
151 
152  /// Convenience method to get the available render contexts.
153  /// This is preferable to HdMaterialSchema::GetContainer()->GetNames().
154  HD_API
156 
157  /// Return the material network schema for the universalRenderContext.
158  HD_API
160 
161  /// Return the material network schema for the given render context.
162  /// \note This does not fall back to the universalRenderContext.
163  HD_API
165  GetMaterialNetwork(TfToken const &renderContext) const;
166 
167  /// Return the first material network schema found among the given
168  /// list of render contexts, falling back to the universal context
169  /// if none of the provided contexts are found.
170  HD_API
172  TfTokenVector const &renderContexts) const;
173 
174  // Find the terminal (surface/volume/displcement) from a given data source locator.
175  HD_API
176  static TfToken
178  HdDataSourceLocator const& locator);
179 
180  HD_API
181  static TfToken
183  HdDataSourceLocator const& locator,
184  TfToken const& renderContext);
185 
186  HD_API
187  static TfToken
189  HdDataSourceLocator const& locator,
190  TfTokenVector const &Contexts);
191 
192 // --(END CUSTOM CODE: Schema Methods)--
193 
194  /// \name Member accessor
195  /// @{
196 
197  /// @}
198 
199  /// \name Schema location
200  /// @{
201 
202  /// Returns a token where the container representing this schema is found in
203  /// a container by default.
204  HD_API
205  static const TfToken &GetSchemaToken();
206 
207  /// Returns an HdDataSourceLocator (relative to the prim-level data source)
208  /// where the container representing this schema is found by default.
209  HD_API
210  static const HdDataSourceLocator &GetDefaultLocator();
211 
212  /// @}
213 
214  /// \name Schema construction
215  /// @{
216  HD_API
217  static HdContainerDataSourceHandle
219  size_t count,
220  const TfToken *names,
221  const HdDataSourceBaseHandle *values);
222 
223  /// @}
224 };
225 
227 
228 #endif
HdMaterialSchema(HdContainerDataSourceHandle container)
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
#define HD_API
Definition: api.h:23
#define HD_MATERIAL_SCHEMA_TOKENS
HD_API HdMaterialNetworkSchema GetMaterialNetwork() const
Return the material network schema for the universalRenderContext.
static HD_API HdContainerDataSourceHandle BuildRetained(size_t count, const TfToken *names, const HdDataSourceBaseHandle *values)
static HD_API HdMaterialSchema GetFromParent(const HdContainerDataSourceHandle &fromParentContainer)
Definition: token.h:70
TF_DECLARE_PUBLIC_TOKENS(HdMaterialSchemaTokens, HD_API, HD_MATERIAL_SCHEMA_TOKENS)
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
static HD_API TfToken GetLocatorTerminal(HdDataSourceLocator const &locator)
static HD_API const TfToken & GetSchemaToken()
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
HD_API TfTokenVector GetRenderContexts() const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
static HD_API const HdDataSourceLocator & GetDefaultLocator()
GLint GLsizei count
Definition: glcorearb.h:405