Dynamic lighting on non-Flash targets

245 views
Skip to first unread message

Claus N

unread,
Jun 21, 2015, 2:11:15 PM6/21/15
to haxef...@googlegroups.com
Hello!

I'm quite new to Haxe, and in my efforts to learn the system I decided to port one Flixel project to HaxeFlixel. Everything was running smoothly until I started implementing dynamic lighting, which plays an important role in the atmosphere of the game. It seems that the FlxSprite.stamp() function ignores blend modes on non-Flash targets.

You can find my sample code here. The function of the code is simple; I have a special FlxSprite abstraction called Darkness, which is cleared to a default color after each update() call in the main loop, and Light abstractions of FlxSprite which stamp themselves onto the Darkness sprite.

I understand, however, that blend modes are supported on non-Flash targets, as rendering sprites normally to a camera does respect the blend modes, as witnessed in rendering the Darkness on top of a background layer (which is just any image).

I tried hacking around the problem by delving into the camera system, and to openfl.display.Tilesheet rendering, but failed to do so. I also thought of making the darkness into it's own camera, which would have solved the problem, but I could not locate the line of code where cameras are rendered on-screen, so I could render the darkness on top of the normal camera using some hack.

Does anyone have any ideas how to proceed? I'd hate to abandon using HaxeFlixel, as I've grown to enjoy the language and the system. I'm using HaxeFlixel 3.3.8.

Gama11

unread,
Jun 21, 2015, 2:56:19 PM6/21/15
to haxef...@googlegroups.com, claus...@gmail.com
There's a DynamicShadows demo using Nape on the dev branch of flixel-demos. It works quite well on native targets.

Claus N

unread,
Jun 21, 2015, 4:08:26 PM6/21/15
to haxef...@googlegroups.com, claus...@gmail.com
Thank you for the tip, but casting shadows isn't what I'm looking for. :(

The dynamic lighting I'm looking to use is sprite-based, instead of drawing a field-of-vision like the DynamicShadows demo. I want to combine multiple sprites with either ADD or SCREEN blend modes to a background sprite, which then gets drawn with the MULTIPLY blend mode.


See attached image for an example. This was taken on the Flash target, however with neko/windows the lighting is buggy, as the draw order of the lights affects the end result, and with colored lights the problem is very apparent.

Bojer Bojington

unread,
Oct 31, 2015, 10:32:45 PM10/31/15
to HaxeFlixel, claus...@gmail.com
Anybody have any solution to this?  Is there some sort of workaround one could implement?  I am having the same exact issue as described here.  There is an issue on non-flash targets when using stamp and blend modes.  It looks great on flash, but bad on Windows or Android.  Example:


On the left is the Windows version and on the right is the flash version.

SruloArt

unread,
Nov 2, 2015, 9:57:39 AM11/2/15
to HaxeFlixel, claus...@gmail.com
* It sounds like a very specific issue with a very specific image on a very specific target, so it would be hard to answer right. My first guess would be something to do with antialiasing.

Eric Grice

unread,
Nov 2, 2015, 10:13:45 AM11/2/15
to haxef...@googlegroups.com

I'll try some different images and different file formats and see if that makes a difference.

--
HaxeFlixel Development Community
See our github https://github.com/haxeflixel/ and our documentation http://haxeflixel.com/documentation/
---
You received this message because you are subscribed to the Google Groups "HaxeFlixel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haxeflixel+...@googlegroups.com.
Visit this group at http://groups.google.com/group/haxeflixel.
To view this discussion on the web visit https://groups.google.com/d/msgid/haxeflixel/6229ab4f-9d28-4a36-9b4a-86a4b221b13e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Claus Nurro

unread,
Nov 2, 2015, 6:03:50 PM11/2/15
to haxef...@googlegroups.com
Only PNG images support transparency, and the windows builds are broken - that's been established through a thorough google search.

You received this message because you are subscribed to a topic in the Google Groups "HaxeFlixel" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/haxeflixel/bRcmtU-nmJ8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to haxeflixel+...@googlegroups.com.

xhunterko

unread,
Nov 2, 2015, 8:14:54 PM11/2/15
to haxef...@googlegroups.com
Hi! This has actually been done before and you can find it here:

http://haxeflixel.com/forum/?place=msg%2Fhaxeflixel%2F8IX0tTHifsQ%2Fk8A3QD6wWiYJ

While it's not exactly what you're trying to do, it might be better?

Enjoy!

Bojer Bojington

unread,
Nov 3, 2015, 8:55:34 PM11/3/15
to haxef...@googlegroups.com
Thank you!  I'm pretty sure that will do the trick... and more!

On Mon, Nov 2, 2015 at 8:14 PM, xhunterko <xhun...@gmail.com> wrote:
Hi! This has actually been done before and you can find it here:

http://haxeflixel.com/forum/?place=msg%2Fhaxeflixel%2F8IX0tTHifsQ%2Fk8A3QD6wWiYJ

Enjoy!

On Sunday, June 21, 2015 at 1:11:15 PM UTC-5, Claus N wrote:
Hello!

I'm quite new to Haxe, and in my efforts to learn the system I decided to port one Flixel project to HaxeFlixel. Everything was running smoothly until I started implementing dynamic lighting, which plays an important role in the atmosphere of the game. It seems that the FlxSprite.stamp() function ignores blend modes on non-Flash targets.

You can find my sample code here. The function of the code is simple; I have a special FlxSprite abstraction called Darkness, which is cleared to a default color after each update() call in the main loop, and Light abstractions of FlxSprite which stamp themselves onto the Darkness sprite.

I understand, however, that blend modes are supported on non-Flash targets, as rendering sprites normally to a camera does respect the blend modes, as witnessed in rendering the Darkness on top of a background layer (which is just any image).

I tried hacking around the problem by delving into the camera system, and to openfl.display.Tilesheet rendering, but failed to do so. I also thought of making the darkness into it's own camera, which would have solved the problem, but I could not locate the line of code where cameras are rendered on-screen, so I could render the darkness on top of the normal camera using some hack.

Does anyone have any ideas how to proceed? I'd hate to abandon using HaxeFlixel, as I've grown to enjoy the language and the system. I'm using HaxeFlixel 3.3.8.

--
HaxeFlixel Development Community
See our github https://github.com/haxeflixel/ and our documentation http://haxeflixel.com/documentation/
---
You received this message because you are subscribed to a topic in the Google Groups "HaxeFlixel" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/haxeflixel/bRcmtU-nmJ8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to haxeflixel+...@googlegroups.com.
Visit this group at http://groups.google.com/group/haxeflixel.
Reply all
Reply to author
Forward
0 new messages