2006-01-07 02:04:26 +01:00
|
|
|
/**
|
|
|
|
* =========================================================================
|
|
|
|
* File : ShadowMap.h
|
|
|
|
* Project : Pyrogenesis
|
|
|
|
* Description : Shadow mapping related texture and matrix management
|
|
|
|
*
|
|
|
|
* @author Nicolai Hähnle <nicolai@wildfiregames.com>
|
|
|
|
* =========================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SHADOWMAP_H
|
|
|
|
#define SHADOWMAP_H
|
|
|
|
|
|
|
|
#include "ogl.h"
|
|
|
|
|
|
|
|
class CBound;
|
|
|
|
class CMatrix3D;
|
|
|
|
|
|
|
|
struct ShadowMapInternals;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class ShadowMap: Maintain the shadow map texture and perform necessary OpenGL setup,
|
|
|
|
* including matrix calculations.
|
|
|
|
*
|
|
|
|
* The class will automatically generate a texture the first time the shadow map is rendered into.
|
|
|
|
* The texture will not be resized afterwards.
|
|
|
|
*
|
|
|
|
* @todo use depth textures for self-shadowing
|
|
|
|
*/
|
|
|
|
class ShadowMap
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ShadowMap();
|
|
|
|
~ShadowMap();
|
|
|
|
|
2006-01-29 18:34:45 +01:00
|
|
|
/**
|
|
|
|
* SetCameraAndLight: Configure light space for the given camera and light direction
|
|
|
|
*
|
|
|
|
* @param camera the camera that will be used for world rendering
|
|
|
|
* @param lightdir the direction of the (directional) sunlight
|
|
|
|
*/
|
|
|
|
void SetCameraAndLight(const CCamera& camera, const CVector3D& lightdir);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* AddShadowedBound: Add the bounding box of an object that has to be shadowed.
|
|
|
|
* This is used to calculate the bounds for the shadow map.
|
|
|
|
*
|
|
|
|
* @param bounds world space bounding box
|
|
|
|
*/
|
|
|
|
void AddShadowedBound(const CBound& bounds);
|
|
|
|
|
2006-01-07 02:04:26 +01:00
|
|
|
/**
|
|
|
|
* SetupFrame: Setup shadow map texture and matrices for this frame.
|
|
|
|
*
|
2006-01-29 18:34:45 +01:00
|
|
|
* @deprecated ???
|
2006-01-07 02:04:26 +01:00
|
|
|
* @param visibleBounds bound around objects that are visible on the screen
|
|
|
|
*/
|
|
|
|
void SetupFrame(const CBound& visibleBounds);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* BeginRender: Set OpenGL state for rendering into the shadow map texture.
|
2006-01-29 18:34:45 +01:00
|
|
|
*
|
2006-01-07 02:04:26 +01:00
|
|
|
* @todo this depends in non-obvious ways on the behaviour of the call-site
|
|
|
|
*/
|
|
|
|
void BeginRender();
|
2006-01-29 18:34:45 +01:00
|
|
|
|
2006-01-07 02:04:26 +01:00
|
|
|
/**
|
|
|
|
* EndRender: Finish rendering into the shadow map.
|
2006-01-29 18:34:45 +01:00
|
|
|
*
|
2006-01-07 02:04:26 +01:00
|
|
|
* @todo this depends in non-obvious ways on the behaviour of the call-site
|
|
|
|
*/
|
|
|
|
void EndRender();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GetTexture: Retrieve the OpenGL texture object name that contains the shadow map.
|
|
|
|
*
|
|
|
|
* @return the texture name of the shadow map texture
|
|
|
|
*/
|
|
|
|
GLuint GetTexture();
|
2006-01-29 18:34:45 +01:00
|
|
|
|
2006-01-07 02:04:26 +01:00
|
|
|
/**
|
|
|
|
* GetTextureMatrix: Retrieve the world-space to shadow map texture coordinates
|
|
|
|
* transformation matrix.
|
|
|
|
*
|
|
|
|
* @return the matrix that transforms world-space coordinates into homogenous
|
|
|
|
* shadow map texture coordinates
|
|
|
|
*/
|
|
|
|
const CMatrix3D& GetTextureMatrix();
|
|
|
|
|
2006-01-29 18:34:45 +01:00
|
|
|
/**
|
|
|
|
* RenderDebugDisplay: Visualize shadow mapping calculations to help in
|
|
|
|
* debugging and optimal shadow map usage.
|
|
|
|
*/
|
|
|
|
void RenderDebugDisplay();
|
|
|
|
|
2006-01-07 02:04:26 +01:00
|
|
|
private:
|
|
|
|
ShadowMapInternals* m;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SHADOWMAP_H
|