InternalLightManager

from panda3d._rplight import InternalLightManager
class InternalLightManager

Bases:

This is the internal class used by the pipeline to handle all lights and shadows. It stores references to the lights, manages handling the light and shadow slots, and also communicates with the GPU with the GPUCommandQueue to store light and shadow source data.

Inheritance diagram

Inheritance diagram of InternalLightManager

__init__()

This constructs the light manager, initializing the light and shadow storage. You should set a command list and shadow manager before calling InternalLightManager.update. s

__init__(param0: InternalLightManager)
add_light(light: RPLight)

This adds a new light to the list of lights. This will throw an error and return if the light is already attached. You may only call this after the ShadowManager was already set.

While the light is attached, the light manager keeps a reference to it, so the light does not get destructed.

This also setups the shadows on the light, in case shadows are enabled. While a light is attached, you can not change whether it casts shadows or not. To do so, detach the light, change the setting, and re-add the light.

In case no free light slot is available, an error will be printed and no action will be performed.

If no shadow manager was set, an assertion will be triggered.

get_max_light_index() int

This returns the maximum light index (also called slot). Any lights after that slot are guaranteed to be zero-lights. This is useful when iterating over the list of lights, because iteration can be stopped when the maximum light index is reached.

The maximum light index points to the last slot which is used. If no lights are attached, -1 is returned. If one light is attached at slot 0, the index is 0, if two are attached at the slots 0 and 1, the index is 1, and so on.

If, for example, two lights are attached at the slots 2 and 5, then the index will be 5. Keep in mind that the max-index is not an indicator for how many lights are attached. Also, zero lights still may occur when iterating over the light lists

get_num_lights() int

This returns the amount of stored lights. This behaves unlike InternalLightManager.get_max_light_index, and instead returns the true amount of lights, which is completely unrelated to the amount of used slots.

get_num_shadow_sources() int

This returns the total amount of stored shadow sources. This does not denote the amount of updated sources, but instead takes into account all sources, even those out of frustum.

get_shadow_manager() ShadowManager

This returns a handle to the internally used shadow manager

property max_light_index int

This returns the maximum light index (also called slot). Any lights after that slot are guaranteed to be zero-lights. This is useful when iterating over the list of lights, because iteration can be stopped when the maximum light index is reached.

The maximum light index points to the last slot which is used. If no lights are attached, -1 is returned. If one light is attached at slot 0, the index is 0, if two are attached at the slots 0 and 1, the index is 1, and so on.

If, for example, two lights are attached at the slots 2 and 5, then the index will be 5. Keep in mind that the max-index is not an indicator for how many lights are attached. Also, zero lights still may occur when iterating over the light lists

property num_lights int

This returns the amount of stored lights. This behaves unlike InternalLightManager.get_max_light_index, and instead returns the true amount of lights, which is completely unrelated to the amount of used slots.

property num_shadow_sources int

This returns the total amount of stored shadow sources. This does not denote the amount of updated sources, but instead takes into account all sources, even those out of frustum.

remove_light(light: RPLight)

This detaches a light. This prevents it from being rendered, and also cleans up all resources used by that light. If no reference is kept on the python side, the light will also get destructed.

If the light was not previously attached with InternalLightManager.add_light, an error will be triggered and nothing happens.

In case the light was set to cast shadows, all shadow sources are cleaned up, and their regions in the shadow atlas are freed.

All resources used by the light in the light and shadow storage are also cleaned up, by emitting cleanup GPUCommands.

If no shadow manager was set, an assertion will be triggered.

set_camera_pos(pos: panda3d.core.LPoint3)

This sets the camera position, which will be used to determine which shadow sources have to get updated

set_command_list(cmd_list: GPUCommandList)

This sets a handle to the global GPUCommandList. This is required to emit GPUCommands, which are used for attaching and detaching lights, as well as shadow source updates.

The cmd_list should be a handle to a GPUCommandList handle, and will be stored somewhere on the python side most likely. The light manager does not keep a reference to it, so the python side should make sure to keep one.

Be sure to call this before the InternalLightManager.update() method is called, otherwise an assertion will get triggered.

set_shadow_manager(mgr: ShadowManager)

This sets the handle to the global shadow manager. It is usually constructed on the python side, so we need to get a handle to it.

The manager should be a handle to a ShadowManager instance, and will be stored somewhere on the python side most likely. The light manager does not keep a reference to it, so the python side should make sure to keep one.

Be sure to call this before the InternalLightManager.update() method is called, otherwise an assertion will get triggered.

set_shadow_update_distance(dist: float)

This controls the maximum distance until which shadows are updated. If a shadow source is past that distance, it is ignored and no longer recieves updates until it is in range again

property shadow_manager ShadowManager
Getter

This returns a handle to the internally used shadow manager

Setter

This sets the handle to the global shadow manager. It is usually constructed on the python side, so we need to get a handle to it.

The manager should be a handle to a ShadowManager instance, and will be stored somewhere on the python side most likely. The light manager does not keep a reference to it, so the python side should make sure to keep one.

Be sure to call this before the InternalLightManager.update() method is called, otherwise an assertion will get triggered.

update()

This is the main update method of the InternalLightManager. It processes all lights and shadow sources, updates them, and notifies the GPU about it. This should be called on a per-frame basis.

If the InternalLightManager was not initialized yet, an assertion is thrown.