TIGSource Forums

Developer => Technical => Topic started by: kvisle on November 02, 2013, 10:37:49 AM



Title: Dynamic lighting in a 2d game
Post by: kvisle on November 02, 2013, 10:37:49 AM
Hi!

I don't post here much, so you have probably not seen me before -

I'm working on my own game, using my own engine written in OpenGL.  The game is all in all 2D, all my mechanics and physics are in place - but I was wondering "wouldn't it be cool to add dynamic lighting in the mix?".

So now I'm pondering how I could implement this.  I've been searching for what techniques will implement this, and I'm not yielding any good results - I may be bad at searching, I don't know.

The idea I have in my head, is that for each fragment in my lightmap, I will need to cast a ray towards the light source(s), and change the value according to if it's lit or not.  This will definetely work - but I worry that doing this on my entire full screen 1080p game every frame won't be a tad bit expensive.

I've decided to ponder on this problem for a while, before I go on and implement it - there are still a lot of other things to do in my game, so it can wait.  But while I do so, I thought I should try ask someone here.

Does anyone have any experiences doing this? Any example implementations to show to?

/Trygve


Title: Re: Dynamic lighting in a 2d game
Post by: Christian Knudsen on November 02, 2013, 11:14:02 AM
http://forums.tigsource.com/index.php?topic=18942.0
http://forums.tigsource.com/index.php?topic=34435.0


Title: Re: Dynamic lighting in a 2d game
Post by: kvisle on November 02, 2013, 03:28:34 PM
Thanks a bunch - it seems I failed to search this specific forum.  This will be helpful :)