Adding light to the terrain

I wanted to add lighting to the terrain engine, but I did not want to use OpenGL’s implementation, instead I wanted to create my own. So I added a light map to the terrain data, and set the program to modify the pixels when creating the textures. Then I added a very simple algorithm to fill it with some interesting data; I just use the height map so that hight pixels will be bright, and low pixels will be dark. The result is better than I hoped for:

With light

With light

Even with this very simple light scheme, the terrain looks a lot better šŸ™‚ It looks even better when moving the camera around. This was a lot easier to add than I expected. Here is another angle:

Another angle

Another angle

But as you can see, the deep valleys are where the simple scheme falls through. The terrain is just too dark.

Dark valley

Dark valley

I need to change the lighting scheme to use normals compared to a artificial sun. I will also add some minimum amount of light, to simulate ambient light. Hopefully this will not be too difficult. šŸ™‚



Tags: , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: