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)--
30 // --(END CUSTOM CODE: Includes)--
31 
33 
34 // --(BEGIN CUSTOM CODE: Declares)--
37 // --(END CUSTOM CODE: Declares)--
38 
39 #define HD_MATERIAL_OVERRIDE_SCHEMA_TOKENS \
40  (materialOverride) \
41  (interfaceValues) \
42  (parameterValues) \
43 
44 TF_DECLARE_PUBLIC_TOKENS(HdMaterialOverrideSchemaTokens, HD_API,
46 
47 //-----------------------------------------------------------------------------
48 
49 
50 /// \class HdMaterialOverrideSchema
51 ///
52 /// The MaterialOverride schema allows overrides to be made to various parts of
53 /// materials, such as the public UI or shader nodes' parameters. Overrides can
54 /// be applied to material scene index prim locations.
55 ///
56 /// The following is an example of a material override affecting a material's
57 /// public UI. The data source to author an override on the public UI name
58 /// "globalSpecularKface" would look like this:
59 ///
60 /// ds at: materialOverride/interfaceValues/globalSpecularKface/value = 0.666
61 ///
62 /// There needs to be an interface mapping defined for "globalSpecularKface",
63 /// which could look like this:
64 ///
65 /// ds at: material/<renderContext>/interface/parameters/
66 /// globalSpecularKface/mappings/[0]/nodePath = MaterialLayer
67 ///
68 /// ds at: material/<renderContext>/interface/parameters/
69 /// globalSpecularKface/mappings/[0]/inputName = specularKface
70 ///
71 /// The above means that the "globalSpecularKface" public UI name will map to
72 /// the node parameter "specularKface", and for example, this node parameter
73 /// may already have a data source for its value:
74 ///
75 /// ds at: material/<renderContext>/nodes/MaterialLayer/parameters/
76 /// specularKface/value = 0.222
77 ///
78 /// After resolving the material override, the data source of the node
79 /// parameter's value is replaced by the overriding value data source.
80 ///
81 /// ds at: material/<renderContext>/nodes/MaterialLayer/parameters/
82 /// specularKface/value = 0.666
83 ///
84 /// The following is an example of a material override affecting a shader
85 /// node's input parameter value. The data source to author to an override on
86 /// the input parameter called "useClamp" on shader node named
87 /// "ManipulateColor" would look like this:
88 ///
89 /// ds at: materialOverride/parameterValues/ManipulateColor/useClamp/ value = 0
90 ///
91 /// The data source of the node parameter's value will be replaced by the
92 /// overriding value data source.
93 ///
94 /// ds at: material/<renderContext>/nodes/ManipulateColor/parameters/
95 /// useClamp/value = 0
96 ///
97 /// Note that the MaterialOverride schema does not specify a render context
98 /// token because material overrides are high-level and do not need to know
99 /// about implementation details--they just need to specify an overriding data
100 /// source. By contrast, the contents of a material network do specify a render
101 /// context token in order to define the material nodes and interface mappings
102 /// --you can imagine that a Renderman vs Storm implementation of a material
103 /// network would be quite different.
104 ///
105 /// In the event where the same parameter has conflicting overrides applied
106 /// both though interface and parameter values, the overrides set through the
107 /// interface values will take precedence.
108 ///
109 /// See also the Material schema documentation for ASCII art diagram.
110 ///
112 {
113 public:
114  /// \name Schema retrieval
115  /// @{
116 
117  HdMaterialOverrideSchema(HdContainerDataSourceHandle container)
118  : HdSchema(container) {}
119 
120  /// Retrieves a container data source with the schema's default name token
121  /// "materialOverride" from the parent container and constructs a
122  /// HdMaterialOverrideSchema instance.
123  /// Because the requested container data source may not exist, the result
124  /// should be checked with IsDefined() or a bool comparison before use.
125  HD_API
127  const HdContainerDataSourceHandle &fromParentContainer);
128 
129  /// @}
130 
131 // --(BEGIN CUSTOM CODE: Schema Methods)--
132 
133  /// Utility method to retrieve the data source for a parameter edit override.
134  /// Returns the data source for the parameter edit of the parameter named
135  /// \p parameterName owned by shader node named \p shaderNodeName.
136  HD_API
138  const TfToken& shaderNodeName, const TfToken& parameterName) const;
139 
140 // --(END CUSTOM CODE: Schema Methods)--
141 
142  /// \name Member accessor
143  /// @{
144 
145  /// Maps interface names (ie. public UI names) to overriding data sources
146  /// that follow the MaterialNodeParameter schema.
147  HD_API
149 
150  /// Contains names of shader nodes whose parameters values are overridden.
151  /// Each parameter within a shader node locator contains overriding data
152  /// sources that follow the MaterialNodeParameter schema.
153  HD_API
155 
156  /// @}
157 
158  /// \name Schema location
159  /// @{
160 
161  /// Returns a token where the container representing this schema is found in
162  /// a container by default.
163  HD_API
164  static const TfToken &GetSchemaToken();
165 
166  /// Returns an HdDataSourceLocator (relative to the prim-level data source)
167  /// where the container representing this schema is found by default.
168  HD_API
169  static const HdDataSourceLocator &GetDefaultLocator();
170 
171  /// @}
172 
173  /// \name Schema construction
174  /// @{
175 
176  /// \deprecated Use Builder instead.
177  ///
178  /// Builds a container data source which includes the provided child data
179  /// sources. Parameters with nullptr values are excluded. This is a
180  /// low-level interface. For cases in which it's desired to define
181  /// the container with a sparse set of child fields, the Builder class
182  /// is often more convenient and readable.
183  HD_API
184  static HdContainerDataSourceHandle
186  const HdContainerDataSourceHandle &interfaceValues,
187  const HdContainerDataSourceHandle &parameterValues
188  );
189 
190  /// \class HdMaterialOverrideSchema::Builder
191  ///
192  /// Utility class for setting sparse sets of child data source fields to be
193  /// filled as arguments into BuildRetained. Because all setter methods
194  /// return a reference to the instance, this can be used in the "builder
195  /// pattern" form.
196  class Builder
197  {
198  public:
199  HD_API
201  const HdContainerDataSourceHandle &interfaceValues);
202  HD_API
204  const HdContainerDataSourceHandle &parameterValues);
205 
206  /// Returns a container data source containing the members set thus far.
207  HD_API
208  HdContainerDataSourceHandle Build();
209 
210  private:
211  HdContainerDataSourceHandle _interfaceValues;
212  HdContainerDataSourceHandle _parameterValues;
213 
214  };
215 
216  /// @}
217 };
218 
220 
221 #endif
HD_API HdMaterialNodeParameterContainerSchema GetInterfaceValues() const
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
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)
HD_API Builder & SetParameterValues(const HdContainerDataSourceHandle &parameterValues)
Definition: token.h:70
HD_API HdMaterialNodeParameterSchema GetParameterOverride(const TfToken &shaderNodeName, const TfToken &parameterName) const
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
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HD_API HdNodeToInputToMaterialNodeParameterSchema GetParameterValues() const
static HD_API HdContainerDataSourceHandle BuildRetained(const HdContainerDataSourceHandle &interfaceValues, const HdContainerDataSourceHandle &parameterValues)