class ShadowManager

Bases: ReferenceCount

Inheritance diagram

ShadowManager(void)
ShadowManager(ShadowManager const&) = default

This constructs a new shadow atlas. There are a set of properties which should be set before calling ShadowManager::init(), see the set-Methods. After all properties are set, ShadowManager::init() should get called. ShadowManager::update() should get called on a per frame basis.

ShadowAtlas *get_atlas(void) const

This returns a handle to the internal shadow atlas instance. This is only valid after calling ShadowManager::init(). Calling this earlier will trigger an assertion and undefined behaviour.

std::size_t get_atlas_size(void) const

This returns the shadow atlas size previously set with ShadowManager::set_atlas_size().

std::size_t get_num_update_slots_left(void) const

This returns how many update slots are left. You can assume the next n calls to add_update will succeed, whereas n is the value returned by this function.

void init(void)

This initializes the ShadowManager. All properties should have been set before calling this, otherwise assertions will get triggered.

This setups everything required for rendering shadows, including the shadow atlas and the various shadow cameras. After calling this method, no properties can be changed anymore.

void set_atlas_graphics_output(GraphicsOutput *graphics_output)

This sets the handle to the GraphicsOutput of the shadow atlas. Usually this is RenderTarget.get_internal_buffer(), whereas the RenderTarget is the target of the ShadowStage.

This is used for creating display regions and attaching cameras to them, for performing shadow updates.

This has to get called before ShadowManager::init(), otherwise an assertion will be triggered.

void set_atlas_size(std::size_t atlas_size)

This sets the desired shadow atlas size. It should be big enough to store all important shadow sources, with some buffer, because the shadow maps usually won’t be fitted perfectly, so gaps can occur.

This has to get called before calling ShadowManager::init(). When calling this method after initialization, an assertion will get triggered.

void set_max_updates(std::size_t max_updates)

This controls the maximum amount of updated ShadowSources per frame. The ShadowManager will take the first <max_updates> ShadowSources, and generate shadow maps for them every frame. If there are more ShadowSources waiting to get updated than available updates, the sources are sorted by priority, and the update of the less important sources is delayed to the next frame.

If the update count is set too low, and there are a lot of ShadowSources waiting to get updated, artifacts will occur, and there might be ShadowSources which never get updated, due to low priority.

If an update count of 0 is passed, no updates will happen. This also means that there are no shadows. This is not recommended.

If an update count < 0 is passed, undefined behaviour occurs.

This method has to get called before ShadowManager::init(), otherwise an assertion will get triggered.

void set_scene(NodePath scene_parent)

This sets the target scene for rendering shadows. All shadow cameras will be parented to this scene to render shadows.

Usually the scene will be ShowBase.render. If the scene is an empty or invalid NodePath, an assertion will be triggered.

This method has to get called before calling ShadowManager::init(), or an assertion will get triggered.

void set_tag_state_manager(TagStateManager *tag_mgr)

This sets the handle to the TagStateManager used by the pipeline. Usually this is RenderPipeline.get_tag_mgr().

This has to get called before ShadowManager::init(), otherwise an assertion will get triggered.

void update(void)

This updates the ShadowManager, processing all shadow sources which need to get updated.

This first collects all sources which require an update, sorts them by priority, and then processes the first <max_updates> ShadowSources.

This may not get called before ShadowManager::init(), or an assertion will be thrown.