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!
10 thoughts on “DynaLight – Dynamic Lighting engine”
hi,I like your great light engine in haxe
can you comine your engine into flambe to cross platform as use stage3d render ?
current NME do not support stage3d but flambe can
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 :)
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.
Hey, can you post my email on here, so other people can see your solution to my issue later? :P
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?
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.
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,
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.
Thanks for sharing this! What would be involved in making this work on native targets?
TECHNICALLY it will work, but be very slow, since this is BitmapData based. Working on native targets using OpenFL would need to transfer to a different system that uses triangle drawing rather than flood filling.
There is an existing outline here: http://simblob.blogspot.com/2012/07/2d-visibility.html This would need to be optimized, but should work better than this system.