Friday, October 19, 2007

Paths

Jayr have been adding more and more excellent media as well as overhauled the media repository layout. He's been moving source files into an "art" directory, so that the "3d_objects" and "3d_skeletons" directories only contains exported formats. This is great since it means that client developers that only want to get access to the used media, without being burdened with having to download a lot of high res source media only need to check out the two latter directories.

With the new media in Ember it becomes more and more apparent that I really need to spruce up the terrain rendering code. As can be seen in this screenshot the terrain really looks awful in the distance when the LOD kicks in.
This is because it's using vertex shading, where the lightning is set by interpolating the normals of the surrounding vertices. As the number of vertices change with the LOD the lightning becomes messed up. All from the beginning the idea has been that this is a purely temporal solution and it should be replaced with a more robust lightning solution. I've just never had time to implement a better model and thus it's been this way for some time. But with jayr's great looking media it becomes more and more jarring.
I've thus started looking into how to better this. There are a couple of different techniques that can be used, with shaders, normal maps and all. Currently I'm experimenting with just creating a one channel shadow texture from the terrain normals I can get from Mercator (compared to the direction of the sun). This won't take into account occlusion though since no ray checking is done, but hopefully it would look good enough (it would actually look pretty much like normal vertex lightning). We want to update the shadow dynamically as the sun moves over the sky, so we can't use too computing intensive techniques.
With some upscaling and perhaps some gaussian blur I think the result will be good enough.

Another pet peeve of mine that's been bugging me for some time was a bug with the foliage code where it didn't take into account "negative" ares, such as the path and the sty, where there should be no foliage. The result was that foliage was added everywhere, even in places where there should be no grass growing. I've been trying to fix it for a while but couldn't find what was wrong. I finally tracked down the problem to a en error in what lookup container for terrain surfaces was used. So now we finally have clear paths! This together with the work I'm doing on nicer terrain shadows should allow for some much nicer visuals in the near future.
Post a Comment