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