HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
lightFilter.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef USDLUX_GENERATED_LIGHTFILTER_H
8 #define USDLUX_GENERATED_LIGHTFILTER_H
9 
10 /// \file usdLux/lightFilter.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/usdLux/api.h"
15 #include "pxr/usd/usd/prim.h"
16 #include "pxr/usd/usd/stage.h"
17 #include "pxr/usd/usdLux/tokens.h"
18 
20 #include "pxr/usd/usdShade/input.h"
21 #include "pxr/usd/usdShade/output.h"
22 
23 #include "pxr/base/vt/value.h"
24 
25 #include "pxr/base/gf/vec3d.h"
26 #include "pxr/base/gf/vec3f.h"
27 #include "pxr/base/gf/matrix4d.h"
28 
29 #include "pxr/base/tf/token.h"
30 #include "pxr/base/tf/type.h"
31 
33 
34 class SdfAssetPath;
35 
36 // -------------------------------------------------------------------------- //
37 // LIGHTFILTER //
38 // -------------------------------------------------------------------------- //
39 
40 /// \class UsdLuxLightFilter
41 ///
42 /// A light filter modifies the effect of a light.
43 /// Lights refer to filters via relationships so that filters may be
44 /// shared.
45 ///
46 /// <b>Linking</b>
47 ///
48 /// Filters can be linked to geometry. Linking controls which geometry
49 /// a light-filter affects, when considering the light filters attached
50 /// to a light illuminating the geometry.
51 ///
52 /// Linking is specified as a collection (UsdCollectionAPI) which can
53 /// be accessed via GetFilterLinkCollection().
54 ///
55 ///
56 /// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
57 /// that are text/tokens, the actual token is published and defined in \ref UsdLuxTokens.
58 /// So to set an attribute to the value "rightHanded", use UsdLuxTokens->rightHanded
59 /// as the value.
60 ///
62 {
63 public:
64  /// Compile time constant representing what kind of schema this class is.
65  ///
66  /// \sa UsdSchemaKind
68 
69  /// Construct a UsdLuxLightFilter on UsdPrim \p prim .
70  /// Equivalent to UsdLuxLightFilter::Get(prim.GetStage(), prim.GetPath())
71  /// for a \em valid \p prim, but will not immediately throw an error for
72  /// an invalid \p prim
73  explicit UsdLuxLightFilter(const UsdPrim& prim=UsdPrim())
74  : UsdGeomXformable(prim)
75  {
76  }
77 
78  /// Construct a UsdLuxLightFilter on the prim held by \p schemaObj .
79  /// Should be preferred over UsdLuxLightFilter(schemaObj.GetPrim()),
80  /// as it preserves SchemaBase state.
81  explicit UsdLuxLightFilter(const UsdSchemaBase& schemaObj)
82  : UsdGeomXformable(schemaObj)
83  {
84  }
85 
86  /// Destructor.
88  virtual ~UsdLuxLightFilter();
89 
90  /// Return a vector of names of all pre-declared attributes for this schema
91  /// class and all its ancestor classes. Does not include attributes that
92  /// may be authored by custom/extended methods of the schemas involved.
94  static const TfTokenVector &
95  GetSchemaAttributeNames(bool includeInherited=true);
96 
97  /// Return a UsdLuxLightFilter holding the prim adhering to this
98  /// schema at \p path on \p stage. If no prim exists at \p path on
99  /// \p stage, or if the prim at that path does not adhere to this schema,
100  /// return an invalid schema object. This is shorthand for the following:
101  ///
102  /// \code
103  /// UsdLuxLightFilter(stage->GetPrimAtPath(path));
104  /// \endcode
105  ///
106  USDLUX_API
107  static UsdLuxLightFilter
108  Get(const UsdStagePtr &stage, const SdfPath &path);
109 
110  /// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
111  /// is defined (according to UsdPrim::IsDefined()) on this stage.
112  ///
113  /// If a prim adhering to this schema at \p path is already defined on this
114  /// stage, return that prim. Otherwise author an \a SdfPrimSpec with
115  /// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
116  /// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
117  /// with \p specifier == \a SdfSpecifierDef and empty typeName at the
118  /// current EditTarget for any nonexistent, or existing but not \a Defined
119  /// ancestors.
120  ///
121  /// The given \a path must be an absolute prim path that does not contain
122  /// any variant selections.
123  ///
124  /// If it is impossible to author any of the necessary PrimSpecs, (for
125  /// example, in case \a path cannot map to the current UsdEditTarget's
126  /// namespace) issue an error and return an invalid \a UsdPrim.
127  ///
128  /// Note that this method may return a defined prim whose typeName does not
129  /// specify this schema class, in case a stronger typeName opinion overrides
130  /// the opinion at the current EditTarget.
131  ///
132  USDLUX_API
133  static UsdLuxLightFilter
134  Define(const UsdStagePtr &stage, const SdfPath &path);
135 
136 protected:
137  /// Returns the kind of schema this class belongs to.
138  ///
139  /// \sa UsdSchemaKind
140  USDLUX_API
141  UsdSchemaKind _GetSchemaKind() const override;
142 
143 private:
144  // needs to invoke _GetStaticTfType.
145  friend class UsdSchemaRegistry;
146  USDLUX_API
147  static const TfType &_GetStaticTfType();
148 
149  static bool _IsTypedSchema();
150 
151  // override SchemaBase virtuals.
152  USDLUX_API
153  const TfType &_GetTfType() const override;
154 
155 public:
156  // --------------------------------------------------------------------- //
157  // SHADERID
158  // --------------------------------------------------------------------- //
159  /// Default ID for the light filter's shader.
160  /// This defines the shader ID for this light filter when a render context
161  /// specific shader ID is not available.
162  ///
163  /// \see GetShaderId
164  /// \see GetShaderIdAttrForRenderContext
165  /// \see SdrRegistry::GetShaderNodeByIdentifier
166  /// \see SdrRegistry::GetShaderNodeByIdentifierAndType
167  ///
168  ///
169  /// | ||
170  /// | -- | -- |
171  /// | Declaration | `uniform token lightFilter:shaderId = ""` |
172  /// | C++ Type | TfToken |
173  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
174  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
175  USDLUX_API
177 
178  /// See GetShaderIdAttr(), and also
179  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
180  /// If specified, author \p defaultValue as the attribute's default,
181  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
182  /// the default for \p writeSparsely is \c false.
183  USDLUX_API
184  UsdAttribute CreateShaderIdAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
185 
186 public:
187  // ===================================================================== //
188  // Feel free to add custom code below this line, it will be preserved by
189  // the code generator.
190  //
191  // Just remember to:
192  // - Close the class declaration with };
193  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
194  // - Close the include guard with #endif
195  // ===================================================================== //
196  // --(BEGIN CUSTOM CODE)--
197 
198  // -------------------------------------------------------------------------
199  /// \name Conversion to and from UsdShadeConnectableAPI
200  ///
201  /// @{
202 
203  /// Constructor that takes a ConnectableAPI object.
204  /// Allow implicit conversion of UsdShadeConnectableAPI to
205  /// UsdLuxLightFilter.
206  USDLUX_API
207  UsdLuxLightFilter(const UsdShadeConnectableAPI &connectable);
208 
209  /// Contructs and returns a UsdShadeConnectableAPI object with this light
210  /// filter.
211  ///
212  /// Note that most tasks can be accomplished without explicitly constructing
213  /// a UsdShadeConnectable API, since connection-related API such as
214  /// UsdShadeConnectableAPI::ConnectToSource() are static methods, and
215  /// UsdLuxLightFilter will auto-convert to a UsdShadeConnectableAPI when
216  /// passed to functions that want to act generically on a connectable
217  /// UsdShadeConnectableAPI object.
218  USDLUX_API
220 
221  /// @}
222 
223  // -------------------------------------------------------------------------
224  /// \name Outputs API
225  ///
226  /// Outputs represent a typed attribute on a light filter whose value is
227  /// computed externally.
228  ///
229  /// @{
230 
231  /// Create an output which can either have a value or can be connected.
232  /// The attribute representing the output is created in the "outputs:"
233  /// namespace. Outputs on a light filter cannot be connected, as their
234  /// value is assumed to be computed externally.
235  ///
236  USDLUX_API
238  const SdfValueTypeName& typeName);
239 
240  /// Return the requested output if it exists.
241  ///
242  USDLUX_API
243  UsdShadeOutput GetOutput(const TfToken &name) const;
244 
245  /// Outputs are represented by attributes in the "outputs:" namespace.
246  /// If \p onlyAuthored is true (the default), then only return authored
247  /// attributes; otherwise, this also returns un-authored builtins.
248  ///
249  USDLUX_API
250  std::vector<UsdShadeOutput> GetOutputs(bool onlyAuthored=true) const;
251 
252  /// @}
253 
254  // -------------------------------------------------------------------------
255 
256  /// \name Inputs API
257  ///
258  /// Inputs are connectable attribute with a typed value.
259  ///
260  /// Light filter parameters are encoded as inputs.
261  ///
262  /// @{
263 
264  /// Create an input which can either have a value or can be connected.
265  /// The attribute representing the input is created in the "inputs:"
266  /// namespace. Inputs on light filters are connectable.
267  ///
268  USDLUX_API
270  const SdfValueTypeName& typeName);
271 
272  /// Return the requested input if it exists.
273  ///
274  USDLUX_API
275  UsdShadeInput GetInput(const TfToken &name) const;
276 
277  /// Inputs are represented by attributes in the "inputs:" namespace.
278  /// If \p onlyAuthored is true (the default), then only return authored
279  /// attributes; otherwise, this also returns un-authored builtins.
280  ///
281  USDLUX_API
282  std::vector<UsdShadeInput> GetInputs(bool onlyAuthored=true) const;
283 
284  /// @}
285 
286  /// Return the UsdCollectionAPI interface used for examining and
287  /// modifying the filter-linking of this light filter. Linking
288  /// controls which geometry this light filter affects.
289  USDLUX_API
291 
292  /// Returns the shader ID attribute for the given \p renderContext.
293  ///
294  /// If \p renderContext is non-empty, this will try to return an attribute
295  /// named _lightFilter:shaderId_ with the namespace prefix \p renderContext.
296  /// For example, if the passed in render context is "ri" then the attribute
297  /// returned by this function would have the following signature:
298  /// | ||
299  /// | -- | -- |
300  /// | Declaration | `token ri:lightFilter:shaderId` |
301  /// | C++ Type | TfToken |
302  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
303  ///
304  /// If the render context is empty, this will return the default shader ID
305  /// attribute as returned by GetShaderIdAttr().
306  USDLUX_API
308  const TfToken &renderContext) const;
309 
310  /// Creates the shader ID attribute for the given \p renderContext.
311  ///
312  /// See GetShaderIdAttrForRenderContext(), and also
313  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
314  /// If specified, author \p defaultValue as the attribute's default,
315  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
316  /// the default for \p writeSparsely is \c false.
317  USDLUX_API
319  const TfToken &renderContext,
320  VtValue const &defaultValue = VtValue(),
321  bool writeSparsely=false) const;
322 
323  /// Return the light filter's shader ID for the given list of available
324  /// \p renderContexts.
325  ///
326  /// The shader ID returned by this function is the identifier to use when
327  /// looking up the shader definition for this light filter in the
328  /// \ref SdrRegistry "shader registry".
329  ///
330  /// The render contexts are expected to be listed in priority order, so
331  /// for each render context provided, this will try to find the shader ID
332  /// attribute specific to that render context (see
333  /// GetShaderIdAttrForRenderContext()) and will return the
334  /// value of the first one found that has a non-empty value. If no shader ID
335  /// value can be found for any of the given render contexts or
336  /// \p renderContexts is empty, then this will return the value of the
337  /// default shader ID attribute (see GetShaderIdAttr()).
338  USDLUX_API
339  TfToken GetShaderId(const TfTokenVector &renderContexts) const;
340 
341 };
342 
344 
345 #endif
USDLUX_API TfToken GetShaderId(const TfTokenVector &renderContexts) const
USDLUX_API UsdShadeOutput CreateOutput(const TfToken &name, const SdfValueTypeName &typeName)
static USDLUX_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
USDLUX_API UsdShadeConnectableAPI ConnectableAPI() const
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
#define USDLUX_API
Definition: api.h:23
static USDLUX_API UsdLuxLightFilter Define(const UsdStagePtr &stage, const SdfPath &path)
Definition: token.h:70
UsdLuxLightFilter(const UsdPrim &prim=UsdPrim())
Definition: lightFilter.h:73
Represents a concrete typed schema.
static const UsdSchemaKind schemaKind
Definition: lightFilter.h:67
USDLUX_API UsdAttribute CreateShaderIdAttrForRenderContext(const TfToken &renderContext, VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
virtual USDLUX_API ~UsdLuxLightFilter()
Destructor.
Definition: prim.h:116
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
GLuint const GLchar * name
Definition: glcorearb.h:786
Definition: path.h:273
USDLUX_API UsdShadeInput CreateInput(const TfToken &name, const SdfValueTypeName &typeName)
UsdSchemaKind
Definition: common.h:112
USDLUX_API UsdCollectionAPI GetFilterLinkCollectionAPI() const
USDLUX_API std::vector< UsdShadeOutput > GetOutputs(bool onlyAuthored=true) const
USDLUX_API UsdShadeInput GetInput(const TfToken &name) const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
USDLUX_API UsdAttribute GetShaderIdAttr() const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
USDLUX_API UsdAttribute GetShaderIdAttrForRenderContext(const TfToken &renderContext) const
USDLUX_API UsdSchemaKind _GetSchemaKind() const override
Definition: type.h:47
USDLUX_API UsdShadeOutput GetOutput(const TfToken &name) const
UsdLuxLightFilter(const UsdSchemaBase &schemaObj)
Definition: lightFilter.h:81
USDLUX_API UsdAttribute CreateShaderIdAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: value.h:146
USDLUX_API std::vector< UsdShadeInput > GetInputs(bool onlyAuthored=true) const
static USDLUX_API UsdLuxLightFilter Get(const UsdStagePtr &stage, const SdfPath &path)