Original Post
I have been looking for a quick / simple way to compute bent normals and Ambient Occlusion style information for heightmaps. Having not found anything I came up with something which does a decent job and is decently quick [8^) Quick Overview: * computes bent normals for a heightmap * computes an occlusion term and scales the bent normals (so a fully occluded vertex would have a bent normal length of 0.0, while a fully un-occluded vertex would have a bent normal of length 1.0) * time is O(pixels * LOD), so a 512x512 takes ~4x longer than a 256x256 (given a fixed LOD, I'm recommending LOD=8) Here is the zip with full source and a demo. Press the up/down arrows to cycle through LOD levels (hint: the effect is most apparent as you go from LOD=0 upward). The demo will generate a random terrain when you run it. Alternatively drag an image onto the exe and it will be loaded as a terrain heightmap. Check the readme.txt for key bindings, implementation notes, etc. All my code in there is under MIT license, except SOIL which is public domain. Before
After
Note, the effect may be subtle or hard to spot in the above pics, so feel free to watch it in action. Comments welcome! [Edited by - lonesock on October 21, 2007 2:06:37 AM]
After
Note, the effect may be subtle or hard to spot in the above pics, so feel free to watch it in action. Comments welcome! [Edited by - lonesock on October 21, 2007 2:06:37 AM]