Tuesday, December 27, 2011

Line of sight and light

I was working on some light for the game, and have implemented a very simple ambient light, it basically just draws everything with a filter to make it appear darker. It was the first step in my lighting idea. I want to add a light map on top of that so I can pre calculate all static lights and just add those values to the ambient light. That will give me instant light at minimum fps cost. Only lost about 100 fps adding ambient light. I still havn't optimized anything, so still doing a lot of overdraw.

I have added a single light at the start position of the map to show what it looks like. I have turned ambient light down to 0 to better show the light.


It supports colors as well, I can set rgb colors. Right now I am not sure how I can blend them if multiple colored lights are next to each other. But I will figure that out when I get the light map to work.


 The light passes through walls at the moment, but that should be fairly easy to fix by implementing a line of sight algorithm. I am thinking Bresenham's line algorithm, implemented one years ago, worked well back then, so should do the job now as well.


 A line of sight algorithmic can also be used for other things, like making npc's detect the player. Ranged attacks will need it to work. Maybe even only drawing tiles that are visible to the player so he cant see enemies sneaking up on him. A lot of fun possibilities.

No comments:

Post a Comment