This demo is a simplified bump map renderer. A full-featured bump mapping needs to have a coordinate system aligned with the surface, consisting of normal, tangent and bitangent (no, that should not read binormal - that applies to curves, not surfaces), where the tangent and bitangent should be aligned with the texture coordinates.
Here, I make a rough simplification instead. I don't care about aligning the tangent and bitangent with the texture coordinates, I just grab any tangent vectors at all that form a complete coordinate system.
Yes, this is cheating. For many bump maps, it is completely wrong, bumps will go inwards and outwards randomly. However, if all I need is a surface with some random bumps, it works just great. So for noise, this works just fine, while for structures with some meaning, it won't.
Updated 2017, Linux Mint. Updated 2022. C++ 2024.
Old version: