GLSL

This project involved writing a set of custom shaders different from OpenGL’s fixed-functionality pipeline. GLSL was used to write a shader that outlined models, giving scenes a cartoon-like, almost cell-shaded appearance. The outlines were generated by comparing neighboring depth and normal values at each fragment. If the depth or normal differences were greater than a specific threshold, an outline was drawn instead of the normal fragment color.

To generate the desired effect, the scene was rendered twice per frame using the OpenGL fixed-functionality pipeline. The first pass uses a framebuffer object to store the fragment normals into a texture. The second pass then uses the same framebuffer object to store the depth and color buffers into two additional textures. All three textures are then passed to the outline shader which compares the differences in depths and normals per fragment.

These three images respectively show the color texture, normal texture, and depth texture for a scene of spheres.

 

Using the normal and depth textures the outline below is generated, and combined with the color texture to create the outlined scene.

 

 

For the plane model, the same three textures are generated.

 

Again, an outline is created and combined with the color texture to create an outline for the plane model.

 

 

Finally, the same algorithm works on textured scenes, giving a very neat effect after the outline is applied.

 

As a side note, the corner between walls does not have an outline because the normals (as shown in the normal texture above) are equal. However, there is an outline between the walls and the floor.