EECS 466 Project |
| For the past several years, a co-worker and I have been making modifications to the Quake 2 engine made by John Carmack. Quake2max, which was written by Psychospaz, includes several key improvements over the Quake 2 engine. These updates include simple shadow effects, alpha mapping, A-Buffering, 3rd Person Camera, stain maps on the world, and an improved particle effect system. From this base my co-worker and I have made several key improvements over Quake2max. Firstly, we changed the animation system from a vertex-based animation system to a bone-based animation system. This change allows us to apply any animation to any model using the same skeleton. Next we improved the shadow system of Quake2max. The Q2Max shadow system took each body part and had it make a shadow; the problem is that the shadow of body parts can and often did overlap, making the areas around the joints darker than the rest of the shadow. We improved the shadow by making stencil shadows, so that the shadow and everything in the outline have the same level of shading. Another feature we added was lighting on models. Before hand, Quake 2 only had ambient lighting on models; we updated it to gouraud lighting on models based on the models normal. Also, more accurate hit detection was added using Tomas Möller’s fast triangle-triangle intersection algorithm. Major improvements to the guard AI have also been added to include improved monster pathing and the addition of several states to the monster’s state based AI system. |
Quake 2 Screenshots |
|
Quake2Max Screenshots |
|
Stealth Tactics Screenshots |
|
Bump Mapping |
| My first project idea was to add bump mapping to the engine. Bump mapping is a technique in which creates the illusion of a three dimensional surface on a two dimensional surface. The advantage to bump mapping is that it allows you to create more detailed models and surfaces without increasing the polygon count. The trick is modifying the light vector reflection to create this 3D look. To do this, you take the dot product of the light vector at that point and a bump parameter. The bump parameter can be gotten in one of three different ways; Emboss Bump Mapping, Dot3 Bump Mapping, and Environment Mapped Bump Mapping. Emboss Bump Mapping is a technique in which the texture is shifted in the direction of the light to get the bump parameter. This technique is generally considered slow and is known to have artifacts in larger textures. Environment Mapped Bump Mapping is currently being developed by ATI for use on their cards. This technique is where an environment map is used to determine the bump parameter. Dot3 Bump Mapping is where a height-map texture is used to determine to bump parameter. This technique is probably the fastest and is known for being used in game engines. I decided to attempt Dot3 Bumping Mapping in my game project. Using ATI’s and Nvidia’s website I created a small demo program of Bump Mapping. This involved using two textures and blending them together. The first is the unmodified texture and the second is the bump parameter textured and the light vectors dotted together using the glMultiTex function. These operations can be done in hardware using the glEnvi command. Next I needed to decide whether to apply it to world structures or models since these are both handled differently by the engine. Unfortunately, after hours of trying I discovered I was unable to add the feature to either component without major engine rewrites. World geometry lighting is done using Radiosity before the level is loaded by a program called Arghrad. This will create a light map which is loaded into the engine uses to render the level. To create bump mapping for the environment I need to modify Arghrad which is currently not open source. I contacted the programmer but he has yet to respond. Bump Mapping on models is next to impossible due to the order in which operations are calculated. Currently, the texture information is created before the model is rotated and translated. This means that I have no way of knowing the lighting until after I apply the texture. Since bump mapping is a texturing technique, the lighting needs to go before the texturing. Unforuneately, Quake 2 has several rotation and translationoff errors which are handled within the rendering of the model. Attempting to correct these bugs causes several more glaring errors such as strange model rotations and the shadow being off. |
Texture
Height Map
Together This picture is as far as I got with the implementation of Bump Mapping in the engine. The gray scale image of the door and character model were created by taking the dot product of the texture and the height map.
|
Bleed |
| My next project idea was to add a system in which I could apply stain maps to models. More specifically, I wanted to make it so if I hit a model with a weapon he would bleed. To do this, I used multi-texturing to create a second texture. If the second texture initially has an alpha of 100%. Next using our poly-poly collision routine, I can determine which polygons are hit on a weapon impact. A damage function is applied to the polygons are hit which reduces the alpha for that polygon. A linear falloff is applied to neighboring polygons to create a bleeding effect on those polygons. The next step is to make sure that the effect of one bleed will not be applied to multiple models. In most games, there are generally several copies of the same model rendered in multiple places. This is because most monsters in games look exactly the same and by having one render copy saves memory. With the new system, it makes every model unique. So a system needed to be created to keep track of every model and all of the bleed effects. |
|
Fog |
| Lastly, I added the coordinate fog system into the engine. Fog is an exact in which the color of the screen is modified. There are three methods of calculating the effect of fog; linear (end – z)/(end – start), exponential e^-(density*z), and exponential squared e^-(density*z)^2. Using standard OpenGL fog, the z is the distance from the camera while the other are passed to it. I started by adding regular fog into the engine. While this was easier to add, there was an artifact in the fog. Some polygon edges showed clearly through the fog. The first fog picture below will illustrate the artefact. Using Coordinate fog, the z value can be passed to OpenGL as well. While this isn’t ground breaking, it does assist with the mood of the game. With the rain and the lightning particle effects, a outdoor scene can be created. |
GL Fog Artifact
Coordinate Fog
|
Random |
| This last section contains several small changes to enchance visual effects on the engine. The first includes a "fix" to gouraud shading on the door models. The door brush model is the worst case scenario for gouraud shading. The corners of the door will be lighted diffrently than the rest of the model. This effect can be seen in the first bleed picture above. This solution does not rely on expensive calculations of phong shading, instead the door is broken into six parts, each part is is thought of as a seperate model but each part belongs to the door. This forces to normal at each corner to match the normal of the rest of the normals for eah face of the door. Also a sky map was added to create the illusion of a more detailed city. |
Sky Map d
Gouraud Shaded Door
|