DynaLight – Dynamic Lighting engine


So, if you were interested in the previous post, I put up the library on GitHub!

You can check out the source there (it’s written in Haxe, but AS3 users should be able to understand most of it anyways), and also I have a .swc up for download if you are planning to use straight up AS3 with it!
Haxe users will need to install polygonal-ds ( haxelib install polygonal-ds ) to use the source!

Please check it out, and let me know if anything goes wrong, or if you have any questions!

Live Demo


10 thoughts on “DynaLight – Dynamic Lighting engine

    1. Unfortunately, the method I’m using isn’t tailored to triangle based rendering systems, since it uses per pixel operations. I’ve been looking into shaders a bit, in which case it would definitely be able to run on Stage3D, but I haven’t done any benchmarking or performance testing. Right now I just plan to finish a few of my game projects with this current engine, and later on I’ll revisit the lighting engine to run on Stage3d and NME :)

  1. Hey man.
    First off, let me tell you that I love your hxDynaLight engine.
    It’s beautiful, and awesome, and yay. I’ll definitely tell you once I release this game.
    So, let me get to the point, my question:

    I keep trying to define rectangular occluders, like in the live demo, but they all end up being just points that shoot thing shadows off into the sky. Is it possible to make, for instance, my flashlight’s light stop once it hits this wall or something of the sort? Does that make sense?

    Thank you so much.

  2. One more question:
    Surely you’ve used the haxe-based game engine HaxeFlixel?
    If so, would you know if there is any way to implement this lighting system as a part of the haxeflixel state, so, for instance, the debugger would not be darkened due to this engine?


    1. Sorry for not replying yet. From what I had seen from your code, everything is fine, so I’m not entirely sure what might be going on. Is the screenshot video you sent me based on that code fragment? If not, then you should show how you set up all of the block lighting. Also, try switching the order in which you pass the points in to the Occluder object. Is your code directly from the sample code? Since that covers lots of lighted blocks with several moving lights.

      I have not used Flixel or HaxePunk. You should only be adding this engine’s bitmap above the elements you want hidden…so…it’s simply a matter of addChilding at the right point/index.

      Btw, I will continue to reply directly in these comments for consistency.

  3. Hello!
    I am using hxDynaLight in LD28 now, and I need your help!

    I can’t get ShadowSegment to work, and I tried creating a ShadowRect class to replace ShadowSegment for my purposes, but none of both worked.

    Here’s the github issue: https://github.com/PDeveloper/hxDynaLight/issues/ ;
    you can find my code on github too: http://github.com/S0lll0s/yogo/
    The relevant part is now in src/entites/RectEntity.hx:

    var seg = new ShadowSegment( x, y );
    seg.add( new PointInt(0,0) );
    seg.add( new PointInt(w,0) );
    seg.add( new PointInt(w,h) );
    seg.add( new PointInt(0,h) );
    occluder = seg;

    It looks like this: http://i.imgur.com/haLNmDE.png

    Please help me,

    1. Oh and also, how do I detect whether an occlude is “seen” (aka throwing an actual shadow) in a directional light?

      I tried creating a callback in LightEngine but it toggled when you looked away too.

Leave a Reply

Your email address will not be published. Required fields are marked *