ComputerGraphik TU WIEN
Classes | Public Member Functions | Private Attributes | List of all members
ShadowMap Class Reference

Implementation of the shadow map effect. More...

#include <shadowMap.hpp>

Inheritance diagram for ShadowMap:
Light SceneObject

Classes

class  EffectObject
 

Public Member Functions

 ShadowMap (const std::string &name, Scene *scene=0, Model *model=0, const glm::mat4 &modelMatrix=glm::mat4(1))
 
virtual ~ShadowMap ()
 
void draw () const
 
void reset ()
 
void update (double deltaT)
 
void setShader (Shader *val)
 
glm::mat4 getDepthMVP () const
 
glm::mat4 getDepthBiasMVP () const
 
GLuint getDepthTexture () const
 
- Public Member Functions inherited from Light
 Light (const std::string &name, Scene *scene=0, Model *model=0, const glm::mat4 &modelMatrix=glm::mat4(1))
 Construct new light. More...
 
virtual ~Light ()
 
glm::vec3 getPower () const
 
glm::vec3 getDiffuse () const
 
glm::vec3 getAmbient () const
 
glm::vec3 getSpecular () const
 
glm::vec3 getPosition () const
 
void setPower (const glm::vec3 &val)
 
void setDiffuse (const glm::vec3 &val)
 
void setAmbient (const glm::vec3 &val)
 
void setSpecular (const glm::vec3 &val)
 
- Public Member Functions inherited from SceneObject
 SceneObject (std::shared_ptr< SceneObject > &effectParent, const glm::mat4 &modelMatrix=glm::mat4(1))
 
 SceneObject (const std::string &name, Scene *scene=0, Model *model=0, const glm::mat4 &modelMatrix=glm::mat4(1))
 
virtual ~SceneObject ()
 
ModelgetModel () const
 
ShadergetShader () const
 
glm::mat4 getModelMatrix () const
 
glm::mat4 getGlobalModelMatrix () const
 
std::string getName () const
 
std::shared_ptr< SceneObjectgetParent () const
 
void setAnimationTime (double time)
 
bool setAnimation (const Animation &anim)
 
bool delChild (size_t idx)
 
bool getChild (size_t idx, std::shared_ptr< SceneObject > &child) const
 
bool addChild (std::shared_ptr< SceneObject > &child)
 
bool remEffect (const std::string &name)
 
SceneObjectgetEffect (const std::string &name) const
 
bool addEffect (const std::string &name, std::unique_ptr< SceneObject > &effect)
 
bool doNotRender ()
 
bool getIsVolSun ()
 
virtual bool animate (double time)
 

Private Attributes

GLuint frameBuffer
 
GLuint depthTexture
 
glm::mat4 depthMVP
 
glm::mat4 depthBiasMVP
 

Additional Inherited Members

- Public Types inherited from SceneObject
typedef std::vector< std::pair< double, glm::mat4 > > Animation
 
- Protected Attributes inherited from Light
glm::vec3 power
 
glm::vec3 diffuse
 
glm::vec3 ambient
 
glm::vec3 specular
 
- Protected Attributes inherited from SceneObject
GLuint vao
 
Scenescene
 
Modelmodel
 
Shadershader
 
glm::mat4 modelMatrix
 
std::string name
 
std::weak_ptr< SceneObjectparent
 
std::vector< std::shared_ptr< SceneObject > > childs
 
std::map< std::string, std::unique_ptr< SceneObject > > effectChilds
 
size_t animIDX
 
Animation animation
 
bool norender
 
bool isVolSun
 

Detailed Description

Implementation of the shadow map effect.

Author
Adam

The scene is being rendered from the light source into a FrameBuffer, which has a texture attached to it. The texture will contain at each position the distance from the light source. When rendering the scene using the camera, the same distance is computed and compared with the one in the texture. If it is less, then the fragment is in shadow. To improve the quality of the shadows, PCF is being used. This is achived by using sampler2Dshadow in the fragment shader. The comparison must be enabled in texture parameters. To requesting a value from the sampler2Dshadow, the x and y texture coordinates and the light distance in the z are given. The sampler will compare also neighboring texels and gives back a value between 0 and 1, the ratio of the texels, which were less then the requested z.

See also
http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-16-shadow-mapping/

Constructor & Destructor Documentation

ShadowMap::ShadowMap ( const std::string &  name,
Scene scene = 0,
Model model = 0,
const glm::mat4 &  modelMatrix = glm::mat4(1) 
)
ShadowMap::~ShadowMap ( )
virtual

Member Function Documentation

void ShadowMap::draw ( ) const
virtual

Reimplemented from SceneObject.

glm::mat4 ShadowMap::getDepthBiasMVP ( ) const
inline
glm::mat4 ShadowMap::getDepthMVP ( ) const
inline
GLuint ShadowMap::getDepthTexture ( ) const
inline
void ShadowMap::reset ( )
virtual
Todo:
Add instanced effect for shadow map.

Reimplemented from SceneObject.

void ShadowMap::setShader ( Shader val)
virtual

Reimplemented from SceneObject.

void ShadowMap::update ( double  deltaT)
virtual

Reimplemented from SceneObject.

Member Data Documentation

glm::mat4 ShadowMap::depthBiasMVP
private
glm::mat4 ShadowMap::depthMVP
private
GLuint ShadowMap::depthTexture
private
GLuint ShadowMap::frameBuffer
private

The documentation for this class was generated from the following files: