# panda3d._rplight.RPLight¶

from panda3d._rplight import RPLight

class RPLight

Bases: ReferenceCount

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.

Inheritance diagram

invalidateShadows() → None

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).

setPos(pos: LVecBase3) → None

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

setPos(x: float, y: float, z: float) → None

@copydetails :meth:RPLight.setPos(const LVecBase3 &pos)

getPos() → LVecBase3

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

Return type

LVecBase3

setColor(color: LVecBase3) → None

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.

setColor(r: float, g: float, b: float) → None

@copydetails :meth:RPLight.setColor(const LVecBase3 &color)

getColor() → LVecBase3

This returns the light color, previously set with RPLight.setColor(). 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.

Return type

LVecBase3

setColorFromTemperature(temperature: float) → None

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.

setEnergy(energy: float) → None

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.

getEnergy() → float

This returns the energy of the light, previously set with RPLight.setEnergy().

getLightType() → LightType

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

Return type

LightType

setCastsShadows(flag: bool) → None

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.

getCastsShadows() → bool

This returns whether the light casts shadows, the returned value is the one previously set with RPLight.setCastsShadows().

setShadowMapResolution(resolution: size_t) → None

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

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.

getShadowMapResolution() → size_t

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.setShadowMapResolution().

Return type

size_t

setIesProfile(profile: int) → None

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.

getIesProfile() → int

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

hasIesProfile() → bool

This returns whether the light has an ies profile assigned, previously done with RPLight.setIesProfile().

clearIesProfile() → None

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

setNearPlane(near_plane: float) → None

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.

getNearPlane() → float

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

property pos
Getter

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

Setter

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

@copydetails :meth:RPLight.setPos(const LVecBase3 &pos)

Return type

LVecBase3

property color
Getter

This returns the light color, previously set with RPLight.setColor(). 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.

Setter

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.

@copydetails :meth:RPLight.setColor(const LVecBase3 &color)

Return type

LVecBase3

property energy
Getter

This returns the energy of the light, previously set with RPLight.setEnergy().

Setter

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.

Return type

float

property light_type

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

Return type

LightType

property casts_shadows
Getter

This returns whether the light casts shadows, the returned value is the one previously set with RPLight.setCastsShadows().

Setter

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.

Return type

bool

property shadow_map_resolution
Getter

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.setShadowMapResolution().

Setter

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

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.

Return type

size_t

property ies_profile
Getter

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

Setter

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.

Return type

int

property near_plane
Getter

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

Setter

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.

Return type

float

enum LightType

Different types of light.

enumerator LT_empty = 0
enumerator LT_point_light = 1
enumerator LT_spot_light = 2