Om
1.0.0
A universal framework for multimedia simulation
|
A class that manages a set of cached shadow maps that it renders. More...
#include <omGraphicsShadowMapRenderer.h>
Public Member Functions | |
ShadowMapRenderer () | |
Create a new shadow map renderer which does not have a valid graphics context. More... | |
ShadowMapRenderer (GraphicsContext *newContext) | |
Create a new shadow map renderer which uses the specified context to render shadow maps. More... | |
void | setContext (GraphicsContext *newContext) |
Change the graphics context that should be used to render shadow maps. More... | |
const GraphicsScene * | getScene () const |
Return a pointer to the scene that is currently being used to render shadow maps. More... | |
void | setScene (const GraphicsScene *newScene) |
Set a pointer to the scene that should be used to render shadow maps. More... | |
const ShadowMap * | cacheShadowMap (const Light *light) |
Render the shadow map for the given light and return the shadow map. More... | |
const ShadowMap * | cacheShadowMap (const Light *light, const Camera *camera) |
Render the shadow map for the given light and camera combination if necessary and return the shadow map. More... | |
const ShadowMap * | getShadowMap (const Light *light) const |
Return the shadow map for the given light stored in the renderer's cache. More... | |
const ShadowMap * | getShadowMap (const Light *light, const Camera *camera) const |
Return the shadow map for the given light and camera combination stored in the renderer's cache. More... | |
Size | getCacheSize () const |
Return the total number of cached entries in the shadow map cache. More... | |
Size | getCacheSizeInBytes () const |
Return the approximate memory usage in bytes of the entries in the shadow map cache. More... | |
void | emptyCache () |
Remove all previously cached shadow maps from this shadow map renderer's internal cache, keeping the texture storage. More... | |
void | clearCache () |
Remove all previously cached shadow maps from this shadow map renderer's internal cache. More... | |
Real | getShadowQuality () const |
Return a value indicating the approximate pixel-to-unit scale factor for shadow textures. More... | |
void | setShadowQuality (Real newShadowQuality) |
Set a value indicating the approximate pixel-to-unit scale factor for shadow textures. More... | |
Size | getMinimumShadowSize () const |
Return the minimum allowed resolution (width or height) for a shadow map. More... | |
void | setMinimumShadowSize (Size newMinimumShadowSize) |
Set the minimum allowed resolution (width or height) for a shadow map. More... | |
Size | getMaximumShadowSize () const |
Return the maximum allowed resolution (width or height) for a shadow map. More... | |
void | setMaximumShadowSize (Size newMaximumShadowSize) |
Set the maximum allowed resolution (width or height) for a shadow map. More... | |
A class that manages a set of cached shadow maps that it renders.
om::graphics::renderers::ShadowMapRenderer::ShadowMapRenderer | ( | ) |
Create a new shadow map renderer which does not have a valid graphics context.
om::graphics::renderers::ShadowMapRenderer::ShadowMapRenderer | ( | GraphicsContext * | newContext | ) |
Create a new shadow map renderer which uses the specified context to render shadow maps.
void om::graphics::renderers::ShadowMapRenderer::setContext | ( | GraphicsContext * | newContext | ) |
Change the graphics context that should be used to render shadow maps.
This method resets any internal context-specific rendering state, including any cached shadow maps.
|
inline |
Return a pointer to the scene that is currently being used to render shadow maps.
|
inline |
Set a pointer to the scene that should be used to render shadow maps.
|
inline |
Render the shadow map for the given light and return the shadow map.
If the shadow map for this light was not already stored in the cache for this shadow map renderer, it is added to the cache. Otherwise, the shadow map that was stored in the cache is returned. A pointer to this shadow map is returned.
If there was an error in accessing the cache or creating shadow map, a NULL pointer is returned. If the light pointer is NULL the method fails, returning NULL.
Since no camera is specified, the camera's view is not taken into account when rendering the shadow map for the light. This may result in lower quality shadows. This method is equivalent to calling the overload cacheShadowMap(light,NULL).
const ShadowMap* om::graphics::renderers::ShadowMapRenderer::cacheShadowMap | ( | const Light * | light, |
const Camera * | camera | ||
) |
Render the shadow map for the given light and camera combination if necessary and return the shadow map.
If the shadow map for this light/camera pair was not already stored in the cache for this shadow map renderer, it is added to the cache. Otherwise, the shadow map that was stored in the cache is returned. A pointer to this shadow map is returned.
If there was an error in accessing the cache or creating shadow map, a NULL pointer is returned. If the light pointer is NULL the method fails, returning NULL.
If the camera pointer is NULL, the camera's view is not taken into account when rendering the shadow map for the light. This may result in lower quality shadows.
|
inline |
Return the shadow map for the given light stored in the renderer's cache.
If there is no shadow map for this light, a NULL pointer is returned.
const ShadowMap* om::graphics::renderers::ShadowMapRenderer::getShadowMap | ( | const Light * | light, |
const Camera * | camera | ||
) | const |
Return the shadow map for the given light and camera combination stored in the renderer's cache.
If there is no shadow map for this combination, a NULL pointer is returned.
|
inline |
Return the total number of cached entries in the shadow map cache.
This is the number of shadow maps that currently in use (not counting unused shadow map textures).
|
inline |
Return the approximate memory usage in bytes of the entries in the shadow map cache.
This is computed from the number of shadow maps that currently in use (not counting unused shadow map textures).
void om::graphics::renderers::ShadowMapRenderer::emptyCache | ( | ) |
Remove all previously cached shadow maps from this shadow map renderer's internal cache, keeping the texture storage.
This method should generally be called at the beginning of drawing the shadow maps for the scene because it removes all cached shadow maps from the previous frame. This method allows the texture storage from the last frame to be reused, unlike the clearCache() method.
void om::graphics::renderers::ShadowMapRenderer::clearCache | ( | ) |
Remove all previously cached shadow maps from this shadow map renderer's internal cache.
This method also releases all texture storage that was previously used by the cache. Calling this method every frame may be expensive, since textures would need to be recreated after each call.
|
inline |
Return a value indicating the approximate pixel-to-unit scale factor for shadow textures.
This value is used to determine the resolution of a shadow map in order to meet a minimum texel density per world unit.
The default shadow quality is 100, corresponding to 100 texels per world unit. If the units are meters, this means one texel per centimeter.
|
inline |
Set a value indicating the approximate pixel-to-unit scale factor for shadow textures.
This value is used to determine the resolution of a shadow map in order to meet a minimum texel density per world unit.
The new shadow quality factor is clamped to be greater than 0.001, which would correspond to a 1-texel-per-kilometer resolution if meters are the units.
The default shadow quality is 100, corresponding to 100 texels per world unit. If the units are meters, this means one texel per centimeter.
|
inline |
Return the minimum allowed resolution (width or height) for a shadow map.
|
inline |
Set the minimum allowed resolution (width or height) for a shadow map.
This value is clamped to be greater than 1.
|
inline |
Return the maximum allowed resolution (width or height) for a shadow map.
|
inline |
Set the maximum allowed resolution (width or height) for a shadow map.
This value is clamped to be greater than 1.