HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
materialOverrideSchema.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_OVERRIDE_SCHEMA_H
19 #define PXR_IMAGING_HD_MATERIAL_OVERRIDE_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_OVERRIDE_SCHEMA_TOKENS \
37  (materialOverride) \
38  (interfaceValues) \
39 
40 TF_DECLARE_PUBLIC_TOKENS(HdMaterialOverrideSchemaTokens, HD_API,
42 
43 //-----------------------------------------------------------------------------
44 
45 // The MaterialOverride schema allows overrides to be made to the material's
46 // public UI. Overrides can be applied to both material or geometry scene
47 // index prim locations.
48 //
49 // The following is an example of a material override. The data source to
50 // author an override on the public UI name "globalSpecularKface" would look
51 // like this:
52 //
53 // ds at: materialOverride/interfaceValues/globalSpecularKface/value = 0.666
54 //
55 // There needs to be an interface mapping defined for "globalSpecularKface",
56 // which could look like this:
57 //
58 // ds at: material/<renderContext>/interfaceMappings/
59 // globalSpecularKface/[0]/nodePath = MaterialLayer
60 //
61 // ds at: material/<renderContext>/interfaceMappings/
62 // globalSpecularKface/[0]/inputName = specularKface
63 //
64 // The above means that the "globalSpecularKface" public UI name will map to
65 // the node parameter "specularKface", and for example, this node parameter
66 // may already have a data source for its value:
67 //
68 // ds at: material/<renderContext>/nodes/MaterialLayer/parameters/
69 // specularKface/value = 0.222
70 //
71 // After resolving the material override, the data source of the node
72 // parameter's value is replaced by the overriding value data source.
73 //
74 // ds at: material/<renderContext>/nodes/MaterialLayer/parameters/
75 // specularKface/value = 0.666
76 //
77 // Note that the MaterialOverride schema does not specify a render context
78 // token because material overrides are high-level and do not need to know
79 // about implementation details--they just need to specify an overriding data
80 // source. By contrast, the contents of a material network do specify a render
81 // context token in order to define the material nodes and interface mappings
82 // --you can imagine that a Renderman vs Storm implementation of a material
83 // network would be quite different.
84 //
85 // See also the Material schema documentation for ASCII art diagram.
86 //
87 
89 {
90 public:
91  /// \name Schema retrieval
92  /// @{
93 
94  HdMaterialOverrideSchema(HdContainerDataSourceHandle container)
95  : HdSchema(container) {}
96 
97  /// Retrieves a container data source with the schema's default name token
98  /// "materialOverride" from the parent container and constructs a
99  /// HdMaterialOverrideSchema instance.
100  /// Because the requested container data source may not exist, the result
101  /// should be checked with IsDefined() or a bool comparison before use.
102  HD_API
104  const HdContainerDataSourceHandle &fromParentContainer);
105 
106  /// @}
107 
108 // --(BEGIN CUSTOM CODE: Schema Methods)--
109 // --(END CUSTOM CODE: Schema Methods)--
110 
111  /// \name Member accessor
112  /// @{
113 
114  /// Maps interface names (ie. public UI names) to overriding data sources
115  /// that follow the MaterialNodeParameter schema.
116  HD_API
118 
119  /// @}
120 
121  /// \name Schema location
122  /// @{
123 
124  /// Returns a token where the container representing this schema is found in
125  /// a container by default.
126  HD_API
127  static const TfToken &GetSchemaToken();
128 
129  /// Returns an HdDataSourceLocator (relative to the prim-level data source)
130  /// where the container representing this schema is found by default.
131  HD_API
132  static const HdDataSourceLocator &GetDefaultLocator();
133 
134  /// @}
135 
136  /// \name Schema construction
137  /// @{
138 
139  /// \deprecated Use Builder instead.
140  ///
141  /// Builds a container data source which includes the provided child data
142  /// sources. Parameters with nullptr values are excluded. This is a
143  /// low-level interface. For cases in which it's desired to define
144  /// the container with a sparse set of child fields, the Builder class
145  /// is often more convenient and readable.
146  HD_API
147  static HdContainerDataSourceHandle
149  const HdContainerDataSourceHandle &interfaceValues
150  );
151 
152  /// \class HdMaterialOverrideSchema::Builder
153  ///
154  /// Utility class for setting sparse sets of child data source fields to be
155  /// filled as arguments into BuildRetained. Because all setter methods
156  /// return a reference to the instance, this can be used in the "builder
157  /// pattern" form.
158  class Builder
159  {
160  public:
161  HD_API
163  const HdContainerDataSourceHandle &interfaceValues);
164 
165  /// Returns a container data source containing the members set thus far.
166  HD_API
167  HdContainerDataSourceHandle Build();
168 
169  private:
170  HdContainerDataSourceHandle _interfaceValues;
171 
172  };
173 
174  /// @}
175 };
176 
178 
179 #endif
HD_API HdMaterialNodeParameterContainerSchema GetInterfaceValues() const
TF_DECLARE_PUBLIC_TOKENS(HdMaterialOverrideSchemaTokens, HD_API, HD_MATERIAL_OVERRIDE_SCHEMA_TOKENS)
#define HD_API
Definition: api.h:23
HdMaterialOverrideSchema(HdContainerDataSourceHandle container)
static HD_API HdMaterialOverrideSchema GetFromParent(const HdContainerDataSourceHandle &fromParentContainer)
static HD_API HdContainerDataSourceHandle BuildRetained(const HdContainerDataSourceHandle &interfaceValues)
Definition: token.h:70
static HD_API const TfToken & GetSchemaToken()
HD_API Builder & SetInterfaceValues(const HdContainerDataSourceHandle &interfaceValues)
HD_API HdContainerDataSourceHandle Build()
Returns a container data source containing the members set thus far.
static HD_API const HdDataSourceLocator & GetDefaultLocator()
#define HD_MATERIAL_OVERRIDE_SCHEMA_TOKENS
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74