Panda3D
Public Member Functions | Public Attributes | List of all members
ShadowManager Class Reference
Inheritance diagram for ShadowManager:
ReferenceCount

Public Member Functions

 __init__ ()
 Constructs a new shadow atlas. More...
 
 __init__ (const ShadowManager)
 
ShadowAtlas getAtlas ()
 Returns a handle to the shadow atlas. More...
 
int getAtlasSize ()
 Returns the shadow atlas size. More...
 
int getNumUpdateSlotsLeft ()
 Returns how many update slots are left. More...
 
 init ()
 Initializes the ShadowManager. More...
 
 setAtlasGraphicsOutput (GraphicsOutput graphics_output)
 Sets the handle to the Shadow targets output. More...
 
 setAtlasSize (int atlas_size)
 Sets the shadow atlas size. More...
 
 setMaxUpdates (int max_updates)
 Sets the maximum amount of updates per frame. More...
 
 setScene (NodePath scene_parent)
 Sets the target scene. More...
 
 setTagStateManager (TagStateManager tag_mgr)
 Sets the handle to the TagStageManager. More...
 
 update ()
 Updates the ShadowManager. 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

ShadowAtlas atlas
 Returns a handle to the shadow atlas. More...
 
int atlas_size
 Returns the shadow atlas size. More...
 
int num_update_slots_left
 Returns how many update slots are left. 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 ()
 

Member Function Documentation

◆ __init__() [1/2]

__init__ ( )

Constructs a new shadow atlas.

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.

◆ __init__() [2/2]

__init__ ( const  ShadowManager)

◆ getAtlas()

ShadowAtlas getAtlas ( )

Returns a handle to the shadow atlas.

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.

Returns
The internal ShadowAtlas instance

◆ getAtlasSize()

int getAtlasSize ( )

Returns the shadow atlas size.

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

Returns
Shadow atlas size in pixels

◆ getNumUpdateSlotsLeft()

int getNumUpdateSlotsLeft ( )

Returns how many update slots are left.

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.

Returns
Number of update slots left.

◆ init()

init ( )

Initializes the ShadowManager.

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.

◆ setAtlasGraphicsOutput()

setAtlasGraphicsOutput ( GraphicsOutput  graphics_output)

Sets the handle to the Shadow targets 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.

Parameters
graphics_output[description]

◆ setAtlasSize()

setAtlasSize ( int  atlas_size)

Sets the shadow 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.

Parameters
atlas_sizeSize of the shadow atlas in pixels

◆ setMaxUpdates()

setMaxUpdates ( int  max_updates)

Sets the maximum amount of updates per frame.

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.

Parameters
max_updatesMaximum amoumt of updates

◆ setScene()

setScene ( NodePath  scene_parent)

Sets the target scene.

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.

Parameters
scene_parentThe target scene

◆ setTagStateManager()

setTagStateManager ( TagStateManager  tag_mgr)

Sets the handle to the TagStageManager.

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.

Parameters
tag_mgr[description]

◆ update()

update ( )

Updates the ShadowManager.

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.

Member Data Documentation

◆ atlas

ShadowAtlas atlas

Returns a handle to the shadow atlas.

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.

Returns
The internal ShadowAtlas instance

◆ atlas_size

int atlas_size

Returns the shadow atlas size.

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

Returns
Shadow atlas size in pixels

◆ num_update_slots_left

int num_update_slots_left

Returns how many update slots are left.

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.

Returns
Number of update slots left.