Panda3D
Public Types | Public Member Functions | Public Attributes | List of all members
RPLight Class Reference

Base class for Lights. More...

Inheritance diagram for RPLight:
ReferenceCount RPPointLight RPSpotLight

Public Types

enum  LightType { LT_empty = 0, LT_point_light = 1, LT_spot_light = 2 }
 Different types of light. More...
 

Public Member Functions

 clearIesProfile ()
 Clears the ies profile. More...
 
bool getCastsShadows ()
 Returns whether the light casts shadows. More...
 
const LVecBase3 getColor ()
 Returns the lights color. More...
 
float getEnergy ()
 Returns the energy of the light. More...
 
int getIesProfile ()
 Returns the lights ies profile. More...
 
RPLight::LightType getLightType ()
 Returns the type of the light. More...
 
float getNearPlane ()
 Returns the near plane of the light. More...
 
const LVecBase3 getPos ()
 Returns the position of the light. More...
 
int getShadowMapResolution ()
 Returns the shadow map resolution. More...
 
bool hasIesProfile ()
 Returns whether the light has an ies profile assigned. More...
 
 invalidateShadows ()
 Invalidates the shadows. More...
 
 setCastsShadows (bool flag)
 Controls whether the light casts shadows. More...
 
 setColor (const LVecBase3 color)
 Sets the lights color. More...
 
 setColor (float r, float g, float b)
 Sets the lights color. More...
 
 setColorFromTemperature (float temperature)
 Sets the lights color from a given color temperature. More...
 
 setEnergy (float energy)
 Sets the energy of the light. More...
 
 setIesProfile (int profile)
 Sets the ies profile. More...
 
 setNearPlane (float near_plane)
 Sets the near plane of the light. More...
 
 setPos (const LVecBase3 pos)
 Sets the position of the light. More...
 
 setPos (float x, float y, float z)
 Sets the position of the light. More...
 
 setShadowMapResolution (int resolution)
 Sets the lights shadow map resolution. More...
 
- Public Member Functions inherited from ReferenceCount
int getRefCount ()
 Returns the current reference count. More...
 
 ref ()
 Explicitly increments the reference count. More...
 
bool testRefCountIntegrity ()
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool testRefCountNonzero ()
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
bool unref ()
 Explicitly decrements the reference count. More...
 

Public Attributes

bool casts_shadows
 Returns whether the light casts shadows. More...
 
const LVecBase3 color
 Returns the lights color. More...
 
float energy
 Returns the energy of the light. More...
 
int ies_profile
 Returns the lights ies profile. More...
 
RPLight::LightType light_type
 Returns the type of the light. More...
 
float near_plane
 Returns the near plane of the light. More...
 
const LVecBase3 pos
 Returns the position of the light. More...
 
int shadow_map_resolution
 Returns the shadow map resolution. More...
 
- Public Attributes inherited from ReferenceCount
int ref_count
 The current reference count. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ReferenceCount
static TypeHandle getClassType ()
 

Detailed Description

Base class for Lights.

This is the base class for all lights in the render pipeline. It stores common properties, and provides methods to modify these. It also defines some interface functions which subclasses have to implement.

Member Enumeration Documentation

◆ LightType

enum LightType

Different types of light.

Enumerator
LT_empty 
LT_point_light 
LT_spot_light 

Member Function Documentation

◆ clearIesProfile()

clearIesProfile ( )

Clears the ies profile.

This clears the ies profile of the light, telling it to no longer use an ies profile, and instead use the default attenuation.

◆ getCastsShadows()

bool getCastsShadows ( )

Returns whether the light casts shadows.

This returns whether the light casts shadows, the returned value is the one previously set with RPLight::set_casts_shadows.

Returns
true if the light casts shadows, false otherwise

◆ getColor()

const LVecBase3 getColor ( )

Returns the lights color.

This returns the light color, previously set with RPLight::set_color. This does not include the energy of the light. It might differ from what was set with set_color, because the color is normalized by dividing it by its luminance.

Returns
Light-color

◆ getEnergy()

float getEnergy ( )

Returns the energy of the light.

This returns the energy of the light, previously set with RPLight::set_energy.

Returns
energy of the light

◆ getIesProfile()

int getIesProfile ( )

Returns the lights ies profile.

This returns the ies profile of a light, previously set with RPLight::set_ies_profile. In case no ies profile was set, returns -1.

Returns
IES Profile handle

◆ getLightType()

RPLight::LightType getLightType ( )

Returns the type of the light.

This returns the internal type of the light, which was specified in the lights constructor. This can be used to distinguish between light types.

Returns
Type of the light

◆ getNearPlane()

float getNearPlane ( )

Returns the near plane of the light.

This returns the lights near plane, previously set with RPLight::set_near_plane. If the light does not cast shadows, this value is meaningless.

Returns
Near-plane

◆ getPos()

const LVecBase3 getPos ( )

Returns the position of the light.

This returns the position of the light previously set with RPLight::set_pos(). The returned position is in world space.

Returns
Light-position

◆ getShadowMapResolution()

int getShadowMapResolution ( )

Returns the shadow map resolution.

This returns the shadow map resolution of each source of the light. If the light is not setup to cast shadows, this value is meaningless. The returned value is the one previously set with RPLight::set_shadow_map_resolution.

Returns
Shadow map resolution in pixels

◆ hasIesProfile()

bool hasIesProfile ( )

Returns whether the light has an ies profile assigned.

This returns whether the light has an ies profile assigned, previously done with RPLight::set_ies_profile.

