RPLight

from panda3d._rplight import RPLight
class RPLight

Bases:

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

Inheritance diagram of RPLight

enum LightType

Different types of light.

enumerator LT_empty = 0
enumerator LT_point_light = 1
enumerator LT_spot_light = 2
property casts_shadows bool
Getter

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

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.

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

property color LVecBase3
Getter

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.

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 RPLight::set_color(const LVecBase3 &color)

property energy float
Getter

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

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.

get_casts_shadows() bool

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

get_color() panda3d.core.LVecBase3

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.

get_energy() float

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

get_ies_profile() int

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

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

get_near_plane() float

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

get_pos() panda3d.core.LVecBase3

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

get_shadow_map_resolution() int

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.

has_ies_profile() bool

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

property ies_profile int
Getter

This returns the IES profile of a light, previously set with RPLight.set_ies_profile. 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 an RPPointLight, whereas for ies profiles which only cover the lower hemisphere you should use an RPSpotLight for the best performance.

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

property light_type 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.

property near_plane float
Getter

This returns the light’s near plane, previously set with RPLight.set_near_plane. 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().

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.

property pos LVecBase3
Getter

This returns the position of the light previously set with RPLight.set_pos(). 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 RPLight::set_pos(const LVecBase3 &pos)

set_casts_shadows(flag: bool)

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.

set_color(color: panda3d.core.LVecBase3)

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.

set_color(r: float, g: float, b: float)

@copydetails RPLight::set_color(const LVecBase3 &color)

set_color_from_temperature(temperature: float)

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.

set_energy(energy: float)

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.

set_ies_profile(profile: int)

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 an RPPointLight, whereas for ies profiles which only cover the lower hemisphere you should use an RPSpotLight for the best performance.

set_near_plane(near_plane: float)

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

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.

set_pos(pos: panda3d.core.LVecBase3)

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

set_pos(x: float, y: float, z: float)

@copydetails RPLight::set_pos(const LVecBase3 &pos)

set_shadow_map_resolution(resolution: int)

This sets the light’s 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. RPPointLight), this controls the resolution of each source. If the light has 6 shadow sources, and you use a resolution of 512x512, the light’s shadow map will occupy a space of 6 * 512x512 maps in the shadow atlas.

property shadow_map_resolution int
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.set_shadow_map_resolution.

Setter

This sets the light’s 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. RPPointLight), this controls the resolution of each source. If the light has 6 shadow sources, and you use a resolution of 512x512, the light’s shadow map will occupy a space of 6 * 512x512 maps in the shadow atlas.