Grid-Based 2D Lighting Problems

Posted by Lemoncreme on Game Development See other posts from Game Development or by Lemoncreme
Published on 2013-10-25T02:56:14Z Indexed on 2013/10/25 4:17 UTC
Read the original article Hit count: 321

Filed under:
|
|
|
|

I am aware this question has been asked before, but unfortunately I am new to the language, so the complicated explanations I've found do not help me in the least.

I need a lighting engine for my game, and I've tried some procedural lighting systems. This method works the best:

if (light[xx - 1, yy] > light[xx, yy]) light[xx, yy] = light[xx - 1, yy] - lightPass;
if (light[xx, yy - 1] > light[xx, yy]) light[xx, yy] = light[xx, yy - 1] - lightPass;
if (light[xx + 1, yy] > light[xx, yy]) light[xx, yy] = light[xx + 1, yy] - lightPass;
if (light[xx, yy + 1] > light[xx, yy]) light[xx, yy] = light[xx, yy + 1] - lightPass;

(Subtracts adjacent values by 'lightPass' variable if they are more bright) (It's in a for() loop)

This is all fine and dandy except for a an obvious reason:

The system favors whatever comes first in the for() loop

This is what the above code looks like applied to my game: Light

If I could get some help on creating a new procedural or otherwise lighting system I would really appreciate it!

© Game Development or respective owner

Related posts about XNA

Related posts about c#