C#: Normal Map Generator

<- Return to Programming blog

For a recent university assignment, I needed to create many different textures for both 3D models and surfaces. I wanted to create normal maps for each of these but I didn't know how to do it.

I decided therefore to experiment with different approaches including photographing a surface with light from different sides and by using filters in GIMP and Photoshop. Both techniques worked well and I realised that I could create a program to speed up the process.

This program is the result of this work. It is currently unfinished (I just need to add a progress bar and other UI elements) but the core works correctly. It uses Sobel convolution kernels to generate the specific colour channels of the normal map. The horizontal kernel is used for normal X offsets (R channel), the vertical kernel for normal Y offsets (G channel) and a combination of the two (creating a Sobel edge-detected image) to create the depth (B) channel. The result is then box blurred (using a 3x3 kernel) to smooth the result.

Source code (Visual C# solution): - Normal_map_generator.zip