hello. Due to the bad performance of the other light version I had to investigate another method. And with a little research it has payed off
here's the result:
(Main) http://littlemofo.soap.com.au/gamedev/lights/
(Debug) http://littlemofo.soap.com.au/gamede...ght_debug.html
the inspiration came from this great article: http://www.gamedev.net/reference/pro.../2dsoftshadow/
but the problem that I quickly found was dealing with a light positioned close to a wall whose length is much greater than the lights radius. The projected edges of the wall would need projections of 20000000 px or similar to mask out the lights radius. So what I did was this:
1 - find intersecting points on the circle add them to edge array.
2 - project line edges out at (radius - edge distance), if > 0 add the edge, otherwise disregard it
3 - sort found edges based on distance to light + distance to lines start
4 - get first 2 closest edges
5 - find angle difference between edges
6 - interpolate between these angles projecting more points
7 - draw from edges to points and back to start to create the shadow geometry
tada!
removing all bitmap drawing / copying and simply using shapes / blendModes gives hardly any performance drop (for 1 light) and light can be massive.
next is giving walls height values. I don't think that trying to implement soft edges is going to be worth it, seeing as you need a custom texture for it to work. I don't like that.
anyway, I'm much happier now![]()






Reply With Quote