120 noise_texture.
setTexParameters( GL_REPEAT, GL_REPEAT, GL_NEAREST, GL_NEAREST );
142 deferred_shader.
bind();
174 ssao_shader.
setUniform(
"global_scale", global_scale);
175 ssao_shader.
setUniform(
"intensity", (GLfloat)intensity);
193 ssao_final_shader.
bind();
201 ssao_final_shader.
setUniform(
"blurRange", blurRange);
206 ssao_final_shader.
unbind();
225 Eigen::Vector4f viewport = camera_trackball.
getViewport();
228 glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
233 fbo.
create(viewport_size[0], viewport_size[1], 5);
236 glEnable(GL_DEPTH_TEST);
237 glClearColor(1.0, 1.0, 1.0, 0.0);
238 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
293 global_scale = value;
322 loadShader(deferred_shader,
"viewspacebuffer");
void createQuad(void)
Sets the mesh as Unit Quad.
Definition: mesh.hpp:841
virtual void initialize(void)
Initializes the SSAO effects,.
Definition: ssao.hpp:114
int getHeight(void)
Returns the height of the FBO.
Definition: framebuffer.hpp:893
Tucano::Framebuffer fbo
Framebuffer to store coord/normal buffer.
Definition: ssao.hpp:52
void getViewMatrix(GLdouble *matrix)
Return the modelview matrix as a GLdouble array.
Definition: camera.hpp:126
int getRadius(void)
Get radius value.
Definition: ssao.hpp:272
virtual void render(Tucano::Mesh &mesh, const Tucano::Camera &camera_trackball, const Tucano::Camera &light_trackball)
Renders the mesh with the desired effect.
Definition: ssao.hpp:223
void getProjectionMatrix(GLdouble *matrix)
Return the projection matrix as a GLdouble array.
Definition: camera.hpp:142
Definition: bufferobject.hpp:34
void clearDepth(void)
Clears the FBO depthbuffer.
Definition: framebuffer.hpp:493
bool apply_blur
Flag indicating wether blur shall be applied or not.
Definition: ssao.hpp:67
static bool loadPPMImage(string filename, Tucano::Texture *tex) __attribute__((unused))
Loads a texture from a PPM file. The texture receives data in the range [0,1] to create a FLOAT textu...
Definition: ppmIO.hpp:46
void clearAttachments(Eigen::Vector4f clear_color=Eigen::Vector4f::Zero())
Clears all attachments with a given color.
Definition: framebuffer.hpp:448
int intensity
Global intensity value.
Definition: ssao.hpp:91
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
Tucano::Shader ssao_final_shader
Join original render with SSAO (blur it first)
Definition: ssao.hpp:61
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
Tucano::Mesh quad
A quad mesh for framebuffer rendering.
Definition: ssao.hpp:64
A Shader object represents one GLSL program.
Definition: shader.hpp:45
void toggleAmbientPass(void)
Toggles the displayAmbientPass flag.
Definition: ssao.hpp:308
Tucano::Shader ssao_shader
The per pixel AO computation shader.
Definition: ssao.hpp:55
void errorCheckFunc(std::string file, int line, std::string message="")
GL error check method.
Definition: misc.hpp:53
virtual void bindRenderBuffer(GLuint attachID)
Bind framebuffer object and set render buffer to given attachment.
Definition: framebuffer.hpp:258
Tucano::Texture noise_texture
Noise texture.
Definition: ssao.hpp:46
int getIntensity(void)
Get intensity value.
Definition: ssao.hpp:254
bool displayAmbientPass
Flag indicating if the mesh should be rendered only with ambient occlusion pass or with full illumina...
Definition: ssao.hpp:70
bool hasAttribute(const string &name) const
Returns wether an attribute exists or not.
Definition: mesh.hpp:503
void setScale(int value)
Set global scale value.
Definition: ssao.hpp:291
virtual void bindRenderBuffers(GLuint attachID0, GLuint attachID1)
Bind framebuffer object and set render buffer to 2 given attachments.
Definition: framebuffer.hpp:269
void setIntensity(int value)
Set intensity value.
Definition: ssao.hpp:263
void unbind(void)
Unbinds fbo and all texture units in use.
Definition: framebuffer.hpp:408
int ssaoTextureID
The ID of the color attachment holding the SSAO result.
Definition: ssao.hpp:85
int blurRange
Number of neighbour pixels used in blurring. The blur will be applied to a blurRange x blurRange squa...
Definition: ssao.hpp:73
SSAO(float rad=1.0)
Default constructor.
Definition: ssao.hpp:104
void unbind(void)
Disables the shader program.
Definition: shader.hpp:1184
int normalTextureID
The ID defining the color attachment to which the normal texture is bound in the framebuffer.
Definition: ssao.hpp:79
int colorTextureID
The ID defining the color attachment to which the color texture is bound in the framebuffer.
Definition: ssao.hpp:82
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
void computeSSAO(const Tucano::Camera &camera)
Compute the Ambient Occlusion factor for each pixel.
Definition: ssao.hpp:161
void setBlurRange(int value)
Definition: ssao.hpp:300
virtual void render(void)
Render the mesh triangles. The method binds the buffers, calls the method to render triangles...
Definition: mesh.hpp:756
Eigen::Affine3f getModelMatrix(void) const
Returns the model matrix.
Definition: model.hpp:103
An OpenGL texture. It can be a simple texture or an FBO texture.
Definition: texture.hpp:41
int getWidth(void)
Returns the width of the FBO.
Definition: framebuffer.hpp:884
void bind(void)
Enables the shader program for usage.
Definition: shader.hpp:1176
void setRadius(int value)
Set radius value.
Definition: ssao.hpp:282
void applySSAO(const Tucano::Camera &light_trackball)
Blur SSAO result and mix with original render.
Definition: ssao.hpp:191
Tucano::Shader deferred_shader
Save coord, normal and color to FBO.
Definition: ssao.hpp:58
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
int depthTextureID
The ID defining the color attachment to which the depth texture is bound in the framebuffer.
Definition: ssao.hpp:76
Eigen::Vector4f getViewport(void) const
Returns the viewport coordinates.
Definition: camera.hpp:246
int blurTextureID
The ID defining the color attachment to which the blur texture is bound in the framebuffer.
Definition: ssao.hpp:88
void createViewSpaceBuffer(Tucano::Mesh &mesh, const Tucano::Camera &camera_trackball, const Tucano::Camera &light_trackball)
First pass of the SSAO, writes coords, normals and colors to a buffer.
Definition: ssao.hpp:135
The Effect class is a holder for Shaders. It is completely optional, but is contains a few methods fo...
Definition: effect.hpp:43
Eigen::Vector2i getViewportSize(void) const
Returns the dimensions of the viewport.
Definition: camera.hpp:256
void initializeShaders(void)
Creates and loads all shaders.
Definition: ssao.hpp:319
float global_scale
Global scale.
Definition: ssao.hpp:94
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
float radius
Kernel radius. If the distance between a sample point and the point for which the occlusion is being ...
Definition: ssao.hpp:49
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