56 Eigen::Vector2i
viewport = Eigen::Vector2i(1024, 1024);
82 loadShader(shadowbuffer_shader,
"shadowbuffer");
83 loadShader(drawbuffer_shader,
"rendershadowmap");
138 aa_fbo.
create(viewport[0], viewport[1], 1, 1);
139 fbo.
create(viewport[0], viewport[1], 1, num_samples);
144 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
151 glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
152 drawbuffer_shader.
bind();
156 drawbuffer_shader.
unbind();
172 recreate_fbo =
false;
175 glEnable(GL_DEPTH_TEST);
177 glViewport(0, 0, viewport[0], viewport[1]);
182 shadowbuffer_shader.
bind();
190 shadowbuffer_shader.
unbind();
Texture * getTexture(int tex_id)
Returns a pointer to a texture (attachment).
Definition: framebuffer.hpp:206
Tucano::Shader shadowbuffer_shader
Creates the shadowmap depth buffer by rendering from light pos.
Definition: shadowmap.hpp:47
void createQuad(void)
Sets the mesh as Unit Quad.
Definition: mesh.hpp:841
void getViewMatrix(GLdouble *matrix)
Return the modelview matrix as a GLdouble array.
Definition: camera.hpp:126
Tucano::Shader drawbuffer_shader
Shader to render shadow map.
Definition: shadowmap.hpp:50
void getProjectionMatrix(GLdouble *matrix)
Return the projection matrix as a GLdouble array.
Definition: camera.hpp:142
Definition: bufferobject.hpp:34
void clearAttachments(Eigen::Vector4f clear_color=Eigen::Vector4f::Zero())
Clears all attachments with a given color.
Definition: framebuffer.hpp:448
void bind(int texture_unit)
Binds the texture to a given unit. Note that if there is another texture already binded to this unit...
Definition: texture.hpp:285
ShadowMap(void)
Default constructor.
Definition: shadowmap.hpp:71
void renderBuffer(const Tucano::Camera &camera)
Definition: shadowmap.hpp:148
void setTexParameters(GLenum wraps=GL_CLAMP, GLenum wrapt=GL_CLAMP, GLenum magfilter=GL_NEAREST, GLenum minfilter=GL_NEAREST)
Deletes the texture.
Definition: texture.hpp:221
int num_samples
Definition: shadowmap.hpp:60
Definition: shadowmap.hpp:37
A Shader object represents one GLSL program.
Definition: shader.hpp:45
virtual void initialize(void)
Initializes the ShadowMap effects,.
Definition: shadowmap.hpp:80
virtual void bindRenderBuffer(GLuint attachID)
Bind framebuffer object and set render buffer to given attachment.
Definition: framebuffer.hpp:258
Tucano::Framebuffer fbo
Framebuffer to store the shadow depth map, this is using multisampling.
Definition: shadowmap.hpp:41
void createBuffers(void)
Creates FBOs, or recreates when size changes.
Definition: shadowmap.hpp:136
void setBufferSize(const Eigen::Vector2i &size)
Set the shadow buffer size.
Definition: shadowmap.hpp:127
Eigen::Vector2i viewport
Shadowbuffer size.
Definition: shadowmap.hpp:56
int depth_tex_id
Definition: shadowmap.hpp:58
Tucano::Mesh quad
Quad for rendering shadow map, mostly for debug.
Definition: shadowmap.hpp:53
void unbind(void)
Unbinds fbo and all texture units in use.
Definition: framebuffer.hpp:408
void unbind(void)
Disables the shader program.
Definition: shader.hpp:1184
Tucano::Framebuffer * getShadowMap(void)
Returns a pointer to the shadow map with single sampling Note that if multisapling is used (num sampl...
Definition: shadowmap.hpp:97
void blitTo(Framebuffer ©fbo, int source_attach=0, int dest_attach=0)
Copy fbo attachment to another fbo with blit operation.
Definition: framebuffer.hpp:421
A wrapper class for creating and using FBOs.
Definition: framebuffer.hpp:44
virtual Shader * loadShader(string shader_name)
Loads a shader by filename, initializes it, and inserts in shaders list.
Definition: effect.hpp:73
void create(int w, int h, int num_attachs=1, int nsamples=1)
Creates the framebuffer with specified parameters.
Definition: framebuffer.hpp:146
virtual void render(void)
Render the mesh triangles. The method binds the buffers, calls the method to render triangles...
Definition: mesh.hpp:756
bool recreate_fbo
Flag to recreate buffer during next render.
Definition: shadowmap.hpp:63
void clearShadowBuffer(void)
Definition: shadowmap.hpp:86
void unbindAttachments(void)
Unbinds all texture attachments.
Definition: framebuffer.hpp:528
Eigen::Affine3f getModelMatrix(void) const
Returns the model matrix.
Definition: model.hpp:103
void bind(void)
Enables the shader program for usage.
Definition: shader.hpp:1176
void render(Tucano::Mesh &mesh, const Tucano::Camera &camera, const Tucano::Camera &light)
Composes the shadow depth buffer.
Definition: shadowmap.hpp:167
A common Mesh, usually containing triagles or points.
Definition: mesh.hpp:194
Defines an abstract camera with a projection and view matrices.
Definition: camera.hpp:37
void setAttributeLocation(Shader *shader)
Automatically sets the attribute locations for a given Shader.
Definition: mesh.hpp:541
void setNumSamples(int n)
Set the number of samples for multisampling.
Definition: shadowmap.hpp:117
Eigen::Vector4f getViewport(void) const
Returns the viewport coordinates.
Definition: camera.hpp:246
The Effect class is a holder for Shaders. It is completely optional, but is contains a few methods fo...
Definition: effect.hpp:43
Tucano::Framebuffer * getShadowMapMultisample(void)
Returns a pointer to the multisampled shadow map.
Definition: shadowmap.hpp:108
void bindAttachment(int attachment, int texture_unit)
Binds a texture attachment to a given texture unit.
Definition: framebuffer.hpp:510
void unbind(void)
Unbinds this texture and frees the texture unit.
Definition: texture.hpp:367
Tucano::Framebuffer aa_fbo
A auxiliary fbo to blit multisampled fbo.
Definition: shadowmap.hpp:44
void setUniform(GLint location, GLint a, GLint b, GLint c, GLint d)
Sets an uniform integer 4D vector (ivec4) given a location and the vector values. ...
Definition: shader.hpp:1258