OGRE-Next: Ogre::Light Class Reference

| OGRE-Next 3.0.0 Object-Oriented Graphics Rendering Engine

Loading...
Searching...
No Matches
Ogre::Light Class Reference
Core | Component » Scene

Representation of a dynamic light source in the scene. More...

`#include <OgreLight.h>`

Inheritance diagram for Ogre::Light:
[legend]

## Public Types
enum | LightTypes { LT_DIRECTIONAL = 0 , LT_POINT = 1 , LT_SPOTLIGHT = 2 , LT_VPL = 3 , MAX_FORWARD_PLUS_LIGHTS = 4 , LT_AREA_APPROX = 4 , LT_AREA_LTC = 5 , NUM_LIGHT_TYPES }
| Defines the type of light. More...
Public Types inherited from Ogre::MovableObject
typedef FastArray< MovableObject * > | MovableObjectArray
Public Types inherited from Ogre::TextureGpuListener
enum | Reason { Unknown , FromStorageToSysRam , FromSysRamToStorage , GainedResidency , LostResidency , PoolTextureSlotChanged , ResidentToSysRamSync , MetadataCacheOutOfDate , ExceptionThrown , FsaaSettingAlteredByApi , ReadyForRendering , Deleted }

## Public Member Functions
| Light (IdType id, ObjectMemoryManager *objectMemoryManager, SceneManager *manager)
| Normal constructor.
| ~Light () override
| Standard destructor.
void | _calcTempSquareDist (const Vector3 &worldPos)
| Internal method for calculating current squared distance from some world position.
Real | _deriveShadowFarClipDistance (const Camera *maincam) const
| Derive a shadow camera far distance from either the light, or from the main camera if the light doesn't have its own setting.
Real | _deriveShadowNearClipDistance (const Camera *maincam) const
| Derive a shadow camera near distance from either the light, or from the main camera if the light doesn't have its own setting.
bool | _getOwnShadowFarDistance () const
void | _setLightProfileIdx (uint16 profileIdx)
virtual void | _updateCustomGpuParameter (uint16 paramIndex, const GpuProgramParameters_AutoConstantEntry &constantEntry, GpuProgramParameters *params) const
| Update a custom GpuProgramParameters constant which is derived from information only this Light knows.
void | _updateRenderQueue (RenderQueue *queue, Camera *camera, const Camera *lodCamera) override
| Internal method by which the movable object must add Renderable subclass instances to the rendering queue.
AnimableValuePtr | createAnimableValue (const String &valueName) override
| Create a reference-counted AnimableValuePtr for the named value.
bool | getAffectParentNode () const
Vector4 | getAs4DVector () const
| Tells this object whether to be visible or not, if it has a renderable component.
Real | getAttenuationConstant () const
| Returns the constant factor in the attenuation formula.
Real | getAttenuationLinear () const
| Returns the linear factor in the attenuation formula.
Real | getAttenuationQuadric () const
| Returns the quadric factor in the attenuation formula.
Real | getAttenuationRange () const
| Returns the absolute upper range of the light.
const Vector4 & | getCustomParameter (uint16 index) const
| Gets the custom value associated with this Light at the given index.
const Vector4 * | getCustomParameterNoThrow (uint16 index) const
Vector3 | getDerivedDirection () const
| Retrieves the direction of the light including any transform from nodes it is attached to.
Vector3 | getDerivedDirectionUpdated () const
Vector2 | getDerivedRectSize () const
const ColourValue & | getDiffuseColour () const
| Returns the colour of the diffuse light given off by this light source (see setDiffuseColour for more info).
Vector3 | getDirection () const
| Returns the light's direction.
bool | getDoubleSided () const
uint16 | getLightProfileIdx () const
const String & | getMovableType () const override
| Returns the type name of this object.
Real | getPowerScale () const
| Set the scaling factor which indicates the relative power of a light.
const Vector2 & | getRectSize () const
Real | getShadowFarClipDistance () const
| Get the far clip plane distance to be used by the shadow camera, if this light casts texture shadows.
Real | getShadowFarDistance () const
| Gets the maximum distance away from the camera that shadows by this light will be visible.
Real | getShadowFarDistanceSquared () const
Real | getShadowNearClipDistance () const
| Get the near clip plane distance to be used by the shadow camera, if this light casts texture shadows.
const ColourValue & | getSpecularColour () const
| Returns the colour of specular light given off by this light source.
Real | getSpotlightFalloff () const
| Returns the falloff between the inner and outer cones of the spotlight.
const Radian & | getSpotlightInnerAngle () const
| Returns the angle covered by the spotlights inner cone.
Real | getSpotlightNearClipDistance () const
| Get the near clip plane distance to be used by spotlights that use light clipping.
const Radian & | getSpotlightOuterAngle () const
| Returns the angle covered by the spotlights outer cone.
Real | getSpotlightTanHalfAngle () const
TextureGpu * | getTexture () const
LightTypes | getType () const
| Returns the light type.
bool | isInLightRange (const Ogre::AxisAlignedBox &container) const
| Check whether a bounding box is included in the lighted area of the light.
bool | isInLightRange (const Ogre::Sphere &sphere) const
| Check whether a sphere is included in the lighted area of the light.
void | notifyTextureChanged (TextureGpu *texture, TextureGpuListener::Reason reason, void *extraData) override
| Called when a TextureGpu changed in a way that affects how it is displayed:
void | resetShadowFarDistance ()
| Tells the light to use the shadow far distance of the SceneManager.
void | setAffectParentNode (bool bAffect)
| A Light must always have a Node attached to it.
void | setAttenuation (Real range, Real constant, Real linear, Real quadratic)
| Sets the attenuation parameters of the light source i.e.
void | setAttenuationBasedOnRadius (Real radius, Real lumThreshold)
| Sets the attenuation parameters (range, constant, linear & quadratic,.
void | setCustomParameter (uint16 index, const Vector4 &value)
| Sets a custom parameter for this Light, which may be used to drive calculations for this specific Renderable, like GPU program parameters.
void | setDiffuseColour (const ColourValue &colour)
| Sets the colour of the diffuse light given off by this source.
void | setDiffuseColour (Real red, Real green, Real blue)
| Sets the colour of the diffuse light given off by this source.
void | setDirection (const Vector3 &vec)
| Sets the direction in which a light points.
void | setDoubleSided (bool bDoubleSided)
| For area lights and custom 2d shapes, specifies whether the light lits in both directions (positive & negative sides of the plane) or if only towards one.
void | setPowerScale (Real power)
| Set a scaling factor to indicate the relative power of a light.
void | setRectSize (Vector2 rectSize)
| For custom 2D shape and area lights, sets the dimensions of the rectangle.
void | setRenderQueueGroup (uint8 queueID) override
| Overload to avoid it. Light::setType uses the RenderQueue ID to classify lights per type.
void | setShadowFarClipDistance (Real farClip)
| Set the far clip plane distance to be used by the shadow camera, if this light casts texture shadows.
void | setShadowFarDistance (Real distance)
| Sets the maximum distance away from the camera that shadows by this light will be visible.
void | setShadowNearClipDistance (Real nearClip)
| Set the near clip plane distance to be used by the shadow camera, if this light casts texture shadows.
void | setSpecularColour (const ColourValue &colour)
| Sets the colour of the specular light given off by this source.
void | setSpecularColour (Real red, Real green, Real blue)
| Sets the colour of the specular light given off by this source.
void | setSpotlightFalloff (Real val)
| Sets the falloff between the inner and outer cones of the spotlight.
void | setSpotlightInnerAngle (const Radian &val)
| Sets the angle covered by the spotlights inner cone.
void | setSpotlightNearClipDistance (Real nearClip)
| Set the near clip plane distance to be used by spotlights that use light clipping, allowing you to render spots as if they start from further down their frustum.
void | setSpotlightOuterAngle (const Radian &val)
| Sets the angle covered by the spotlights outer cone.
void | setSpotlightRange (const Radian &innerAngle, const Radian &outerAngle, Real falloff=1.0)
| Sets the range of a spotlight, i.e.
void | setTexture (TextureGpu *texture)
| Sets a textured for types of light that support it.
void | setTextureRaw (TextureGpu *texture, uint32 sliceIdx)
void | setType (LightTypes type)
| Sets the type of light - see LightTypes for more info.
Public Member Functions inherited from Ogre::MovableObject
| MovableObject (IdType id, ObjectMemoryManager *objectMemoryManager, SceneManager *manager, uint8 renderQueueId)
| Constructor.
| MovableObject (ObjectData *objectDataPtrs)
| Don't use this constructor unless you know what you're doing.
virtual | ~MovableObject ()
| Virtual destructor - read Scott Meyers if you don't know why this is needed.
LightList * | _getLightList ()
| Returns a pointer to the current list of lights for this object.
SceneManager * | _getManager () const
| Get the manager of this object, if any (internal use only).
ObjectData & | _getObjectData ()
| Returns a direct access to the ObjectData state.
const Matrix4 & | _getParentNodeFullTransform () const
| Returns the full transformation of the parent sceneNode or the attachingPoint node.
virtual void | _notifyAttached (Node *parent)
| Internal method called to notify the object that it has been attached to a node.
void | _notifyManager (SceneManager *man)
| Notify the object of it's manager (internal use only).
virtual void | _notifyParentNodeMemoryChanged ()
virtual void | _notifyStaticDirty () const
| Called by SceneManager when it is telling we're a static MovableObject being dirty Don't call this directly.
virtual void | _releaseManualHardwareResources ()
| Notifies the movable object that hardware resources were lost.
virtual void | _restoreManualHardwareResources ()
| Notifies the movable object that hardware resources should be restored.
void | addQueryFlags (uint32 flags)
| As setQueryFlags, except the flags passed as parameters are appended to the existing flags on this object.
void | addVisibilityFlags (uint32 flags)
| As setVisibilityFlags, except the flags passed as parameters are appended to the existing flags on this object.
void | detachFromParent ()
| Detaches an object from a parent SceneNode if attached.
RealAsUint | getCachedDistanceToCamera () const
| Returns the distance to camera as calculated in cullFrustum().
Real | getCachedDistanceToCameraAsReal () const
| Returns the distance to camera as calculated in cullFrustum().
bool | getCastShadows () const
| Returns whether shadow casting is enabled for this object.
unsigned char | getCurrentMeshLod () const
uint32 | getLightMask () const
| Get a bitwise mask which will filter the lights affecting this object.
Listener * | getListener () const
| Gets the current listener for this object.
Aabb | getLocalAabb () const
| Retrieves the local axis-aligned bounding box for this object.
float | getLocalRadius () const
| See getLocalAabb and getWorldRadius.
const String & | getName () const
| Returns the name of this object.
Node * | getParentNode () const
| Returns the node to which this object is attached.
SceneNode * | getParentSceneNode () const
uint32 | getQueryFlags () const
| Returns the query flags relevant for this object.
Real | getRenderingDistance () const
| Gets the distance at which batches are no longer rendered.
Real | getRenderingMinPixelSize () const
| Returns the minimum pixel size an object needs to be in both screen axes in order to be rendered.
uint8 | getRenderQueueGroup () const
| Gets the queue group for this entity, see setRenderQueueGroup for full details.
Real | getShadowRenderingDistance () const
| Gets the distance at which batches are no longer casting shadows.
SkeletonInstance * | getSkeletonInstance () const
UserObjectBindings & | getUserObjectBindings ()
| Return an instance of user objects binding associated with this class.
const UserObjectBindings & | getUserObjectBindings () const
| Return an instance of user objects binding associated with this class.
uint32 | getVisibilityFlags () const
| Returns the visibility flags relevant for this object.
bool | getVisible () const
| Gets this object whether to be visible or not, if it has a renderable component.
Aabb | getWorldAabb () const
| Gets the axis aligned box in world space.
Aabb | getWorldAabbUpdated ()
| Gets the axis aligned box in world space.
float | getWorldRadius () const
| Gets the bounding Radius scaled by max( scale.x, scale.y, scale.z ).
float | getWorldRadiusUpdated ()
| Gets the bounding Radius scaled by max( scale.x, scale.y, scale.z ).
virtual void | instanceBatchCullFrustumThreaded (const Frustum *frustum, const Camera *lodCamera, uint32 combinedVisibilityFlags)
bool | isAttached () const
| Returns true if this object is attached to a Node.
bool | isStatic () const
| Checks whether this MovableObject is static.
bool | isVisible () const
| Returns whether or not this object is supposed to be visible or not.
const LightList & | queryLights () const
| Gets a list of lights, ordered relative to how close they are to this movable object.
void | removeQueryFlags (uint32 flags)
| As setQueryFlags, except the flags passed as parameters are removed from the existing flags on this object.
void | removeVisibilityFlags (uint32 flags)
| As setVisibilityFlags, except the flags passed as parameters are removed from the existing flags on this object.
void | setCastShadows (bool enabled)
| Sets whether or not this object will cast shadows.
void | setLightMask (uint32 lightMask)
| Set a bitwise mask which will filter the lights affecting this object.
void | setListener (Listener *listener)
| Sets a listener for this object.
void | setLocalAabb (const Aabb box)
| Sets the local axis-aligned bounding box for this object.
void | setName (const String &name)
| Sets a custom name for this node.
void | setQueryFlags (uint32 flags)
| Sets the query flags for this object.
void | setRenderingDistance (Real dist)
| Sets the distance at which the object is no longer rendered.
void | setRenderingMinPixelSize (Real pixelSize)
| Sets the minimum pixel size an object needs to be in both screen axes in order to be rendered.
void | setShadowRenderingDistance (Real dist)
| Sets the distance at which the object is no longer casting shadows.
bool | setStatic (bool bStatic)
| Turns this Node into static or dynamic.
void | setVisibilityFlags (uint32 flags)
| Sets the visibility flags for this object.
void | setVisible (bool visible)
| Tells this object whether to be visible or not, if it has a renderable component.
Public Member Functions inherited from Ogre::AnimableObject
| AnimableObject ()
virtual | ~AnimableObject ()
const StringVector & | getAnimableValueNames () const
| Gets a list of animable value names for this object.
Public Member Functions inherited from Ogre::IdObject
| IdObject (IdType id)
| We don't call generateNewId() here, to prevent objects in the stack (i.e.
IdType | getId () const
| Get the unique id of this object.
bool | operator() (const IdObject &left, const IdObject &right)
bool | operator() (const IdObject *left, const IdObject *right)
Public Member Functions inherited from Ogre::TextureGpuListener
virtual | ~TextureGpuListener ()
virtual bool | shouldStayLoaded (TextureGpu *texture)
| Return true if this TextureGpu should likely stay loaded or else graphical changes could occur.

## Public Attributes
uint16 | mTexLightMaskDiffuseMipStart
| Control the start of mip level for diffuse component for area lights The value is UNORM, thus the range [0; 65535] maps to [0; 1] where 1.0 means to use the highest mip level, and 0 the lowest mip.
uint16 | mTextureLightMaskIdx
Real | tempSquareDist
| Temp tag used for sorting.
Public Attributes inherited from Ogre::MovableObject
size_t | mGlobalIndex
| Index in the vector holding this MO reference (could be our parent node, or a global array tracking all movable objecst to avoid memory leaks).
size_t | mParentIndex
| Index in the vector holding this MO reference (could be our parent node, or a global array tracking all movable objecst to avoid memory leaks).
RenderableArray | mRenderables

## Additional Inherited Members
Static Public Member Functions inherited from Ogre::MovableObject
static void | buildLightList (const size_t numNodes, ObjectData t, const LightListInfo &globalLightList)
static void | calculateCastersBox (const size_t numNodes, ObjectData t, uint32 sceneVisibilityFlags, AxisAlignedBox *outBox)
static void | cullFrustum (const size_t numNodes, ObjectData t, const Camera *frustum, uint32 sceneVisibilityFlags, MovableObjectArray &outCulledObjects, const Camera *lodCamera)
static void | cullLights (const size_t numNodes, ObjectData t, uint32 sceneLightMask, LightListInfo &outGlobalLightList, const FrustumVec &frustums, const FrustumVec &cubemapFrustums)
| See SceneManager::cullLights & see MovableObject::cullFrustum.
static uint32 | getDefaultLightMask ()
| Get the default light mask for all future MovableObject instances.
static uint32 | getDefaultQueryFlags ()
| Get the default query flags for all future MovableObject instances.
static uint32 | getDefaultVisibilityFlags ()
| Get the default visibility flags for all future MovableObject instances.
static void | setDefaultLightMask (uint32 mask)
| Set the default light mask for all future MovableObject instances.
static void | setDefaultQueryFlags (uint32 flags)
| Set the default query flags for all future MovableObject instances.
static void | setDefaultVisibilityFlags (uint32 flags)
| Set the default visibility flags for all future MovableObject instances.
static void | updateAllBounds (const size_t numNodes, ObjectData t)
Static Public Attributes inherited from Ogre::MovableObject
static const FastArray< Real > | c_DefaultLodMesh

## Detailed Description

Representation of a dynamic light source in the scene.

Remarks
  Lights are added to the scene like any other object. They contain various parameters like type, position, attenuation (how light intensity fades with distance), colour etc.

  The defaults when a light is created is pure white diffuse light, with no attenuation (does not decrease with distance) and a range of 1000 world units.

  Lights are created by using the SceneManager::createLight method. Starting Ogre 2.0 all Lights must be associated to a SceneNode in order to work; which holds the position and direction. Light::setDirection and Light::getDirection will redirect to the SceneNode and assert or crash if not attached to one.

  Remember also that dynamic lights rely on modifying the colour of vertices based on the position of the light compared to an object's vertex normals. Dynamic lighting will only look good if the object being lit has a fair level of tessellation and the normals are properly set. This is particularly true for the spotlight which will only look right on highly tessellated models. In the future OGRE may be extended for certain scene types so an alternative to the standard dynamic lighting may be used, such as dynamic lightmaps.

## Member Enumeration Documentation

## ◆ LightTypes

enum Ogre::Light::LightTypes

Defines the type of light.

Enumerator
LT_DIRECTIONAL | Directional lights simulate parallel light beams from a distant source, hence have direction but no position.
LT_POINT | Point light sources give off light equally in all directions, so require only position not direction.
LT_SPOTLIGHT | Spotlights simulate a cone of light from a source so require position and direction, plus extra values for falloff.
LT_VPL | Virtual point lights, used for Instant Radiosity (Global Illumination fake / approximation).
MAX_FORWARD_PLUS_LIGHTS |
LT_AREA_APPROX | Non-PBR version of Area lights. Not an accurate approximation, but they're flexible, useful & cheap. They aren't physically correct at all.
LT_AREA_LTC | PBR version of Area lights using Linearly Transformed Cosines as researched by Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt. It's slower than LT_AREA_APPROX, and does not currently support textures. However it's physically accurate.
NUM_LIGHT_TYPES |

## Constructor & Destructor Documentation

## ◆ Light()

Ogre::Light::Light | ( | IdType | id,
|  | ObjectMemoryManager * | objectMemoryManager,
|  | SceneManager * | manager )

Normal constructor.

Should not be called directly, but rather the SceneManager::createLight method should be used.

## ◆ ~Light()

Ogre::Light::~Light | ( |  | ) |
| override

Standard destructor.

## Member Function Documentation

## ◆ _calcTempSquareDist()

void Ogre::Light::_calcTempSquareDist | ( | const Vector3 & | worldPos | ) |

Internal method for calculating current squared distance from some world position.

## ◆ _deriveShadowFarClipDistance()

Real Ogre::Light::_deriveShadowFarClipDistance | ( | const Camera * | maincam | ) | const

Derive a shadow camera far distance from either the light, or from the main camera if the light doesn't have its own setting.

## ◆ _deriveShadowNearClipDistance()

Real Ogre::Light::_deriveShadowNearClipDistance | ( | const Camera * | maincam | ) | const

Derive a shadow camera near distance from either the light, or from the main camera if the light doesn't have its own setting.

## ◆ _getOwnShadowFarDistance()

bool Ogre::Light::_getOwnShadowFarDistance | ( |  | ) | const

## ◆ _setLightProfileIdx()

void Ogre::Light::_setLightProfileIdx | ( | uint16 | profileIdx | ) |
| inline

## ◆ _updateCustomGpuParameter()

virtual void Ogre::Light::_updateCustomGpuParameter | ( | uint16 | paramIndex,
|  | const GpuProgramParameters_AutoConstantEntry & | constantEntry,
|  | GpuProgramParameters * | params ) const
| virtual

Update a custom GpuProgramParameters constant which is derived from information only this Light knows.

Remarks
  This method allows a Light to map in a custom GPU program parameter based on it's own data. This is represented by a GPU auto parameter of ACT_LIGHT_CUSTOM, and to allow there to be more than one of these per Light, the 'data' field on the auto parameter will identify which parameter is being updated and on which light. The implementation of this method must identify the parameter being updated, and call a 'setConstant' method on the passed in GpuProgramParameters object.

  You do not need to override this method if you're using the standard sets of data associated with the Renderable as provided by setCustomParameter and getCustomParameter. By default, the implementation will map from the value indexed by the 'constantEntry.data' parameter to a value previously set by setCustomParameter. But custom Renderables are free to override this if they want, in any case.

Parameters

  paramIndex | The index of the constant being updated
  constantEntry | The auto constant entry from the program parameters
  params | The parameters object which this method should call to set the updated parameters.

## ◆ _updateRenderQueue()

void Ogre::Light::_updateRenderQueue | ( | RenderQueue * | queue,
|  | Camera * | camera,
|  | const Camera * | lodCamera )
| inlineoverridevirtual

Internal method by which the movable object must add Renderable subclass instances to the rendering queue.

Remarks
  The engine will call this method when this object is to be rendered. The object must then create one or more Renderable subclass instances which it places on the passed in Queue for rendering.

Reimplemented from Ogre::MovableObject.

## ◆ createAnimableValue()

AnimableValuePtr Ogre::Light::createAnimableValue | ( | const String & | valueName | ) |
| overridevirtual

Create a reference-counted AnimableValuePtr for the named value.

Remarks
  You can use the returned object to animate a value on this object, using AnimationTrack. Subclasses must override this if they wish to support animation of their values.

Reimplemented from Ogre::AnimableObject.

## ◆ getAffectParentNode()

bool Ogre::Light::getAffectParentNode | ( |  | ) | const
| inline

## ◆ getAs4DVector()

Vector4 Ogre::Light::getAs4DVector | ( |  | ) | const

Tells this object whether to be visible or not, if it has a renderable component.

Note
  An alternative approach of making an object invisible is to detach it from it's SceneNode, or to remove the SceneNode entirely. Detaching a node means that structurally the scene graph changes. Once this change has taken place, the objects / nodes that have been removed have less overhead to the visibility detection pass than simply making the object invisible, so if you do this and leave the objects out of the tree for a long time, it's faster. However, the act of detaching / reattaching nodes is in itself more expensive than setting an object visibility flag, since in the latter case structural changes are not made. Therefore, small or frequent visibility changes are best done using this method; large or more longer term changes are best done by detaching.

Remarks
  Although lights themselves are not 'visible', setting a light to invisible means it no longer affects the scene. Gets the details of this light as a 4D vector.
  Getting details of a light as a 4D vector can be useful for doing general calculations between different light types; for example the vector can represent both position lights (w=1.0f) and directional lights (w=0.0f) and be used in the same calculations.

## ◆ getAttenuationConstant()

Real Ogre::Light::getAttenuationConstant | ( |  | ) | const
| inline

Returns the constant factor in the attenuation formula.

## ◆ getAttenuationLinear()

Real Ogre::Light::getAttenuationLinear | ( |  | ) | const
| inline

Returns the linear factor in the attenuation formula.

## ◆ getAttenuationQuadric()

Real Ogre::Light::getAttenuationQuadric | ( |  | ) | const
| inline

Returns the quadric factor in the attenuation formula.

## ◆ getAttenuationRange()

Real Ogre::Light::getAttenuationRange | ( |  | ) | const
| inline

Returns the absolute upper range of the light.

## ◆ getCustomParameter()

const Vector4 & Ogre::Light::getCustomParameter | ( | uint16 | index | ) | const

Gets the custom value associated with this Light at the given index.

Parameters

  index | Index of the parameter to retrieve

See also
  setCustomParameter for full details.

## ◆ getCustomParameterNoThrow()

const Vector4 * Ogre::Light::getCustomParameterNoThrow | ( | uint16 | index | ) | const

## ◆ getDerivedDirection()

Vector3 Ogre::Light::getDerivedDirection | ( |  | ) | const

Retrieves the direction of the light including any transform from nodes it is attached to.

## ◆ getDerivedDirectionUpdated()

Vector3 Ogre::Light::getDerivedDirectionUpdated | ( |  | ) | const

## ◆ getDerivedRectSize()

Vector2 Ogre::Light::getDerivedRectSize | ( |  | ) | const

## ◆ getDiffuseColour()

const ColourValue & Ogre::Light::getDiffuseColour | ( |  | ) | const
| inline

Returns the colour of the diffuse light given off by this light source (see setDiffuseColour for more info).

## ◆ getDirection()

Vector3 Ogre::Light::getDirection | ( |  | ) | const

Returns the light's direction.

Remarks
  Applicable only to the spotlight and directional light types. Try to cache the value instead of calling it multiple times in the same scope

## ◆ getDoubleSided()

bool Ogre::Light::getDoubleSided | ( |  | ) | const
| inline

## ◆ getLightProfileIdx()

uint16 Ogre::Light::getLightProfileIdx | ( |  | ) | const
| inline

## ◆ getMovableType()

const String & Ogre::Light::getMovableType | ( |  | ) | const
| overridevirtual

Returns the type name of this object.

Implements Ogre::MovableObject.

## ◆ getPowerScale()

Real Ogre::Light::getPowerScale | ( |  | ) | const
| inline

Set the scaling factor which indicates the relative power of a light.

## ◆ getRectSize()

const Vector2 & Ogre::Light::getRectSize | ( |  | ) | const
| inline

## ◆ getShadowFarClipDistance()

Real Ogre::Light::getShadowFarClipDistance | ( |  | ) | const
| inline

Get the far clip plane distance to be used by the shadow camera, if this light casts texture shadows.

Remarks
  May be zero if the light doesn't have it's own far distance set; use _deriveShadowfarDistance for a version guaranteed to give a result.

## ◆ getShadowFarDistance()

Real Ogre::Light::getShadowFarDistance | ( |  | ) | const

Gets the maximum distance away from the camera that shadows by this light will be visible.

## ◆ getShadowFarDistanceSquared()

Real Ogre::Light::getShadowFarDistanceSquared | ( |  | ) | const

## ◆ getShadowNearClipDistance()

Real Ogre::Light::getShadowNearClipDistance | ( |  | ) | const
| inline

Get the near clip plane distance to be used by the shadow camera, if this light casts texture shadows.

Remarks
  May be zero if the light doesn't have it's own near distance set; use _deriveShadowNearDistance for a version guaranteed to give a result.

## ◆ getSpecularColour()

const ColourValue & Ogre::Light::getSpecularColour | ( |  | ) | const
| inline

Returns the colour of specular light given off by this light source.

## ◆ getSpotlightFalloff()

Real Ogre::Light::getSpotlightFalloff | ( |  | ) | const
| inline

Returns the falloff between the inner and outer cones of the spotlight.

## ◆ getSpotlightInnerAngle()

const Radian & Ogre::Light::getSpotlightInnerAngle | ( |  | ) | const
| inline

Returns the angle covered by the spotlights inner cone.

## ◆ getSpotlightNearClipDistance()

Real Ogre::Light::getSpotlightNearClipDistance | ( |  | ) | const
| inline

Get the near clip plane distance to be used by spotlights that use light clipping.

## ◆ getSpotlightOuterAngle()

const Radian & Ogre::Light::getSpotlightOuterAngle | ( |  | ) | const
| inline

Returns the angle covered by the spotlights outer cone.

## ◆ getSpotlightTanHalfAngle()

Real Ogre::Light::getSpotlightTanHalfAngle | ( |  | ) | const
| inline

## ◆ getTexture()

TextureGpu * Ogre::Light::getTexture | ( |  | ) | const
| inline

## ◆ getType()

LightTypes Ogre::Light::getType | ( |  | ) | const
| inline

Returns the light type.

## ◆ isInLightRange() [1/2]

bool Ogre::Light::isInLightRange | ( | const Ogre::AxisAlignedBox & | container | ) | const

Check whether a bounding box is included in the lighted area of the light.

Note
  The function trades accuracy for efficiency. As a result you may get false-positives (The function should not return any false-negatives).

## ◆ isInLightRange() [2/2]

bool Ogre::Light::isInLightRange | ( | const Ogre::Sphere & | sphere | ) | const

Check whether a sphere is included in the lighted area of the light.

Note
  The function trades accuracy for efficiency. As a result you may get false-positives (The function should not return any false-negatives).

## ◆ notifyTextureChanged()

void Ogre::Light::notifyTextureChanged | ( | TextureGpu * | texture,
|  | TextureGpuListener::Reason | reason,
|  | void * | extraData )
| overridevirtual

Called when a TextureGpu changed in a way that affects how it is displayed:

1. TextureGpu::notifyDataIsReady got called (texture is ready to be displayed)
2. Texture changed residency status.
3. Texture is being deleted. It won't be a valid pointer after this call.

Implements Ogre::TextureGpuListener.

## ◆ resetShadowFarDistance()

void Ogre::Light::resetShadowFarDistance | ( |  | ) |

Tells the light to use the shadow far distance of the SceneManager.

## ◆ setAffectParentNode()

void Ogre::Light::setAffectParentNode | ( | bool | bAffect | ) |

A Light must always have a Node attached to it.

The direction is taken from the node's orientation, and thus setDirection modifies the attached node directly.

  However, when changing the range and the spot falloff; the node is not affected. This is intentional in case you want to create (e.g.) a node for a flashlight, and attach both the flashlight entity and the light to the same node; thus controlling the node moves both the flashlight and its visual effect.

  Despite this, there are cases where you want the changes to this light to be reflected in the parent node: The most common example are light volumes in deferred shading setups, and debug objects.

Remarks
  This setting is only useful for non-directional lights. For point lights, the scale is calculated as setSize( range, range, range ) which means a light volume should be a sphere of radius = 1;

  For spot lights, the scale is calc. as setSize( tan( outerAngle * 0.5 * range ), tan( outerAngle * 0.5 * range ), range ); which means a light volume should be a cone with Z = 1, and X & Y = 2

Parameters

  bAffect | When true, the scene node is affected and modified by changes to range and falloff.

## ◆ setAttenuation()

void Ogre::Light::setAttenuation | ( | Real | range,
|  | Real | constant,
|  | Real | linear,
|  | Real | quadratic )

Sets the attenuation parameters of the light source i.e.

how it diminishes with distance.

Remarks
  Lights normally get fainter the further they are away. Also, each light is given a maximum range beyond which it cannot affect any objects.

  Light attenuation is not applicable to directional lights since they have an infinite range and constant intensity.

  This follows a standard attenuation approach - see any good 3D text for the details of what they mean since i don't have room here!

Parameters

  range | The absolute upper range of the light in world units.
  constant | The constant factor in the attenuation formula: 1.0 means never attenuate, 0.0 is complete attenuation.
  linear | The linear factor in the attenuation formula: 1 means attenuate evenly over the distance.
  quadratic | The quadratic factor in the attenuation formula: adds a curvature to the attenuation formula.

## ◆ setAttenuationBasedOnRadius()

void Ogre::Light::setAttenuationBasedOnRadius | ( | Real | radius,
|  | Real | lumThreshold )

Sets the attenuation parameters (range, constant, linear & quadratic,.

See also
  setAttenuation) based on a given radius.

Remarks
  The actual attenuation formula is:

## 1

(distance / radius)² * 0.5 + 0.5

The original formula never ends, that is the range is infinity. This function calculates a range based on "lumThreshold": When the luminosity past certain distance is below the established threshold, the light calculations are cut.

Parameters

  radius | The radius of the light. i.e. A light bulb is a couple centimeters, the sun is ~696km; but be sure to be consistent in the unit of measurement you use (i.e. don't use km if your default unit is in meters). Note: Having a radius = 2 means that at distance = 2 the pixel is lit 100% Anything inside that radius (which is supposedly impossible) will have more than 100% light power.
  lumThreshold | Value in the range [0; 1) Sets range at which the luminance (in percentage) of a point would go below the threshold. For example lumThreshold = 0 means the attenuation range is infinity; lumThreshold = 1 means the range is set to 0.

  The value you want as threshold to use depends on your HDR pipeline and the power of the light. For example, with a power = 1 in LDR, a lumThreshold < 1 / 255 (roughly 0.00392) is pointless. Past that point the actual RGB value will always be (0, 0, 0). But for an LDR pipeline with a light power of 50, lumThreshold < 1 / (255 * 50) is pointless. For an HDR pipeline, the answer is more faint, as it depends on the threshold of your HDR tonemapping past which it stops adjusting the exposure.

## ◆ setCustomParameter()

void Ogre::Light::setCustomParameter | ( | uint16 | index,
|  | const Vector4 & | value )

Sets a custom parameter for this Light, which may be used to drive calculations for this specific Renderable, like GPU program parameters.

Remarks
  Calling this method simply associates a numeric index with a 4-dimensional value for this specific Light. This is most useful if the material which this Renderable uses a vertex or fragment program, and has an ACT_LIGHT_CUSTOM parameter entry. This parameter entry can refer to the index you specify as part of this call, thereby mapping a custom parameter for this renderable to a program parameter.

Parameters

  index | The index with which to associate the value. Note that this does not have to start at 0, and can include gaps. It also has no direct correlation with a GPU program parameter index - the mapping between the two is performed by the ACT_LIGHT_CUSTOM entry, if that is used.
  value | The value to associate.

## ◆ setDiffuseColour() [1/2]

void Ogre::Light::setDiffuseColour | ( | const ColourValue & | colour | ) |
| inline

Sets the colour of the diffuse light given off by this source.

Remarks
  Material objects have ambient, diffuse and specular values which indicate how much of each type of light an object reflects. This value denotes the amount and colour of this type of light the light exudes into the scene. The actual appearance of objects is a combination of the two.

  Diffuse light simulates the typical light emanating from light sources and affects the base colour of objects together with ambient light.

## ◆ setDiffuseColour() [2/2]

void Ogre::Light::setDiffuseColour | ( | Real | red,
|  | Real | green,
|  | Real | blue )
| inline

Sets the colour of the diffuse light given off by this source.

Remarks
  Material objects have ambient, diffuse and specular values which indicate how much of each type of light an object reflects. This value denotes the amount and colour of this type of light the light exudes into the scene. The actual appearance of objects is a combination of the two.

  Diffuse light simulates the typical light emanating from light sources and affects the base colour of objects together with ambient light.

## ◆ setDirection()

void Ogre::Light::setDirection | ( | const Vector3 & | vec | ) |

Sets the direction in which a light points.

Remarks
  Applicable only to the spotlight and directional light types.

Note
  This direction will be concatenated with the parent SceneNode.

## ◆ setDoubleSided()

void Ogre::Light::setDoubleSided | ( | bool | bDoubleSided | ) |

For area lights and custom 2d shapes, specifies whether the light lits in both directions (positive & negative sides of the plane) or if only towards one.

Parameters

  bDoubleSided | True to enable. Default: false.

## ◆ setPowerScale()

void Ogre::Light::setPowerScale | ( | Real | power | ) |

Set a scaling factor to indicate the relative power of a light.

Remarks
  This factor is only useful in High Dynamic Range (HDR) rendering. You can bind it to a shader variable to take it into account,

See also
  GpuProgramParameters

Parameters

  power | The power rating of this light, default is 1.0.

## ◆ setRectSize()

void Ogre::Light::setRectSize | ( | Vector2 | rectSize | ) |

For custom 2D shape and area lights, sets the dimensions of the rectangle.

Parameters

  rectSize | Dimensions of light area.

## ◆ setRenderQueueGroup()

void Ogre::Light::setRenderQueueGroup | ( | uint8 | queueID | ) |
| overridevirtual

Overload to avoid it. Light::setType uses the RenderQueue ID to classify lights per type.

Reimplemented from Ogre::MovableObject.

## ◆ setShadowFarClipDistance()

void Ogre::Light::setShadowFarClipDistance | ( | Real | farClip | ) |
| inline

Set the far clip plane distance to be used by the shadow camera, if this light casts texture shadows.

Remarks
  This is different from the 'shadow far distance', which is always measured from the main camera. This distance is the far clip plane of the light camera.

Parameters

  farClip | The distance, or -1 to use the main camera setting.

## ◆ setShadowFarDistance()

void Ogre::Light::setShadowFarDistance | ( | Real | distance | ) |

Sets the maximum distance away from the camera that shadows by this light will be visible.

Remarks
  Shadow techniques can be expensive, therefore it is a good idea to limit them to being rendered close to the camera if possible, and to skip the expense of rendering shadows for distance objects. This method allows you to set the distance at which shadows will no longer be rendered.

Note
  Each shadow technique can interpret this subtely differently. For example, one technique may use this to eliminate casters, another might use it to attenuate the shadows themselves. You should tweak this value to suit your chosen shadow technique and scene setup.

## ◆ setShadowNearClipDistance()

void Ogre::Light::setShadowNearClipDistance | ( | Real | nearClip | ) |
| inline

Set the near clip plane distance to be used by the shadow camera, if this light casts texture shadows.

Parameters

  nearClip | The distance, or -1 to use the main camera setting.

## ◆ setSpecularColour() [1/2]

void Ogre::Light::setSpecularColour | ( | const ColourValue & | colour | ) |
| inline

Sets the colour of the specular light given off by this source.

Remarks
  Material objects have ambient, diffuse and specular values which indicate how much of each type of light an object reflects. This value denotes the amount and colour of this type of light the light exudes into the scene. The actual appearance of objects is a combination of the two.

  Specular light affects the appearance of shiny highlights on objects, and is also dependent on the 'shininess' Material value.

## ◆ setSpecularColour() [2/2]

void Ogre::Light::setSpecularColour | ( | Real | red,
|  | Real | green,
|  | Real | blue )
| inline

Sets the colour of the specular light given off by this source.

Remarks
  Material objects have ambient, diffuse and specular values which indicate how much of each type of light an object reflects. This value denotes the amount and colour of this type of light the light exudes into the scene. The actual appearance of objects is a combination of the two.

  Specular light affects the appearance of shiny highlights on objects, and is also dependent on the 'shininess' Material value.

## ◆ setSpotlightFalloff()

void Ogre::Light::setSpotlightFalloff | ( | Real | val | ) |
| inline

Sets the falloff between the inner and outer cones of the spotlight.

## ◆ setSpotlightInnerAngle()

void Ogre::Light::setSpotlightInnerAngle | ( | const Radian & | val | ) |

Sets the angle covered by the spotlights inner cone.

## ◆ setSpotlightNearClipDistance()

void Ogre::Light::setSpotlightNearClipDistance | ( | Real | nearClip | ) |
| inline

Set the near clip plane distance to be used by spotlights that use light clipping, allowing you to render spots as if they start from further down their frustum.

Parameters

  nearClip | The near distance.

## ◆ setSpotlightOuterAngle()

void Ogre::Light::setSpotlightOuterAngle | ( | const Radian & | val | ) |

Sets the angle covered by the spotlights outer cone.

## ◆ setSpotlightRange()

void Ogre::Light::setSpotlightRange | ( | const Radian & | innerAngle,
|  | const Radian & | outerAngle,
|  | Real | falloff = 1.0 )

Sets the range of a spotlight, i.e.

the angle of the inner and outer cones and the rate of falloff between them.

Parameters

  innerAngle | Angle covered by the bright inner cone

Note
  The inner cone applicable only to Direct3D, it'll always treat as zero in OpenGL.

Parameters

  outerAngle | Angle covered by the outer cone
  falloff | The rate of falloff between the inner and outer cones. 1.0 means a linear falloff, less means slower falloff, higher means faster falloff.

## ◆ setTexture()

void Ogre::Light::setTexture | ( | TextureGpu * | texture | ) |

Sets a textured for types of light that support it.

At the time of writing only LT_AREA_APPROX supports it.

Remarks
  Note that HlmsPbs only supports one 2D Array texture active at a time. i.e. you must call hlmsPbs->setAreaLightMasks( texture ); and if that texture belongs to a different pool as the one you're inputting here, the wrong texture will be displayed!

Parameters

  texture | Texture. Can be monochrome or coloured. For Raw version must be a 2D Array texture. For non-Raw version, must be a 2D texture.
  sliceIdx | Slice to the texture.

## ◆ setTextureRaw()

void Ogre::Light::setTextureRaw | ( | TextureGpu * | texture,
|  | uint32 | sliceIdx )

## ◆ setType()

void Ogre::Light::setType | ( | LightTypes | type | ) |

Sets the type of light - see LightTypes for more info.

## Member Data Documentation

## ◆ mTexLightMaskDiffuseMipStart

uint16 Ogre::Light::mTexLightMaskDiffuseMipStart

Control the start of mip level for diffuse component for area lights The value is UNORM, thus the range [0; 65535] maps to [0; 1] where 1.0 means to use the highest mip level, and 0 the lowest mip.

## ◆ mTextureLightMaskIdx

uint16 Ogre::Light::mTextureLightMaskIdx

## ◆ tempSquareDist

Real Ogre::Light::tempSquareDist

Temp tag used for sorting.

The documentation for this class was generated from the following file:

- OgreLight.h