Friday, December 21, 2007

Progression on the project

A number of areas have progressed with the project so I thought it was about time I updated my blog.

Firstly the most noticeable update is on the graphics front. Here's a screenshot of the current build:


1) 3-D textures
The terrain is now textured with a 3-D texture. 3-D textures are basically stacks of standard 2-D textures which allows you to gently blend between different layers. In the case of the terrain, there are 6 different layers ranging from sand to dirt, to grass, to smoother grass, to rougher grass and eventually to a snow type texture. In the case of the terrain, the height at each point dictates which texture layer should be used. This means that low areas near the water have a sandy beach effect whilst high areas blend into snow capped mountains.

I noticed that originally the terrain looked very artificial because the layers were very clear, so I randomly offset the layer on each point of the terrain to add extra variation. This isn't the best solution, but it certainly gives an overall more natural feel. I may create a separate blend map layer to allow for extra terrain features such as roads.

2) Shaders
I have implemented a system to use the OpenGL shader language (GLSL) to create some shader effects. Currently this supports per-pixel diffuse lighting on the terrain and models. I want to extend this for more complex materials, bump mapping and special effects.

3) OBJ Model loading
I have chosen to use the OBJ format for model loading as nearly every 3-D modelling program supports it and its a relatively easy format to import. The model loader will read position, normal and texture coordinate data, and will generate normal data if none is available. It also generates edge data for use in shadow volumes (see below)

4) Shadows
I have opted to use a shadow volume technique for generating shadows. Basically for each object a volume is created to represent the space which is occluded from the light source. The area where this volume intersects with surrounding geometry is where it is in shadow. I'm not quite happy with my current implementation as there are a few graphical glitches. Also the lighting model is not quite finished which is why the shadows are completely blacked out. I'll post more on the topic when the lighting model is in place.

5) Object instancing
I have written a dynamically sized object container which allows for speedy random access. It is basically a tree structure which increases in size as you add more objects. Each object is given an ID value which means searching for it is just a matter of traversing the correct nodes on the tree. This is a big plus as it means when it comes to implementing multiplayer, objects can be referenced by ID during communication.

6) Picking
I have implemented a system to decipher which object in the scene the mouse pointer is hovering over which will be very useful for the overall input system. All objects are redrawn in the scene in 'select' mode with each object assigned an ID value. The same system should allow the user to click and drag a rectangular area to select multiple objects.

Thats about it for now. Here are some of the next things I want to be working on:
- Lighting model (ambient occlusion, directional light source, correct shadowing)
- Selecting objects
+- Object messaging infrastructure (issuing commands)
+- Movement and pathfinding
- Animation
- Occlusion culling