OpenGL 3D Renderer

A simple 3D graphics renderer which showcases a number of graphics techniques and features, including:

  • Forward Rendering

  • Deferred Rendering/Lighting

  • Tessellation

Forward Rendering

Loads in an OBJ model and performs lighting calculations using the forward rendering path.

5 point lights positioned at each candle, and the cauldron in the center, to give the environment more ambiance

Wireframe mode can be toggled on and off, which helps showcase tessellation.

Tessellation is performed based on camera distance. The camera’s position is provided to the tessellation control shader, where it is then tested against the vertices’ positions. The tessellation level is then turned up or down, depending on how far the camera is.

opengl_gif.gif
deferred composite.png

Deferred Rendering

Deferred rendering is a multi-render pass technique which uses a set of render targets called a G-Buffer, and delays lighting calculations until the final image has been rendered.

We create an offscreen framebuffer object with multiple color attachments and a depth attachment for the G-buffer. In the first pass, we render the scene without any lighting and store the object’s vertex positions, normals, and albedo texture in different attachments.

Now that we know what the final scene looks like, with all of the geometry now in place, we can do our lighting calculations in a second pass on the finalized scene. This prevents us from doing any extra calculations on parts of the scene that may otherwise be covered by different geometry. This is also helpful for areas with lots of geometry, as performing lighting calculations are expensive on performance, so we minimize what we decide to do lighting on.

Previous
Previous

Snowball Showdown