MegaTextures & Terrain Generation


This was my independent study project for Computer Graphics 2. The main goal was to implement the MegaTexturing technique developed by id Software. Also included were the secondary goals of terrain generation, and automatic normal generation. You can find the final report here, which summarizes the project.

My first goal was to find a container that would allow me to stream any portion of the texture data on the fly. I ended up using DTX5, which is a lossy image compression format, commonly used in games today. It cuts the size to about 1/4 and allowed me to decompress any portion in a logical way.

After being able to recompress the image, I researched ways to convert 2D images into normal maps. I ended up grey scaling the image then processing it through the Sobel Operator, a matrix filter that detects hard edges. I then ran the image through a mean-smoothing filter to soften the edges from the Sobel image. Through these techniques I was able to create an acceptable normal map for the image.

With everything else completed, for the Megatexturing I simply created a tesselated square which I sliced into thirds and resampled the image based off of the location and desired resolution. Once that was done I used the Diamond-Square algorithim to add terrain to the otherwise flat image.


  • MegaTexturing
  • DXT5 Image Compression
  • Automatic Normal Generation
  • Diamond-Square Terrain Generation