HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
lightAPI.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_LIGHTAPI_H
8 #define USDLUX_GENERATED_LIGHTAPI_H
9 
10 /// \file usdLux/lightAPI.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 // LIGHTAPI //
38 // -------------------------------------------------------------------------- //
39 
40 /// \class UsdLuxLightAPI
41 ///
42 /// API schema that imparts the quality of being a light onto a prim.
43 ///
44 /// A light is any prim that has this schema applied to it. This is true
45 /// regardless of whether LightAPI is included as a built-in API of the prim
46 /// type (e.g. RectLight or DistantLight) or is applied directly to a Gprim
47 /// that should be treated as a light.
48 ///
49 /// <b>Quantities and Units</b>
50 ///
51 /// Most renderers consuming OpenUSD today are RGB renderers, rather than
52 /// spectral. Units in RGB renderers are tricky to define as each of the red,
53 /// green and blue channels transported by the renderer represents the
54 /// convolution of a spectral exposure distribution, e.g. CIE Illuminant D65,
55 /// with a sensor response function, e.g. CIE 1931 𝓍̅. Thus the main quantity
56 /// in an RGB renderer is neither radiance nor luminance, but "integrated
57 /// radiance" or "tristimulus weight".
58 ///
59 /// The emission of a default light with `intensity` 1 and `color` [1, 1, 1] is
60 /// an Illuminant D spectral distribution with chromaticity matching the
61 /// rendering color space white point, normalized such that a ray normally
62 /// incident upon the sensor with EV0 exposure settings will generate a pixel
63 /// value of [1, 1, 1] in the rendering color space.
64 ///
65 /// Given the above definition, that means that the luminance of said default
66 /// light will be 1 *nit (cd∕m²)* and its emission spectral radiance
67 /// distribution is easily computed by appropriate normalization.
68 ///
69 /// For brevity, the term *emission* will be used in the documentation to mean
70 /// "emitted spectral radiance" or "emitted integrated radiance/tristimulus
71 /// weight", as appropriate.
72 ///
73 /// The method of "uplifting" an RGB color to a spectral distribution is
74 /// unspecified other than that it should round-trip under the rendering
75 /// illuminant to the limits of numerical accuracy.
76 ///
77 /// Note that some color spaces, most notably ACES, define their white points
78 /// by chromaticity coordinates that do not exactly line up to any value of a
79 /// standard illuminant. Because we do not define the method of uplift beyond
80 /// the round-tripping requirement, we discourage the use of such color spaces
81 /// as the rendering color space, and instead encourage the use of color spaces
82 /// whose white point has a well-defined spectral representation, such as D65.
83 ///
84 /// <b>Linking</b>
85 ///
86 /// Lights can be linked to geometry. Linking controls which geometry
87 /// a light illuminates, and which geometry casts shadows from the light.
88 ///
89 /// Linking is specified as collections (UsdCollectionAPI) which can
90 /// be accessed via GetLightLinkCollection() and GetShadowLinkCollection().
91 /// Note that these collections have their includeRoot set to true,
92 /// so that lights will illuminate and cast shadows from all objects
93 /// by default. To illuminate only a specific set of objects, there
94 /// are two options. One option is to modify the collection paths
95 /// to explicitly exclude everything else, assuming it is known;
96 /// the other option is to set includeRoot to false and explicitly
97 /// include the desired objects. These are complementary approaches
98 /// that may each be preferable depending on the scenario and how
99 /// to best express the intent of the light setup.
100 ///
101 /// <b>Encapsulation</b>
102 /// A prim with LightAPI applied must not be parented under a
103 /// UsdShadeConnectable prim, with the exception of prims which themselves have
104 /// UsdLuxLightAPI applied. Some lighting scenarios require light prims to be
105 /// parented under other light prims. For example, a DomeLight might contain
106 /// PortalLight children to refine the lighting for a particular scene.
107 ///
108 ///
109 ///
110 /// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
111 /// that are text/tokens, the actual token is published and defined in \ref UsdLuxTokens.
112 /// So to set an attribute to the value "rightHanded", use UsdLuxTokens->rightHanded
113 /// as the value.
114 ///
116 {
117 public:
118  /// Compile time constant representing what kind of schema this class is.
119  ///
120  /// \sa UsdSchemaKind
122 
123  /// Construct a UsdLuxLightAPI on UsdPrim \p prim .
124  /// Equivalent to UsdLuxLightAPI::Get(prim.GetStage(), prim.GetPath())
125  /// for a \em valid \p prim, but will not immediately throw an error for
126  /// an invalid \p prim
127  explicit UsdLuxLightAPI(const UsdPrim& prim=UsdPrim())
128  : UsdAPISchemaBase(prim)
129  {
130  }
131 
132  /// Construct a UsdLuxLightAPI on the prim held by \p schemaObj .
133  /// Should be preferred over UsdLuxLightAPI(schemaObj.GetPrim()),
134  /// as it preserves SchemaBase state.
135  explicit UsdLuxLightAPI(const UsdSchemaBase& schemaObj)
136  : UsdAPISchemaBase(schemaObj)
137  {
138  }
139 
140  /// Destructor.
141  USDLUX_API
142  virtual ~UsdLuxLightAPI();
143 
144  /// Return a vector of names of all pre-declared attributes for this schema
145  /// class and all its ancestor classes. Does not include attributes that
146  /// may be authored by custom/extended methods of the schemas involved.
147  USDLUX_API
148  static const TfTokenVector &
149  GetSchemaAttributeNames(bool includeInherited=true);
150 
151  /// Return a UsdLuxLightAPI holding the prim adhering to this
152  /// schema at \p path on \p stage. If no prim exists at \p path on
153  /// \p stage, or if the prim at that path does not adhere to this schema,
154  /// return an invalid schema object. This is shorthand for the following:
155  ///
156  /// \code
157  /// UsdLuxLightAPI(stage->GetPrimAtPath(path));
158  /// \endcode
159  ///
160  USDLUX_API
161  static UsdLuxLightAPI
162  Get(const UsdStagePtr &stage, const SdfPath &path);
163 
164 
165  /// Returns true if this <b>single-apply</b> API schema can be applied to
166  /// the given \p prim. If this schema can not be a applied to the prim,
167  /// this returns false and, if provided, populates \p whyNot with the
168  /// reason it can not be applied.
169  ///
170  /// Note that if CanApply returns false, that does not necessarily imply
171  /// that calling Apply will fail. Callers are expected to call CanApply
172  /// before calling Apply if they want to ensure that it is valid to
173  /// apply a schema.
174  ///
175  /// \sa UsdPrim::GetAppliedSchemas()
176  /// \sa UsdPrim::HasAPI()
177  /// \sa UsdPrim::CanApplyAPI()
178  /// \sa UsdPrim::ApplyAPI()
179  /// \sa UsdPrim::RemoveAPI()
180  ///
181  USDLUX_API
182  static bool
183  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
184 
185  /// Applies this <b>single-apply</b> API schema to the given \p prim.
186  /// This information is stored by adding "LightAPI" to the
187  /// token-valued, listOp metadata \em apiSchemas on the prim.
188  ///
189  /// \return A valid UsdLuxLightAPI object is returned upon success.
190  /// An invalid (or empty) UsdLuxLightAPI object is returned upon
191  /// failure. See \ref UsdPrim::ApplyAPI() for conditions
192  /// resulting in failure.
193  ///
194  /// \sa UsdPrim::GetAppliedSchemas()
195  /// \sa UsdPrim::HasAPI()
196  /// \sa UsdPrim::CanApplyAPI()
197  /// \sa UsdPrim::ApplyAPI()
198  /// \sa UsdPrim::RemoveAPI()
199  ///
200  USDLUX_API
201  static UsdLuxLightAPI
202  Apply(const UsdPrim &prim);
203 
204 protected:
205  /// Returns the kind of schema this class belongs to.
206  ///
207  /// \sa UsdSchemaKind
208  USDLUX_API
209  UsdSchemaKind _GetSchemaKind() const override;
210 
211 private:
212  // needs to invoke _GetStaticTfType.
213  friend class UsdSchemaRegistry;
214  USDLUX_API
215  static const TfType &_GetStaticTfType();
216 
217  static bool _IsTypedSchema();
218 
219  // override SchemaBase virtuals.
220  USDLUX_API
221  const TfType &_GetTfType() const override;
222 
223 public:
224  // --------------------------------------------------------------------- //
225  // SHADERID
226  // --------------------------------------------------------------------- //
227  /// Default ID for the light's shader.
228  /// This defines the shader ID for this light when a render context specific
229  /// shader ID is not available.
230  ///
231  /// The default shaderId for the intrinsic UsdLux lights (RectLight,
232  /// DistantLight, etc.) are set to default to the light's type name. For
233  /// each intrinsic UsdLux light, we will always register an SdrShaderNode in
234  /// the SdrRegistry, with the identifier matching the type name and the
235  /// source type "USD", that corresponds to the light's inputs.
236  /// \see GetShaderId
237  /// \see GetShaderIdAttrForRenderContext
238  /// \see SdrRegistry::GetShaderNodeByIdentifier
239  /// \see SdrRegistry::GetShaderNodeByIdentifierAndType
240  ///
241  ///
242  /// | ||
243  /// | -- | -- |
244  /// | Declaration | `uniform token light:shaderId = ""` |
245  /// | C++ Type | TfToken |
246  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
247  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
248  USDLUX_API
250 
251  /// See GetShaderIdAttr(), and also
252  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
253  /// If specified, author \p defaultValue as the attribute's default,
254  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
255  /// the default for \p writeSparsely is \c false.
256  USDLUX_API
257  UsdAttribute CreateShaderIdAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
258 
259 public:
260  // --------------------------------------------------------------------- //
261  // MATERIALSYNCMODE
262  // --------------------------------------------------------------------- //
263  ///
264  /// For a LightAPI applied to geometry that has a bound Material,
265  /// which is entirely or partly emissive, this specifies the relationship
266  /// of the Material response to the lighting response.
267  /// Valid values are:
268  /// - materialGlowTintsLight: All primary and secondary rays see the
269  /// emissive/glow response as dictated by the bound Material while the
270  /// base color seen by light rays (which is then modulated by all of the
271  /// other LightAPI controls) is the multiplication of the color feeding
272  /// the emission/glow input of the Material (i.e. its surface or volume
273  /// shader) with the scalar or pattern input to *inputs:color*.
274  /// This allows the light's color to tint the geometry's glow color while
275  /// preserving access to intensity and other light controls as ways to
276  /// further modulate the illumination.
277  /// - independent: All primary and secondary rays see the emissive/glow
278  /// response as dictated by the bound Material, while the base color seen
279  /// by light rays is determined solely by *inputs:color*. Note that for
280  /// partially emissive geometry (in which some parts are reflective
281  /// rather than emissive), a suitable pattern must be connected to the
282  /// light's color input, or else the light will radiate uniformly from
283  /// the geometry.
284  /// - noMaterialResponse: The geometry behaves as if there is no Material
285  /// bound at all, i.e. there is no diffuse, specular, or transmissive
286  /// response. The base color of light rays is entirely controlled by the
287  /// *inputs:color*. This is the standard mode for "canonical" lights in
288  /// UsdLux and indicates to renderers that a Material will either never
289  /// be bound or can always be ignored.
290  ///
291  ///
292  /// | ||
293  /// | -- | -- |
294  /// | Declaration | `uniform token light:materialSyncMode = "noMaterialResponse"` |
295  /// | C++ Type | TfToken |
296  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
297  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
298  /// | \ref UsdLuxTokens "Allowed Values" | materialGlowTintsLight, independent, noMaterialResponse |
299  USDLUX_API
301 
302  /// See GetMaterialSyncModeAttr(), and also
303  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
304  /// If specified, author \p defaultValue as the attribute's default,
305  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
306  /// the default for \p writeSparsely is \c false.
307  USDLUX_API
308  UsdAttribute CreateMaterialSyncModeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
309 
310 public:
311  // --------------------------------------------------------------------- //
312  // INTENSITY
313  // --------------------------------------------------------------------- //
314  /// Scales the brightness of the light linearly.
315  ///
316  /// Expresses the "base", unmultiplied luminance emitted (L) of the light,
317  /// in nits (cd∕m²):
318  ///
319  /// <center><b>
320  /// L<sub>Scalar</sub> = intensity
321  /// </b></center>
322  ///
323  /// Normatively, the lights' emission is in units of spectral radiance
324  /// normalized such that a directly visible light with `intensity` 1 and
325  /// `exposure` 0 normally incident upon the sensor plane will generate a
326  /// pixel value of [1, 1, 1] in an RGB renderer, and thus have a luminance
327  /// of 1 nit. A light with `intensity` 2 and `exposure` 0 would therefore
328  /// have a luminance of 2 nits.
329  ///
330  ///
331  /// | ||
332  /// | -- | -- |
333  /// | Declaration | `float inputs:intensity = 1` |
334  /// | C++ Type | float |
335  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
336  USDLUX_API
338 
339  /// See GetIntensityAttr(), and also
340  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
341  /// If specified, author \p defaultValue as the attribute's default,
342  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
343  /// the default for \p writeSparsely is \c false.
344  USDLUX_API
345  UsdAttribute CreateIntensityAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
346 
347 public:
348  // --------------------------------------------------------------------- //
349  // EXPOSURE
350  // --------------------------------------------------------------------- //
351  /// Scales the brightness of the light exponentially as a power
352  /// of 2 (similar to an F-stop control over exposure). The result
353  /// is multiplied against the intensity:
354  ///
355  /// <center><b>
356  /// L<sub>Scalar</sub> = L<sub>Scalar</sub> ⋅ 2<sup>exposure</sup>
357  /// </b></center>
358  ///
359  /// Normatively, the lights' emission is in units of spectral radiance
360  /// normalized such that a directly visible light with `intensity` 1 and
361  /// `exposure` 0 normally incident upon the sensor plane will generate a
362  /// pixel value of [1, 1, 1] in an RGB renderer, and thus have a luminance
363  /// of 1 nit (cd∕m²). A light with `intensity` 1 and `exposure` 2 would
364  /// therefore have a luminance of 4 nits.
365  ///
366  ///
367  /// | ||
368  /// | -- | -- |
369  /// | Declaration | `float inputs:exposure = 0` |
370  /// | C++ Type | float |
371  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
372  USDLUX_API
374 
375  /// See GetExposureAttr(), and also
376  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
377  /// If specified, author \p defaultValue as the attribute's default,
378  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
379  /// the default for \p writeSparsely is \c false.
380  USDLUX_API
381  UsdAttribute CreateExposureAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
382 
383 public:
384  // --------------------------------------------------------------------- //
385  // DIFFUSE
386  // --------------------------------------------------------------------- //
387  /// A multiplier for the effect of this light on the diffuse
388  /// response of materials. This is a non-physical control.
389  ///
390  /// | ||
391  /// | -- | -- |
392  /// | Declaration | `float inputs:diffuse = 1` |
393  /// | C++ Type | float |
394  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
395  USDLUX_API
397 
398  /// See GetDiffuseAttr(), and also
399  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
400  /// If specified, author \p defaultValue as the attribute's default,
401  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
402  /// the default for \p writeSparsely is \c false.
403  USDLUX_API
404  UsdAttribute CreateDiffuseAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
405 
406 public:
407  // --------------------------------------------------------------------- //
408  // SPECULAR
409  // --------------------------------------------------------------------- //
410  /// A multiplier for the effect of this light on the specular
411  /// response of materials. This is a non-physical control.
412  ///
413  /// | ||
414  /// | -- | -- |
415  /// | Declaration | `float inputs:specular = 1` |
416  /// | C++ Type | float |
417  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
418  USDLUX_API
420 
421  /// See GetSpecularAttr(), and also
422  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
423  /// If specified, author \p defaultValue as the attribute's default,
424  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
425  /// the default for \p writeSparsely is \c false.
426  USDLUX_API
427  UsdAttribute CreateSpecularAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
428 
429 public:
430  // --------------------------------------------------------------------- //
431  // NORMALIZE
432  // --------------------------------------------------------------------- //
433  /// Normalizes the emission such that the power of the light
434  /// remains constant while altering the size of the light, by dividing the
435  /// luminance by the world-space surface area of the light.
436  ///
437  /// This makes it easier to independently adjust the brightness and size
438  /// of the light, by causing the total illumination provided by a light to
439  /// not vary with the area or angular size of the light.
440  ///
441  /// Mathematically, this means that the luminance of the light will be
442  /// divided by a factor representing the "size" of the light:
443  ///
444  /// <center><b>
445  /// L<sub>Scalar</sub> = L<sub>Scalar</sub> / sizeFactor
446  /// </b></center>
447  ///
448  /// ...where `sizeFactor` = 1 if `normalize` is off, and is calculated
449  /// depending on the family of the light as described below if `normalize`
450  /// is on.
451  ///
452  /// ### DomeLight / PortalLight:
453  ///
454  /// For a dome light (and its associated PortalLight), this attribute is
455  /// ignored:
456  ///
457  /// <center><b>
458  /// sizeFactor<sub>dome</sub> = 1
459  /// </b></center>
460  ///
461  /// ### Area Lights:
462  ///
463  /// For an area light, the `sizeFactor` is the surface area (in world
464  /// space) of the shape of the light, including any scaling applied to the
465  /// light by its transform stack. This includes the boundable light types
466  /// which have a calculable surface area:
467  ///
468  /// - MeshLightAPI
469  /// - DiskLight
470  /// - RectLight
471  /// - SphereLight
472  /// - CylinderLight
473  ///
474  /// <center><b>
475  /// sizeFactor<sub>area</sub> = worldSpaceSurfaceArea(light)
476  /// </b></center>
477  ///
478  /// ### DistantLight:
479  ///
480  /// For distant lights, we first define 𝛳<sub>max</sub> as:
481  ///
482  /// <center><b>
483  /// 𝛳<sub>max</sub> = clamp(toRadians(distantLightAngle) / 2, 0, 𝜋)
484  /// </b></center>
485  ///
486  /// Then we use the following formula:
487  ///
488  /// * <i>if 𝛳<sub>max</sub> = 0:</i>
489  /// <center><b>
490  /// sizeFactor<sub>distant</sub> = 1
491  /// </b></center>
492  ///
493  /// * <i>if 0 < 𝛳<sub>max</sub> ≤ 𝜋 / 2:</i>
494  /// <center><b>
495  /// sizeFactor<sub>distant</sub> = sin²𝛳<sub>max</sub> ⋅ 𝜋
496  /// </b></center>
497  ///
498  /// * <i>if 𝜋 / 2 < 𝛳<sub>max</sub> ≤ 𝜋:</i>
499  /// <center><b>
500  /// sizeFactor<sub>distant</sub> =
501  /// (2 - sin²𝛳<sub>max</sub>) ⋅ 𝜋
502  /// </b></center>
503  ///
504  /// This formula is used because it satisfies the following two properties:
505  ///
506  /// 1. When normalize is enabled, the received illuminance from this light
507  /// on a surface normal to the light's primary direction is held constant
508  /// when angle changes, and the "intensity" property becomes a measure of
509  /// the illuminance, expressed in lux, for a light with 0 exposure.
510  ///
511  /// 2. If we assume that our distant light is an approximation for a "very
512  /// far" sphere light (like the sun), then (for
513  /// *0 < 𝛳<sub>max</sub> ≤ 𝜋/2*) this definition agrees with the
514  /// definition used for area lights - i.e., the total power of this distant
515  /// sphere light is constant when the "size" (i.e., angle) changes, and our
516  /// sizeFactor is proportional to the total surface area of this sphere.
517  ///
518  /// ### Other Lights
519  ///
520  /// The above taxonomy describes behavior for all built-in light types.
521  /// (Note that the above is based on schema *family* - i.e., `DomeLight_1`
522  /// follows the rules for a `DomeLight`, and ignores `normalize`).
523  ///
524  /// Lights from other third-party plugins / schemas must document their
525  /// expected behavior with regards to normalize. However, some general
526  /// guidelines are:
527  ///
528  /// - Lights that either inherit from or are strongly associated with one of
529  /// the built-in types should follow the behavior of the built-in type
530  /// they inherit/resemble; i.e., a renderer-specific "MyRendererRectLight"
531  /// should have its size factor be its world-space surface area.
532  /// - Lights that are boundable and have a calculable surface area should
533  /// follow the rules for an Area Light, and have their sizeFactor be their
534  /// world-space surface area.
535  /// - Lights that are non-boundable and/or have no way to concretely or even
536  /// "intuitively" associate them with a "size" will ignore this attribute
537  /// (and always set sizeFactor = 1).
538  ///
539  /// Lights that don't clearly meet any of the above criteria may either
540  /// ignore the normalize attribute or try to implement support using
541  /// whatever heuristic seems to make sense. For instance,
542  /// MyMandelbulbLight might use a sizeFactor equal to the world-space
543  /// surface area of a sphere which "roughly" bounds it.
544  ///
545  ///
546  /// | ||
547  /// | -- | -- |
548  /// | Declaration | `bool inputs:normalize = 0` |
549  /// | C++ Type | bool |
550  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Bool |
551  USDLUX_API
553 
554  /// See GetNormalizeAttr(), and also
555  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
556  /// If specified, author \p defaultValue as the attribute's default,
557  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
558  /// the default for \p writeSparsely is \c false.
559  USDLUX_API
560  UsdAttribute CreateNormalizeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
561 
562 public:
563  // --------------------------------------------------------------------- //
564  // COLOR
565  // --------------------------------------------------------------------- //
566  /// The color of emitted light, in the rendering color space.
567  ///
568  /// This color is just multiplied with the emission:
569  ///
570  /// <center><b>
571  /// L<sub>Color</sub> = L<sub>Scalar</sub> ⋅ color
572  /// </b></center>
573  ///
574  /// In the case of a spectral renderer, this color should be uplifted such
575  /// that it round-trips to within the limit of numerical accuracy under the
576  /// rendering illuminant. We recommend the use of a rendering color space
577  /// well defined in terms of a Illuminant D illuminant (ideally a D
578  /// illuminant whose white point has a well-defined spectral representation,
579  /// such as D65), to avoid unspecified uplift. See: \ref usdLux_quantities
580  ///
581  ///
582  /// | ||
583  /// | -- | -- |
584  /// | Declaration | `color3f inputs:color = (1, 1, 1)` |
585  /// | C++ Type | GfVec3f |
586  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Color3f |
587  USDLUX_API
588  UsdAttribute GetColorAttr() const;
589 
590  /// See GetColorAttr(), and also
591  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
592  /// If specified, author \p defaultValue as the attribute's default,
593  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
594  /// the default for \p writeSparsely is \c false.
595  USDLUX_API
596  UsdAttribute CreateColorAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
597 
598 public:
599  // --------------------------------------------------------------------- //
600  // ENABLECOLORTEMPERATURE
601  // --------------------------------------------------------------------- //
602  /// Enables using colorTemperature.
603  ///
604  /// | ||
605  /// | -- | -- |
606  /// | Declaration | `bool inputs:enableColorTemperature = 0` |
607  /// | C++ Type | bool |
608  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Bool |
609  USDLUX_API
611 
612  /// See GetEnableColorTemperatureAttr(), and also
613  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
614  /// If specified, author \p defaultValue as the attribute's default,
615  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
616  /// the default for \p writeSparsely is \c false.
617  USDLUX_API
618  UsdAttribute CreateEnableColorTemperatureAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
619 
620 public:
621  // --------------------------------------------------------------------- //
622  // COLORTEMPERATURE
623  // --------------------------------------------------------------------- //
624  /// Color temperature, in degrees Kelvin, representing the
625  /// white point. The default is a common white point, D65. Lower
626  /// values are warmer and higher values are cooler. The valid range
627  /// is from 1000 to 10000. Only takes effect when
628  /// enableColorTemperature is set to true. When active, the
629  /// computed result multiplies against the color attribute.
630  /// See UsdLuxBlackbodyTemperatureAsRgb().
631  ///
632  /// This is always calculated as an RGB color using a D65 white point,
633  /// regardless of the rendering color space, normalized such that the
634  /// default value of 6500 will always result in white, and then should be
635  /// transformed to the rendering color space.
636  ///
637  /// Spectral renderers should do the same and then uplift the resulting
638  /// color after multiplying with the `color` attribute. We recommend the
639  /// use of a rendering color space well defined in terms of a Illuminant D
640  /// illuminant, to avoid unspecified uplift. See: \ref usdLux_quantities
641  ///
642  ///
643  /// | ||
644  /// | -- | -- |
645  /// | Declaration | `float inputs:colorTemperature = 6500` |
646  /// | C++ Type | float |
647  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
648  USDLUX_API
650 
651  /// See GetColorTemperatureAttr(), and also
652  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
653  /// If specified, author \p defaultValue as the attribute's default,
654  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
655  /// the default for \p writeSparsely is \c false.
656  USDLUX_API
657  UsdAttribute CreateColorTemperatureAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
658 
659 public:
660  // --------------------------------------------------------------------- //
661  // FILTERS
662  // --------------------------------------------------------------------- //
663  /// Relationship to the light filters that apply to this light.
664  ///
665  USDLUX_API
667 
668  /// See GetFiltersRel(), and also
669  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create
670  USDLUX_API
672 
673 public:
674  // ===================================================================== //
675  // Feel free to add custom code below this line, it will be preserved by
676  // the code generator.
677  //
678  // Just remember to:
679  // - Close the class declaration with };
680  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
681  // - Close the include guard with #endif
682  // ===================================================================== //
683  // --(BEGIN CUSTOM CODE)--
684 
685  // -------------------------------------------------------------------------
686  /// \name Conversion to and from UsdShadeConnectableAPI
687  ///
688  /// @{
689 
690  /// Constructor that takes a ConnectableAPI object.
691  /// Allow implicit conversion of a UsdShadeConnectableAPI to UsdLuxLightAPI
692  USDLUX_API
693  UsdLuxLightAPI(const UsdShadeConnectableAPI &connectable);
694 
695  /// Contructs and returns a UsdShadeConnectableAPI object with this light.
696  ///
697  /// Note that most tasks can be accomplished without explicitly constructing
698  /// a UsdShadeConnectable API, since connection-related API such as
699  /// UsdShadeConnectableAPI::ConnectToSource() are static methods, and
700  /// UsdLuxLightAPI will auto-convert to a UsdShadeConnectableAPI when
701  /// passed to functions that want to act generically on a connectable
702  /// UsdShadeConnectableAPI object.
703  USDLUX_API
705 
706  /// @}
707 
708  // -------------------------------------------------------------------------
709  /// \name Outputs API
710  ///
711  /// Outputs represent a typed attribute on a light whose value is computed
712  /// externally.
713  ///
714  /// @{
715 
716  /// Create an output which can either have a value or can be connected.
717  /// The attribute representing the output is created in the "outputs:"
718  /// namespace. Outputs on a light cannot be connected, as their
719  /// value is assumed to be computed externally.
720  ///
721  USDLUX_API
723  const SdfValueTypeName& typeName);
724 
725  /// Return the requested output if it exists.
726  ///
727  USDLUX_API
728  UsdShadeOutput GetOutput(const TfToken &name) const;
729 
730  /// Outputs are represented by attributes in the "outputs:" namespace.
731  /// If \p onlyAuthored is true (the default), then only return authored
732  /// attributes; otherwise, this also returns un-authored builtins.
733  ///
734  USDLUX_API
735  std::vector<UsdShadeOutput> GetOutputs(bool onlyAuthored=true) const;
736 
737  /// @}
738 
739  // -------------------------------------------------------------------------
740 
741  /// \name Inputs API
742  ///
743  /// Inputs are connectable attribute with a typed value.
744  ///
745  /// Light parameters are encoded as inputs.
746  ///
747  /// @{
748 
749  /// Create an input which can either have a value or can be connected.
750  /// The attribute representing the input is created in the "inputs:"
751  /// namespace. Inputs on lights are connectable.
752  ///
753  USDLUX_API
755  const SdfValueTypeName& typeName);
756 
757  /// Return the requested input if it exists.
758  ///
759  USDLUX_API
760  UsdShadeInput GetInput(const TfToken &name) const;
761 
762  /// Inputs are represented by attributes in the "inputs:" namespace.
763  /// If \p onlyAuthored is true (the default), then only return authored
764  /// attributes; otherwise, this also returns un-authored builtins.
765  ///
766  USDLUX_API
767  std::vector<UsdShadeInput> GetInputs(bool onlyAuthored=true) const;
768 
769  /// @}
770 
771  /// Return the UsdCollectionAPI interface used for examining and
772  /// modifying the light-linking of this light. Light-linking
773  /// controls which geometry this light illuminates.
774  USDLUX_API
776 
777  /// Return the UsdCollectionAPI interface used for examining and
778  /// modifying the shadow-linking of this light. Shadow-linking
779  /// controls which geometry casts shadows from this light.
780  USDLUX_API
782 
783  /// Returns the shader ID attribute for the given \p renderContext.
784  ///
785  /// If \p renderContext is non-empty, this will try to return an attribute
786  /// named _light:shaderId_ with the namespace prefix \p renderContext. For
787  /// example, if the passed in render context is "ri" then the attribute
788  /// returned by this function would have the following signature:
789  /// | ||
790  /// | -- | -- |
791  /// | Declaration | `token ri:light:shaderId` |
792  /// | C++ Type | TfToken |
793  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
794  ///
795  /// If the render context is empty, this will return the default shader ID
796  /// attribute as returned by GetShaderIdAttr().
797  USDLUX_API
799  const TfToken &renderContext) const;
800 
801  /// Creates the shader ID attribute for the given \p renderContext.
802  ///
803  /// See GetShaderIdAttrForRenderContext(), and also
804  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
805  /// If specified, author \p defaultValue as the attribute's default,
806  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
807  /// the default for \p writeSparsely is \c false.
808  USDLUX_API
810  const TfToken &renderContext,
811  VtValue const &defaultValue = VtValue(),
812  bool writeSparsely=false) const;
813 
814  /// Return the light's shader ID for the given list of available
815  /// \p renderContexts.
816  ///
817  /// The shader ID returned by this function is the identifier to use when
818  /// looking up the shader definition for this light in the
819  /// \ref SdrRegistry "shader registry".
820  ///
821  /// The render contexts are expected to be listed in priority order, so
822  /// for each render context provided, this will try to find the shader ID
823  /// attribute specific to that render context (see
824  /// GetShaderIdAttrForRenderContext()) and will return the
825  /// value of the first one found that has a non-empty value. If no shader ID
826  /// value can be found for any of the given render contexts or
827  /// \p renderContexts is empty, then this will return the value of the
828  /// default shader ID attribute (see GetShaderIdAttr()).
829  USDLUX_API
830  TfToken GetShaderId(const TfTokenVector &renderContexts) const;
831 };
832 
834 
835 #endif
USDLUX_API UsdAttribute CreateDiffuseAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDLUX_API UsdShadeConnectableAPI ConnectableAPI() const
static const UsdSchemaKind schemaKind
Definition: lightAPI.h:121
USDLUX_API UsdAttribute CreateExposureAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDLUX_API UsdAttribute GetIntensityAttr() const
UsdLuxLightAPI(const UsdSchemaBase &schemaObj)
Definition: lightAPI.h:135
USDLUX_API UsdAttribute GetDiffuseAttr() const
USDLUX_API UsdAttribute GetExposureAttr() const
USDLUX_API UsdShadeInput CreateInput(const TfToken &name, const SdfValueTypeName &typeName)
UsdLuxLightAPI(const UsdPrim &prim=UsdPrim())
Definition: lightAPI.h:127
USDLUX_API UsdRelationship CreateFiltersRel() const
Single Apply API schema.
USDLUX_API TfToken GetShaderId(const TfTokenVector &renderContexts) const
USDLUX_API UsdAttribute GetShaderIdAttrForRenderContext(const TfToken &renderContext) const
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
USDLUX_API UsdShadeOutput GetOutput(const TfToken &name) const
USDLUX_API UsdShadeOutput CreateOutput(const TfToken &name, const SdfValueTypeName &typeName)
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
USDLUX_API UsdAttribute CreateColorTemperatureAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
#define USDLUX_API
Definition: api.h:23
USDLUX_API std::vector< UsdShadeOutput > GetOutputs(bool onlyAuthored=true) const
USDLUX_API std::vector< UsdShadeInput > GetInputs(bool onlyAuthored=true) const
USDLUX_API UsdAttribute CreateEnableColorTemperatureAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDLUX_API UsdAttribute CreateColorAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
static USDLUX_API bool CanApply(const UsdPrim &prim, std::string *whyNot=nullptr)
USDLUX_API UsdAttribute GetNormalizeAttr() const
USDLUX_API UsdAttribute CreateShaderIdAttrForRenderContext(const TfToken &renderContext, VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDLUX_API UsdSchemaKind _GetSchemaKind() const override
static USDLUX_API UsdLuxLightAPI Get(const UsdStagePtr &stage, const SdfPath &path)
Definition: token.h:70
USDLUX_API UsdCollectionAPI GetShadowLinkCollectionAPI() const
USDLUX_API UsdAttribute GetColorAttr() const
USDLUX_API UsdRelationship GetFiltersRel() const
USDLUX_API UsdAttribute CreateMaterialSyncModeAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDLUX_API UsdAttribute GetColorTemperatureAttr() const
USDLUX_API UsdAttribute GetMaterialSyncModeAttr() const
Definition: prim.h:116
USDLUX_API UsdCollectionAPI GetLightLinkCollectionAPI() const
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
GLuint const GLchar * name
Definition: glcorearb.h:786
USDLUX_API UsdAttribute GetEnableColorTemperatureAttr() const
Definition: path.h:280
USDLUX_API UsdAttribute GetSpecularAttr() const
UsdSchemaKind
Definition: common.h:112
virtual USDLUX_API ~UsdLuxLightAPI()
Destructor.
USDLUX_API UsdAttribute CreateNormalizeAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDLUX_API UsdAttribute CreateShaderIdAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDLUX_API UsdAttribute GetShaderIdAttr() const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
USDLUX_API UsdShadeInput GetInput(const TfToken &name) const
Definition: type.h:47
USDLUX_API UsdAttribute CreateSpecularAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDLUX_API UsdAttribute CreateIntensityAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
static USDLUX_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
Definition: value.h:89
static USDLUX_API UsdLuxLightAPI Apply(const UsdPrim &prim)