Awesome OpenGL lighting effects in 2D games

Master Of Guns Screenshot 2

I recently implemented a cool lighting effect in Master Of Guns. I added normal maps and shader programs to calculate the specular and ambient light. This way i was able to create night and day levels and add cool 3D like reflections to my 2D sprites which i find quite cool.

How did i achieve these awesome lighting effects?

First of all i digged into the topic GLSL shader programming which was quite cool because it was a completely new experience for me programming the GPU instead of the CPU.
A very good tutorial what helped me a lot is mattdesl’s shaderlessons on github.

After i got familiar with shaders i implemented normal map reflections and lights. I was able to create a sun like lightsource for day levels. For night levels i made a cool looking flashlight which is bound to the players aiming direction.

Why all the effort is absolutely worth it!

These effects improved the visual appearance of Master Of Guns so much. I am so happy about it. There is more variation in the visuals now than never before.

The Night levels bring even more variation into the game because the are not only improving the visuals but also the gameplay and the overall atmosphere of the level. Enemies are more difficult to kill by night since the player can’t see as good as by day.

I spared out shadows in my implementation so its looks a bit unrealistic because walls dont drop shadows as expected the light just go straight through them. But i think it looks good the way it is. Maybe i will implement correct shadows later.

So what do you think about lighting and shaders do you have experience with it? Have you already worked with it? Or is it completely new to you like it was to me? Leave me a comment below!

About Marius

Hey, thank's for reading the post! My name is Marius and I'm a game-developer from Germany. I started Helfsoft to create the games of my dreams!

Leave a Comment