Ok, so I'm putting CLOD on hold for a bit, I'm not looking forward to be honest given I've pretty much forgotten everything to do with geometry. So instead I implemented light mapping. Light mapping is just darkening pixels on the terrain so it looks like a light is casting shadows. The simplest and most visually attractive technique in my opinion is slope lighting. Following a line of pixels in a direction from where the light source should be (in this case I chose south (which is x = 0, z = -1)), make the current pixel darker than the previous by a factor of how much higher the previous height is. If the previous pixel is lower than the current pixel, don't darken it.
shade = 1.0f - ((heightMap[x - xLightDir, z - zLightDir] - heightMap[x, z]) / softness);
As always you can play about with parameters to make the light come from a different direction, or to create a more severe (darker) shadow. Here's how the effect looks in practice on my engine (before and after):
It's not proper shadowing but I like the effect. I think it could be extended to stretch the shadows - for example a low sun would create long shadows, so you probably could choose a direction as above with a shadow range of 10 (something like x = 0, z = -10). However sections of the edges would look a bit out of place because they don't have 10 pixels before them.
For a realistic Irish effect you don't need shadows at all because there's no direct light source, just make sure to turn the colour of your ambient light to dark grey.
No comments:
Post a Comment