A Flash Developer Resource Site

Results 1 to 20 of 21

Thread: playing with light v2

Threaded View

  1. #1
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139

    playing with light v2

    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
    Last edited by mr_malee; 10-23-2008 at 10:19 PM.
    lather yourself up with soap - soap arcade

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center