Tuesday, October 2, 2007

MD2 Bump mapping viewer

Looking at animated models in the widespread MD2 (Quake 2) format i noticed they generally are very poor of details because of the limited number of polygons supported by this format. So i had the idea to use bump mapping to improve their detail. I wrote a little viewer for MD2 models rendered with a bump mapping effect. I used shaders written in HLSL using the shader model 2.0 for DirectX 9.0c. The only difficulty was on pre-computing tangents. In fact an MD2 animated model stores a vertex list for every key-frame of the animations. So is necessary to compute tangents for every key-frame. In a typical model there are hundreds of key-frames so this operation is very slow if it's done after loading the model. The solution is to pre-compute the tangents and store it in a separate file; in fact the md2 format does not support tangent data in the vertex format.


Features:

  • Per-pixel diffuse and specular lighting model, implemented using shaders
  • Pre-computed mesh normals,binormals,tangents for doing tangent-space per-pixel lighting
  • Uses HLSL pixel and vertex shaders, version 2.0
  • Use of specular per-pixel lighting permits more detail, even on low-poly models
  • Supported OS: MS Windows 2000/XP
  • Uses DirectX 9.0c API

download demo (6.57 MB)

No comments: