Post Effect

struct glen::PostEffect

Abstract post effect struct for doing 2D effects

Subclassed by Bloom, Deferred, ToneMap

Public Functions

PostEffect()

Constructor.

void draw()

Render the effect to screen.

Mesh *mesh()

Return

The window quad mesh used to render the effect.

Bloom

struct glen::Bloom : public PostEffect

Create glow in bright areas.

Public Functions

Bloom(const glm::uvec2 &dimensions, ToneMap *tone_map)
void draw() override

Render the effect to screen.

Tone Map

struct glen::ToneMap : public PostEffect

Tonemap HDR image.

Used to render information that would usually be outside the usual 0 to 1 range.

Public Functions

ToneMap(Framebuffer *backbuffer, const glm::uvec2 &dimensions)

Constructor.

Parameters
  • backbuffer: Simple Framebuffer object (e.g. `Framebuffer{ GL_FRAMEBUFFER }).

  • dimensions: The dimensions of the window.

void draw() override

Render the effect to screen.

Texture *beauty()

Return

A texture containing the final beauty render.

Texture *bright()

A texture containing the un-tonemapped image.

Deferred

struct glen::Deferred : public PostEffect

Struct for adding a deferred render stage to the primary renderer.

The deferred stage allows images to be rendered based on pre-passes containing data (e.g. normals, position etc.) intead of image output. This way the final render stage just needs to make calculations based off pixel data instead of 3D geometry.

Subclassed by AO_BlurDeferred, AO_GBufferDeferred, BlinnDeferred

Public Functions

Deferred(const GLenum target, Framebuffer *g_buffer, Material *material, const glm::uvec2 &dimensions)

Constructor.

Parameters
  • target: The GL target to use (e.g. GL_TEXTURE_2D).

  • g_buffer: The Framebuffer object to use.

  • material: The Material to use. Should be specific G-Buffer material (AO_GBufferMaterial for example).

  • dimensions: The dimensions of the window.

Deferred(const Deferred &other) = delete

Use move constructor instead of copy constructor.

Deferred(Deferred &&other) noexcept

Move constructor.

Deferred &operator=(const Deferred &other) = delete

Use move assign instead of copy assign.

Deferred &operator=(Deferred &&other) noexcept

Move assign.

~Deferred() = default
void bind()

Ensure the Framebuffer associated with this object is ‘active’ in relation to OpenGL.

void unbind()

Unbind the Framebuffer.

void update_view(const CameraNode *camera_node)

Update the Material associated with this object with the provided camera_node information.

void draw() override

Render to the screen.

glm::uvec2 dimensions()

Return

Internal dimensions.

Framebuffer *framebuffer()

Return

The framebuffer object.

Material *material()

Return

The G-Buffer material.

MeshNode *mesh_node()

Return

The rectangle screen mesh.

Texture *texture(const GLuint g_buffer_loc)

Return

The internal g-buffer texture at index g_buffer_loc

const Texture *depth_texture()

Return

The internal depth texture

void set_target(const GLenum target)

Set the GL target (e.g. GL_TEXTURE_2D).

void set_dimensions(const glm::uvec2 &dimensions)

Set the screen dimensions to be used.

void set_color_texture(const GLuint g_buffer_loc, Texture *texture)

Set a color g-buffer texture at index g_buffer_loc

void set_color_texture(const GLuint g_buffer_loc, Texture texture)

Set a color g-buffer texture at index g_buffer_loc and also store it in this object.

void set_depth_texture(Texture *texture)

Set the internal depth texture.

void set_depth_texture(Texture texture)

Set the internal depth texture and also store it in this object.

void send_color_textures_to_framebuffer()

Pass all color textures to the associated Framebuffer

Blinn Deferred

struct glen::BlinnDeferred : public Deferred

Used to render a blinn shader in deferred mode.

Public Functions

BlinnDeferred(const GLenum target, Framebuffer *g_buffer, const glm::uvec2 &dimensions)

Constructor.

Parameters
  • target: GL target (e.g. GL_TEXTURE_2D).

  • g_buffer: Simple Framebuffer object (e.g. Framebuffer{ GL_FRAMEBUFFER }).

  • dimensions: The dimensions of the window.

AO G-Buffer Deferred

struct glen::AO_GBufferDeferred : public Deferred

Used to render ambient occlusion.

Public Functions

AO_GBufferDeferred(const GLenum target, Framebuffer *g_buffer, const glm::uvec2 &dimensions)

Constructor.

Parameters
  • target: GL target (e.g. GL_TEXTURE_2D)

  • g_buffer: Simple Frmabuffer object (e.g. Framebuffer{ GL_FRAMEBUFFER })

  • dimensions: The dimensions of the window.

AO Blur Deferred

struct glen::AO_BlurDeferred : public Deferred

Used to render the second step in screen space ambient occlusion. The initial stage produces an image which is very grainy. This stage blurs the graininess to make the result look smoother on screen.

Public Functions

AO_BlurDeferred(const GLenum target, Framebuffer *g_buffer, const glm::uvec2 &dimensions)

Constructor.

Parameters
  • target: GL target (e.g. GL_TEXTURE_2D)

  • g_buffer: Simple Frmabuffer object (e.g. Framebuffer{ GL_FRAMEBUFFER })

  • dimensions: The dimensions of the window.