HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
shadowAPI.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_SHADOWAPI_H
8 #define USDLUX_GENERATED_SHADOWAPI_H
9 
10 /// \file usdLux/shadowAPI.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 
19 #include "pxr/usd/usdShade/input.h"
20 #include "pxr/usd/usdShade/output.h"
21 
22 #include "pxr/base/vt/value.h"
23 
24 #include "pxr/base/gf/vec3d.h"
25 #include "pxr/base/gf/vec3f.h"
26 #include "pxr/base/gf/matrix4d.h"
27 
28 #include "pxr/base/tf/token.h"
29 #include "pxr/base/tf/type.h"
30 
32 
33 class SdfAssetPath;
34 
35 // -------------------------------------------------------------------------- //
36 // SHADOWAPI //
37 // -------------------------------------------------------------------------- //
38 
39 /// \class UsdLuxShadowAPI
40 ///
41 /// Controls to refine a light's shadow behavior. These are
42 /// non-physical controls that are valuable for visual lighting work.
43 ///
45 {
46 public:
47  /// Compile time constant representing what kind of schema this class is.
48  ///
49  /// \sa UsdSchemaKind
51 
52  /// Construct a UsdLuxShadowAPI on UsdPrim \p prim .
53  /// Equivalent to UsdLuxShadowAPI::Get(prim.GetStage(), prim.GetPath())
54  /// for a \em valid \p prim, but will not immediately throw an error for
55  /// an invalid \p prim
56  explicit UsdLuxShadowAPI(const UsdPrim& prim=UsdPrim())
57  : UsdAPISchemaBase(prim)
58  {
59  }
60 
61  /// Construct a UsdLuxShadowAPI on the prim held by \p schemaObj .
62  /// Should be preferred over UsdLuxShadowAPI(schemaObj.GetPrim()),
63  /// as it preserves SchemaBase state.
64  explicit UsdLuxShadowAPI(const UsdSchemaBase& schemaObj)
65  : UsdAPISchemaBase(schemaObj)
66  {
67  }
68 
69  /// Destructor.
71  virtual ~UsdLuxShadowAPI();
72 
73  /// Return a vector of names of all pre-declared attributes for this schema
74  /// class and all its ancestor classes. Does not include attributes that
75  /// may be authored by custom/extended methods of the schemas involved.
77  static const TfTokenVector &
78  GetSchemaAttributeNames(bool includeInherited=true);
79 
80  /// Return a UsdLuxShadowAPI holding the prim adhering to this
81  /// schema at \p path on \p stage. If no prim exists at \p path on
82  /// \p stage, or if the prim at that path does not adhere to this schema,
83  /// return an invalid schema object. This is shorthand for the following:
84  ///
85  /// \code
86  /// UsdLuxShadowAPI(stage->GetPrimAtPath(path));
87  /// \endcode
88  ///
90  static UsdLuxShadowAPI
91  Get(const UsdStagePtr &stage, const SdfPath &path);
92 
93 
94  /// Returns true if this <b>single-apply</b> API schema can be applied to
95  /// the given \p prim. If this schema can not be a applied to the prim,
96  /// this returns false and, if provided, populates \p whyNot with the
97  /// reason it can not be applied.
98  ///
99  /// Note that if CanApply returns false, that does not necessarily imply
100  /// that calling Apply will fail. Callers are expected to call CanApply
101  /// before calling Apply if they want to ensure that it is valid to
102  /// apply a schema.
103  ///
104  /// \sa UsdPrim::GetAppliedSchemas()
105  /// \sa UsdPrim::HasAPI()
106  /// \sa UsdPrim::CanApplyAPI()
107  /// \sa UsdPrim::ApplyAPI()
108  /// \sa UsdPrim::RemoveAPI()
109  ///
110  USDLUX_API
111  static bool
112  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
113 
114  /// Applies this <b>single-apply</b> API schema to the given \p prim.
115  /// This information is stored by adding "ShadowAPI" to the
116  /// token-valued, listOp metadata \em apiSchemas on the prim.
117  ///
118  /// \return A valid UsdLuxShadowAPI object is returned upon success.
119  /// An invalid (or empty) UsdLuxShadowAPI object is returned upon
120  /// failure. See \ref UsdPrim::ApplyAPI() for conditions
121  /// resulting in failure.
122  ///
123  /// \sa UsdPrim::GetAppliedSchemas()
124  /// \sa UsdPrim::HasAPI()
125  /// \sa UsdPrim::CanApplyAPI()
126  /// \sa UsdPrim::ApplyAPI()
127  /// \sa UsdPrim::RemoveAPI()
128  ///
129  USDLUX_API
130  static UsdLuxShadowAPI
131  Apply(const UsdPrim &prim);
132 
133 protected:
134  /// Returns the kind of schema this class belongs to.
135  ///
136  /// \sa UsdSchemaKind
137  USDLUX_API
138  UsdSchemaKind _GetSchemaKind() const override;
139 
140 private:
141  // needs to invoke _GetStaticTfType.
142  friend class UsdSchemaRegistry;
143  USDLUX_API
144  static const TfType &_GetStaticTfType();
145 
146  static bool _IsTypedSchema();
147 
148  // override SchemaBase virtuals.
149  USDLUX_API
150  const TfType &_GetTfType() const override;
151 
152 public:
153  // --------------------------------------------------------------------- //
154  // SHADOW:ENABLE
155  // --------------------------------------------------------------------- //
156  /// Enables shadows to be cast by this light.
157  ///
158  /// | ||
159  /// | -- | -- |
160  /// | Declaration | `bool inputs:shadow:enable = 1` |
161  /// | C++ Type | bool |
162  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Bool |
163  USDLUX_API
165 
166  /// See GetShadowEnableAttr(), and also
167  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
168  /// If specified, author \p defaultValue as the attribute's default,
169  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
170  /// the default for \p writeSparsely is \c false.
171  USDLUX_API
172  UsdAttribute CreateShadowEnableAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
173 
174 public:
175  // --------------------------------------------------------------------- //
176  // SHADOW:COLOR
177  // --------------------------------------------------------------------- //
178  /// The color of shadows cast by the light. This is a
179  /// non-physical control. The default is to cast black shadows.
180  ///
181  /// | ||
182  /// | -- | -- |
183  /// | Declaration | `color3f inputs:shadow:color = (0, 0, 0)` |
184  /// | C++ Type | GfVec3f |
185  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Color3f |
186  USDLUX_API
188 
189  /// See GetShadowColorAttr(), and also
190  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
191  /// If specified, author \p defaultValue as the attribute's default,
192  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
193  /// the default for \p writeSparsely is \c false.
194  USDLUX_API
195  UsdAttribute CreateShadowColorAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
196 
197 public:
198  // --------------------------------------------------------------------- //
199  // SHADOW:DISTANCE
200  // --------------------------------------------------------------------- //
201  /// The maximum distance shadows are cast. The distance is
202  /// measured as the distance between the point on the surface and the
203  /// occluder.
204  /// The default value (-1) indicates no limit.
205  ///
206  ///
207  /// | ||
208  /// | -- | -- |
209  /// | Declaration | `float inputs:shadow:distance = -1` |
210  /// | C++ Type | float |
211  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
212  USDLUX_API
214 
215  /// See GetShadowDistanceAttr(), and also
216  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
217  /// If specified, author \p defaultValue as the attribute's default,
218  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
219  /// the default for \p writeSparsely is \c false.
220  USDLUX_API
221  UsdAttribute CreateShadowDistanceAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
222 
223 public:
224  // --------------------------------------------------------------------- //
225  // SHADOW:FALLOFF
226  // --------------------------------------------------------------------- //
227  /// The size of the shadow falloff zone within the shadow max
228  /// distance, which can be used to hide the hard cut-off for shadows seen
229  /// stretching past the max distance. The falloff zone is the area that
230  /// fades from full shadowing at the beginning of the falloff zone to no
231  /// shadowing at the max distance from the occluder. The falloff zone
232  /// distance cannot exceed the shadow max distance. A falloff value equal
233  /// to or less than zero (with -1 as the default) indicates no falloff.
234  ///
235  ///
236  /// | ||
237  /// | -- | -- |
238  /// | Declaration | `float inputs:shadow:falloff = -1` |
239  /// | C++ Type | float |
240  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
241  USDLUX_API
243 
244  /// See GetShadowFalloffAttr(), and also
245  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
246  /// If specified, author \p defaultValue as the attribute's default,
247  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
248  /// the default for \p writeSparsely is \c false.
249  USDLUX_API
250  UsdAttribute CreateShadowFalloffAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
251 
252 public:
253  // --------------------------------------------------------------------- //
254  // SHADOW:FALLOFFGAMMA
255  // --------------------------------------------------------------------- //
256  /// A gamma (i.e., exponential) control over shadow strength
257  /// with linear distance within the falloff zone. This controls the rate
258  /// of the falloff.
259  /// This requires the use of shadowDistance and shadowFalloff.
260  ///
261  /// | ||
262  /// | -- | -- |
263  /// | Declaration | `float inputs:shadow:falloffGamma = 1` |
264  /// | C++ Type | float |
265  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
266  USDLUX_API
268 
269  /// See GetShadowFalloffGammaAttr(), and also
270  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
271  /// If specified, author \p defaultValue as the attribute's default,
272  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
273  /// the default for \p writeSparsely is \c false.
274  USDLUX_API
275  UsdAttribute CreateShadowFalloffGammaAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
276 
277 public:
278  // ===================================================================== //
279  // Feel free to add custom code below this line, it will be preserved by
280  // the code generator.
281  //
282  // Just remember to:
283  // - Close the class declaration with };
284  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
285  // - Close the include guard with #endif
286  // ===================================================================== //
287  // --(BEGIN CUSTOM CODE)--
288 
289  // -------------------------------------------------------------------------
290  /// \name Conversion to and from UsdShadeConnectableAPI
291  ///
292  /// @{
293 
294  /// Constructor that takes a ConnectableAPI object.
295  /// Allow implicit conversion of UsdShadeConnectableAPI to
296  /// UsdLuxShadowAPI.
297  USDLUX_API
298  UsdLuxShadowAPI(const UsdShadeConnectableAPI &connectable);
299 
300  /// Contructs and returns a UsdShadeConnectableAPI object with this shadow
301  /// API prim. Note that a valid UsdLuxShadowAPI will only return a valid
302  /// UsdShadeConnectableAPI if the its prim's Typed schema type is actually
303  /// connectable.
304  USDLUX_API
306 
307  /// @}
308 
309  // -------------------------------------------------------------------------
310  /// \name Outputs API
311  ///
312  /// Outputs represent a typed attribute on a shadow API whose value is
313  /// computed externally.
314  ///
315  /// @{
316 
317  /// Create an output which can either have a value or can be connected.
318  /// The attribute representing the output is created in the "outputs:"
319  /// namespace. Outputs on a shadow API cannot be connected, as their
320  /// value is assumed to be computed externally.
321  ///
322  USDLUX_API
324  const SdfValueTypeName& typeName);
325 
326  /// Return the requested output if it exists.
327  ///
328  USDLUX_API
329  UsdShadeOutput GetOutput(const TfToken &name) const;
330 
331  /// Outputs are represented by attributes in the "outputs:" namespace.
332  /// If \p onlyAuthored is true (the default), then only return authored
333  /// attributes; otherwise, this also returns un-authored builtins.
334  ///
335  USDLUX_API
336  std::vector<UsdShadeOutput> GetOutputs(bool onlyAuthored=true) const;
337 
338  /// @}
339 
340  // -------------------------------------------------------------------------
341 
342  /// \name Inputs API
343  ///
344  /// Inputs are connectable attribute with a typed value.
345  ///
346  /// Shadow API parameters are encoded as inputs.
347  ///
348  /// @{
349 
350  /// Create an input which can either have a value or can be connected.
351  /// The attribute representing the input is created in the "inputs:"
352  /// namespace. Inputs on shadow API are connectable.
353  ///
354  USDLUX_API
356  const SdfValueTypeName& typeName);
357 
358  /// Return the requested input if it exists.
359  ///
360  USDLUX_API
361  UsdShadeInput GetInput(const TfToken &name) const;
362 
363  /// Inputs are represented by attributes in the "inputs:" namespace.
364  /// If \p onlyAuthored is true (the default), then only return authored
365  /// attributes; otherwise, this also returns un-authored builtins.
366  ///
367  USDLUX_API
368  std::vector<UsdShadeInput> GetInputs(bool onlyAuthored=true) const;
369 
370  /// @}
371 };
372 
374 
375 #endif
static USDLUX_API bool CanApply(const UsdPrim &prim, std::string *whyNot=nullptr)
static USDLUX_API UsdLuxShadowAPI Apply(const UsdPrim &prim)
static USDLUX_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
USDLUX_API UsdAttribute GetShadowFalloffGammaAttr() const
Single Apply API schema.
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
#define USDLUX_API
Definition: api.h:23
USDLUX_API UsdAttribute GetShadowColorAttr() const
Definition: token.h:70
UsdLuxShadowAPI(const UsdSchemaBase &schemaObj)
Definition: shadowAPI.h:64
USDLUX_API UsdAttribute CreateShadowEnableAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDLUX_API std::vector< UsdShadeOutput > GetOutputs(bool onlyAuthored=true) const
USDLUX_API UsdAttribute GetShadowDistanceAttr() const
Definition: prim.h:116
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
USDLUX_API UsdShadeConnectableAPI ConnectableAPI() const
GLuint const GLchar * name
Definition: glcorearb.h:786
USDLUX_API UsdAttribute GetShadowEnableAttr() const
Definition: path.h:273
virtual USDLUX_API ~UsdLuxShadowAPI()
Destructor.
UsdSchemaKind
Definition: common.h:112
USDLUX_API UsdShadeInput GetInput(const TfToken &name) const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
static const UsdSchemaKind schemaKind
Definition: shadowAPI.h:50
USDLUX_API UsdShadeInput CreateInput(const TfToken &name, const SdfValueTypeName &typeName)
USDLUX_API UsdShadeOutput GetOutput(const TfToken &name) const
USDLUX_API UsdAttribute CreateShadowFalloffAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
USDLUX_API UsdAttribute CreateShadowColorAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: type.h:47
USDLUX_API std::vector< UsdShadeInput > GetInputs(bool onlyAuthored=true) const
USDLUX_API UsdAttribute CreateShadowFalloffGammaAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDLUX_API UsdSchemaKind _GetSchemaKind() const override
USDLUX_API UsdAttribute GetShadowFalloffAttr() const
USDLUX_API UsdShadeOutput CreateOutput(const TfToken &name, const SdfValueTypeName &typeName)
USDLUX_API UsdAttribute CreateShadowDistanceAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: value.h:146
static USDLUX_API UsdLuxShadowAPI Get(const UsdStagePtr &stage, const SdfPath &path)
UsdLuxShadowAPI(const UsdPrim &prim=UsdPrim())
Definition: shadowAPI.h:56