Cel Shading

A Graphics Final Project by Nolan Marcy

 

Project Description

For my graphics final project I implemented a Cel Shader, mush like the one done previously as another graphics project.

 

Cel Shading is a method of rendering a model which results in a model that looks very cartoon like, especially if cartoon edges are drawn. This is achieved without the use of OpenGL lighting since it uses the Phong model. Instead, we use a one dimensional texture which contains shading information (from dark to light).

 

The algorithm uses the position for a light source that we define (the light doesn’t actually exist, just the position) and compares the angle between that light source and the normals of the vertices of the model. The angle is then mapped into the shading texture and the shade is applied to the model causing parts of it to appear darker/shaded.

 

The overall result depends greatly on the shading texture as it is what determines what and where to shade. The nice part about the shading texture is that it is very flexible. Typically, these shades are grayscale and go from dark to light. However, imagine that the shades blend from light to dark blue to dark red, then to light red. Now we have what appear to be two lights, one blue and one red, on opposite sides of the model.

 

Program Use

The user is able to zoom/rotate the camera using the left mouse button (Zoom and Rotate are selected from a pop-up menu attached to the right mouse button).

 

Additionally, the following keyboard commands are available:

 

            'l'          toggles user light manipulation mode on and off

            't'          toggles light ray tracing on and off

            'a'         toggles horizontal light animation

            'z'         toggles vertical light animation

            'w'        changes to wireframe mode

            'c'         changes to cel shading mode

            'e'         toggles cartoon edge drawing on and off

            'v'         toggles between orthographic and perspective viewing

            'r'         resets to initial configuration

            'q'         exits the program

 

 

Additional Comments

I wanted to use a mesh other than the gameguy used in the previous cel shading project. This required finding another mesh on the internet – most of which are in .3ds format. Unfortunately, my program can’t load .3ds models so I used a program called Deep Exploration (see links) to open a .3ds file and convert it to a lightwave object file (.obj). The .obj format is very close to the .m format that we use in class. I was able to write a converter that takes in a .obj file and a corresponding .mtl (materials) file (to preserve color information) and convert them to a .m file.

 

The only downside to all this is that most of the models that are available on the internet are very complex and my rendering techniques are quite inefficient (when compared to industry standards). This resulted in spectacularly slow-rendering (but cool looking!) cel shaded models.

 

Links

My email

A very useful cel shading example/tutorial

The Deep Exploration 3d model converter

The obj file format specification

A nice little collection of free 3d Models

The previous graphics cel shading project that I refer to

 

 

Screenshots

 

A Cel Shaded Tie “Invader” with ray tracing enabled.

 

A Cel Shaded Heavy Arms Gundam from the movie Endless Waltz.

 

A Cel Shaded legoman (good thing he doesn’t have to breathe!).