McGill University
Computer Science Dept.

TechnicalQuake

A Project for COMP-767 - Non-Photorealistic Rendering

Michael Batchelder and Kacper Wysocki
Winter 2005

Final Presentation


Rebuilding edge information

After many hours of hard work building a complex data structure with information regarding the neighbouring surfaces of edges in the models, we discovered that the information was virtually useless. The models in Quake often contain degenerate triangles, edges with only on surface, and triangles with their three vertices speficied as the same point. Because of this our neighbouring information is garbage and we could not use it as we had hoped. The (tiny amount of) good news in all of this is that we no longer loose the 5 to 8 frames per second in performance since we no longer build the edge table.


Take home message: Quake's Models are Garbage!

Time Demo demo1 demo2 demo3 bigass1
Edge 78.283.272.471.0
No edge 98.796.390.987.5

The results were obtained in 800x600 window mode NPRQuake, on a Pentium 4 2.66GHz with 512MB RAM and a GeForce4 Ti 420, running gentoo GNU/Linux.

Gooch Shading

We implemented Gooch shading on the models, which linearly interpolates between a cool (receding) and warm (advancing) color based on the light direction and the surface normals, according to the equation:

I=((1+l.n)/2)*kcool + (1-(1+l.n)/2)*kwarm
This reserves high and low luminance ranges for silhouettes and creases, thereby increasing shape comprehension.

cool-to-warm
This image illustrates the cool-to-warm tonal transition that keeps luminance constant.

transition
Here we can clearly see that depth and shape cues are conveyed nicely from the shading.

cool-to-warmer
The shape cues are retained in different lighting conditions.

Splashback

Splashback is an adaptation of the cool-to-warm Gooch shading that simulates the more dramatic effects sometimes used by artists. The effect is acheived when the reflected light from the left of the object produces a back-splash of light opposite the direct lighting source. We acheive this effect simply by adding the following multiplier to the Gooch shading color equation:

(alpha*abs(cos(theta))+(1-alpha))^p

splasH! Back!
whip lash back splash
We see that the model shading appears more dramatic than in the earlier examples.

Silhouettes and creases - nice try

Silhouettes and creases are where we had the most problems. As mentioned above, we were unable to properly compute neighbouring information and we were also never able to find a proper camera vector. Every possible idea was exhausted in trying to find the eye position yet none proved fruitful. The point (0,0,0) was translated from world coordinates to model coordinates using the inverse MODELVIEW matrix from OpenGL to no avail. Vertices in the model were translated to world coordinates and we attempted to draw a line from them to the camera yet the result was diverging lines, not converging lines. In short, we were unable to properly compute silhouettes and creases in the manner in which we desired.

silsncreasesrbad
How a good idea can go wrong.

Compromise

Silhouettes

We implemented a silhouette algorithm that simply drew back-facing polygons with thick lines of the desired silhouette color. This is an improvement on the approach found in literature [1][2] where back-facing triangles are extended with GL_QUADS of a certain thickness because we do not have to draw an extra polygon consisting of 4 extra vertices for every polygon edge in the list of back-facing surfaces. These results are very good.

decent silhouettes
Silhouettes(black) are drawn here with a thickness of 4.

Creases

We implemented creases - all creases - by just drawing them for every edge. This is not particularly interesting, nor does it look very good so we made some observations about the idea of technical illustrations - especially within the realm of Quake:

Creases don't work when far away
Creases Far Away.

Having made these observations we implemented a two-pronged approach:

  1. shade creases the same color as the underlying model but with an added amount of white value, and
  2. fade this crease color into the underlying model color the farther away from the model the viewer gets.
This gave much more pleasing results that can be easily modified with user parameters to specify the white level to add and the distance at which the crease completely fade away. This same approach can be taken with silhouettes, which can also be jarring from long distances.

Creases that fade with distance
Creases That Fade with Distance.

Shadows

We draw soft drop shadows from the models by extending the very simple approach of projecting the model polygons onto a plane roughly at ground level. Our extension, aiming to implement the 'soft' shadows described in [1], involves three of these scaled model projections slightly offset from each other.

The lame shadows already in quake.
Simple shadows already implemented in NPRQuake.

The really cool shadows we came up with.
Our soft drop shadows with a hard umbra and a hard penumbra.

Long attached drop shadows.
Shadows help imply shape that is not visible.

Can you see the pole?
We can clearly see the pole in hand just by looking at the shadow.

Can you see the hand?
The entire left side of the monster model is implied by its shadow.

large offset for dramatic effect.
The user-configurable offset is set large here.

playing with alpha is fun
A large alpha value here.

playing with offset is fun
A large offset value looks like two lights are casting shadow here.

playing with offset is fun
A large scale value creates this gloomy, dramatic effect.

First, two projections are drawn, one offset in the positive y direction, and the other offset in the negative y direction, with an alpha value that is a fraction of the set shadow alpha value, roughly approximating a hard penumbra. If the offset is large, the model looks like it has shadows from two separate light sources. Then, the umbra is drawn in the full alpha value, scaled down so that it is smaller than the 'penumbra' shadows. Each projection is drawn with a slightly different depth so as to reduce flicker, as opengl becomes confused when several polygons with alpha values are drawn on top of each other at the same depth.
The shadow alpha and color are configurable parameters, as is the scale factor of the shadow and the offset for the penumbra projections.

The approach is not exactly accurate, and will result in shadows that look rather unnatural in some circumstances: the shadows will 'float', for example when the model is on a step and the shadow is cast off the step, and the shadows will disappear into a wall instead of being cast onto the wall. However, we feel that the approach yeilds fairly realistic-looking soft shadows.

User Definable Parameters

To facilitate the exploration of various technical effects such as fading creases, cool-to-warm shading, and silhouette width, we added many user definable parameters to the system that change the look and feel of the 3D rendering system in realtime.



Project References:

[1] Bruce Gooch, Peter-Pike J. Sloan, Amy Gooch, Peter Shirley and Richard Riesenfeld. Interactive Technical Illustration. Symp on Interactive 3D Graphics, 1999

[2] Ramesh Raskar. Hardware Support for Non-photorealistic Rendering. In Graphics Hardware, 2001

[3] Amy Gooch and Bruce Gooch and Peter Shirley and Elaine Cohen. A Non-photorealistic Lighting Model for Automatic Technical Illustration. ACM Siggraph '98 Conference Proceedings, 1998

[4] Alex Mohr, Erik Bakke, Andrew Gardner, Christopher Hennman, and Steve Dutcher. NPRQuake at http://www.cs.wisc.edu/graphics/Gallery/NPRQuake/whoWeAre.html

[5] ID Software. Quake 1 Source Code. At http://www.idsoftware.com/business/techdownloads/

[6] Adrian Ilie. COMP 238 Final Project: Non-Photorealistic Rendering Techniques for a Game Engine. At http://www.cs.unc.edu/~adyilie/comp238/Final/Final.htm

[7] Adam Lake, Carl Marshall, Mark Harris, and Marc Blackstein. Stylized rendering techniques for scalable real-time 3d animation. Proceedings of NPAR 2000, 13--20

[8] Olivier Montanuy. Unofficial Quake Specifications version 3.3 at http://www.gamers.org/dEngine/quake/spec/quake-spec33/qkmenu.htm. 1995, 1996


COMP-767 - Advanced Topics in Graphics: Non-Photorealistic Rendering