Beginning bumpmapping

I’ve been busy for the past month, trying to fit in the time to create a bumpmapper. Mine is heavily based on ATi’s Normalmapper from their Tools page in 2002. Here are some of the results from it, with my very simple box model that has a low-polygon, 12-triangle mesh and a high-polygon, 30,000 triangle mesh.

This is a baseline test, a slightly scaled up box was used:

ATi's Normalmapper, baseline

The next two are the first attempt at a high-resolution model that’s just a face on the front side:

ATi's Normalmapper, border expanded ATi's Normalmapper, without boarder expansion

As can be seen, there are a few “holes” in the non-expanded version. I suspect it’s due to a more lax threshold when considering an intersection between the base and the detail mesh.

My first attempt, the face at least started to appear, though it wasn’t mapped correctly at all:

After fixing the texture coordinate issues, I started to get something that began to resemble what I was expecting, using the albedo texture as a reference:

I almost had the tangent space worked out with the next attempt:

I decided to just focus on the first triangle to make sure that the normals were orientated correctly:

The time it was taking to do the whole cube reached 45 minutes, so I attempted to fix that by ignoring the intersection points, leading to this:

It didn’t help by much, in the end I was able to get the time down to around 8 minutes by allocating data and copying from the STL structures before processing.

With the speed increase, I figured out that the type I was using for the indices was an unsigned 16-bit integer, which is of course good up to 65,536 indices total. I changed it to an unsigned 32-bit integer and the sides appeared:

Very close to fixed, there were still a few incorrect pixels, though:

I decided to see where the holes were, so I set the default value to <-1, -1, -1> for the normals:

I took the epsilon value down to loosen the tolerance when considering a ray as having hit. The black pixels are present as I wanted to see if there were any holes:

The final, filled-in normal map, though it’s not what appears in the output from the console as I attempted to draw a face on all sides of the cube:

Final normal map

The scene as it is in Anvil:

The scene in Anvil

Final rendered output from the console, without the albedo texture:

Final output, without albedo

Final rendered output from the console, with the albedo texture:

Final output, with albedo

I’m pleased with the result so far. It’s not perfect, but there’s time to improve it. The plan is to use this for scenery, not so much characters. Though, I’ll try and use it for characters if possible. There are more blending tasks I want to look into, such as specular maps. At the moment, I’m not sure where I’m going to go from here. There’s so much more to be done and I still have the scripting system that’s half-baked as well as the code and data integrity checking. Not to mention the audio system.