Returns
true if the light has an ies profile assigned, false otherwise

◆ invalidateShadows()

invalidateShadows ( )

Invalidates the shadows.

This invalidates all shadows of the light, causing them to get regenerated. This might be the case when the lights position or similar changed. This will cause all shadow sources to be updated, emitting a shadow update. Be careful when calling this method if you don't want all sources to get updated. If you only have to invalidate a single shadow source, use get_shadow_source(n)->set_needs_update(true).

◆ setCastsShadows()

setCastsShadows ( bool  flag)

Controls whether the light casts shadows.

This sets whether the light casts shadows. You can not change this while the light is attached. When flag is set to true, the light will be setup to cast shadows, spawning shadow sources based on the lights type. If the flag is set to false, the light will be inddicated to cast no shadows.

Parameters
flagWhether the light casts shadows

◆ setColor() [1/2]

setColor ( const LVecBase3  color)

Sets the lights color.

This sets the lights color. The color should not include the brightness of the light, you should control that with the energy. The color specifies the lights "tint" and will get multiplied with its specular and diffuse contribution.

The color will be normalized by dividing by the colors luminance. Setting higher values than 1.0 will have no effect.

Parameters
colorLight color

◆ setColor() [2/2]

setColor ( float  r,
float  g,
float  b 
)

Sets the lights color.

Parameters
rRed-component of the color
gGreen-component of the color
bBlue-component of the color

◆ setColorFromTemperature()

setColorFromTemperature ( float  temperature)

Sets the lights color from a given color temperature.

This sets the lights color, given a temperature. This is more physically based than setting a user defined color. The color will be computed from the given temperature.

Parameters
temperatureLight temperature

◆ setEnergy()

setEnergy ( float  energy)

Sets the energy of the light.

This sets the energy of the light, which can be seen as the brightness of the light. It will get multiplied with the normalized color.

Parameters
energyenergy of the light

◆ setIesProfile()

setIesProfile ( int  profile)

Sets the ies profile.

This sets the ies profile of the light. The parameter should be a handle previously returned by RenderPipeline.load_ies_profile. Using a value of -1 indicates no ies profile.

Notice that for ies profiles which cover a whole range, you should use PointLights, whereas for ies profiles which only cover the lower hemisphere you should use SpotLights for the best performance.

Parameters
profileIES Profile handle

◆ setNearPlane()

setNearPlane ( float  near_plane)

Sets the near plane of the light.

This sets the near plane of all shadow sources of the light. It has no effects if the light does not cast shadows. This prevents artifacts from objects near to the light. It behaves like Lens::set_near_plane.

It can also help increasing shadow map precision, low near planes will cause the precision to suffer. Try setting the near plane as big as possible.

If a negative or zero near plane is passed, an assertion is thrown.

Parameters
near_planeNear-plane

◆ setPos() [1/2]

setPos ( const LVecBase3  pos)

Sets the position of the light.

This sets the position of the light in world space. It will cause the light to get invalidated, and resubmitted to the GPU.

Parameters
posPosition in world space

◆ setPos() [2/2]

setPos ( float  x,
float  y,
float  z 
)

Sets the position of the light.

Parameters
xX-component of the position
yY-component of the position
zZ-component of the position

◆ setShadowMapResolution()

setShadowMapResolution ( int  resolution)

Sets the lights shadow map resolution.

This sets the lights shadow map resolution. This has no effect when the light is not told to cast shadows (Use RPLight::set_casts_shadows).

When calling this on a light with multiple shadow sources (e.g. PointLight), this controls the resolution of each source. If the light has 6 shadow sources, and you use a resolution of 512x512, the lights shadow map will occur a space of 6 * 512x512 maps in the shadow atlas.

Parameters
resolutionResolution of the shadow map in pixels

Member Data Documentation

◆ casts_shadows

bool casts_shadows

Returns whether the light casts shadows.

This returns whether the light casts shadows, the returned value is the one previously set with RPLight::set_casts_shadows.

Returns
true if the light casts shadows, false otherwise

◆ color

const LVecBase3 color

Returns the lights color.

This returns the light color, previously set with RPLight::set_color. This does not include the energy of the light. It might differ from what was set with set_color, because the color is normalized by dividing it by its luminance.

Returns
Light-color

◆ energy

float energy

Returns the energy of the light.

This returns the energy of the light, previously set with RPLight::set_energy.

Returns
energy of the light

◆ ies_profile

int ies_profile

Returns the lights ies profile.

This returns the ies profile of a light, previously set with RPLight::set_ies_profile. In case no ies profile was set, returns -1.

Returns
IES Profile handle

◆ light_type

RPLight::LightType light_type

Returns the type of the light.

This returns the internal type of the light, which was specified in the lights constructor. This can be used to distinguish between light types.

Returns
Type of the light

◆ near_plane

float near_plane

Returns the near plane of the light.

This returns the lights near plane, previously set with RPLight::set_near_plane. If the light does not cast shadows, this value is meaningless.

Returns
Near-plane

◆ pos

const LVecBase3 pos

Returns the position of the light.

This returns the position of the light previously set with RPLight::set_pos(). The returned position is in world space.

Returns
Light-position

◆ shadow_map_resolution

int shadow_map_resolution

Returns the shadow map resolution.

This returns the shadow map resolution of each source of the light. If the light is not setup to cast shadows, this value is meaningless. The returned value is the one previously set with RPLight::set_shadow_map_resolution.

Returns
Shadow map resolution in pixels