DynaLight (alpha ver) for punk.fx


(azrafe7) #1

Wow we’re - finally - back: BIG THANKS to who managed to bring the Forums back online (thanks zach)!

Missed the community.

I’m working (actually was, but I’m planning to resume it) on a dynamic lighting effect for punk.fx (a project that maybe some of you remember - I should probably take the time to make a post about that project on this new forum…) based on ideas from catalinzima.

This thing it’s just in alpha stage, but I’ve successfully integrated it in punk.fx and rewritten all the pixel-by-pixel code into PixelBender shaders (hopefully leveraging the use of GPU power instead of relying on the CPU).

With this effect you can add lights (and specify a bunch of parameters for them - size, falloff, etc.) to the rendered scene and shadows will be automatically calculated from a background image representing the occluding objects.

Keep in mind that it’s still an alpha, and has to be worked on (optimizations, refactoring, etc.) but… here’s what it looks like as of now: https://dl.dropboxusercontent.com/u/32864004/dev/FPDemo/DynaLightAlpha.swf.

Also: can we have a “Work-In-Progress” category like in the old forum? OK, I’m fine with it.

EDIT: If you’re on Chrome disable the Pepper plugin.


Flashpunk and lighting?
(Zachary Lewis) #2

That’s awesome. Shaders rock. :heart:

I didn’t see the need to separate creations into multiple categories. If you’d like feedback on your work, you can also post a topic into the feedback category.


(Joe_Williamson) #3

That’s so pretty! I look forward to using this. :slight_smile:


(TheHuckleberryWill) #4

Looks brilliant! Will definitely be using it!


(JasperYong) #5

dem pretty lights, does remind me a lot of 'Darkwood’s atmosphere :stuck_out_tongue:


(azrafe7) #6

New demo, but haven’t yet pushed the code to github (needs extra work… hope to find out how could I squeeze some more FPS).

Cave environment and multiple lights: https://dl.dropboxusercontent.com/u/32864004/dev/FPDemo/DynaLightDemo%20-%20alpha0.swf


(Abel Toy) #7

Looks really cool, but yeah, squeezing a bit more FPS would be nice!

Is it using shaders? I had a lights implementation which didn’t use them run at a similar speed…


(Alex Larioza) #8

Wow! This looks fantastic! I’ll probably make a game using this just because it looks awesome. :smile:


(azrafe7) #9

Many thanks for the appreciations! :smile:

@AbelToy: Yes, it’s using shaders (actually two), and every pass could render up to 3 lights (can have different properties - size, falloff, etc. - but are bound to be of the same color).

The nice thing that got me started is that to have this light/shadow simulation working no actual raycasting (in the common meaning) is needed (so no polygons/points), just a simple image with a transparent background (you can read about the overall process over here and take a look at this awesome implementation without shaders here on wonderfl).

For example the “occluders bitmap” used in the last demo is just this (+ the moving platform):

![cave.png](/uploads/default/669/d1b1505ab47c2c1a.png)

I pass this image through the effect (which applies two shaders). The effect spits out a lights/shadows’ image that then gets some blur and color adjustments and is rendered with a MULTIPLY blend mode.

Haven’t yet found a suitable way to improve performance (other than downscaling the “occluders bitmap” thus reducing quality), but am still searching and toying with it (any thoughts welcome!).

In FireFox it (unexpectedly) performs better, and after a couple of minutes runs at a steady 50/55 FPS. Also some small improvements can be seen building for Flash 11.5 or AIR (demo should be for 11.2 IIRC).

Abel, you got me curious about your previous implementation, can you please expand on that (maybe I could steal some ideas too :wink: )?


(Abel Toy) #10

Haha, your implementation sounds better than mine indeed. I just did the typical raycasting over some polygons… I guess having same-colored lights would make it faster?


(Ultima2876) #11

Oddly, it seems to be smooth (50+ fps) when I’m not moving the mouse but then drops to 5-10 fps whenever I move the mouse (change the lightsource position).


(azrafe7) #12

@AbelToy: yes, using same-colored lights actually makes it a bit faster, but I’m still not satisfied with it. Moreover I keep getting different FPS from time to time, even though I’m testing the same code with the same settings (don’t know if it’s due to FlashDevelop or what?!).

@Ultima2876: That’s odd (also the part where you get 50+ FPS :wink:). I’m doing nothing fancy with the mouse other than using Input.mouseX and Input.mouseY.

What browser are you using? If you’re on Chrome can you please try disabling the pepperflash plugin (as mentioned in the first post) and see if it gets better?


(Ultima2876) #13

Safari on Mac OSX :slight_smile:


(azrafe7) #14

@Ultima2876: Ouch… I have no way to test on a Mac other than a VM, and flash runs waaaay to slow on it.

If you have any other browser installed could you please tell me how it performs on them?


(Ultima2876) #15

I tried on chrome with pepperflash disabled, similar results. It seems to be that when the mouse moves it does some kind of recalculation which bogs things down. I’ll try it on my Windows PC later on and let you know how that goes :slight_smile:

EDIT: Tested on my Windows machine… silky smooth 60fps. Though that machine is quite powerful (Intel i5 4ghz, 8gb RAM, Radeon HD5850)


IntelliJ IDEA Licenses for FlashPunk Developers
(azrafe7) #16

Thanks for the update!

Though it’s not a fair benchmark running things on that monster o.O


(Ultima2876) #17

Haha, yeah, that’s why I generally test things on my MacBook Air. I only really use that Windows comp for playing games (and occasional development).


(no-jo) #18

That’s pretty smooth @azrafe7

Another great flashpunk effect. This would work great in an idea i have for a world in my game. excellent stuff.

Still love pixelate though.

Good to see you back on the forums (you helped me a couple of times on the old one. Many thanks)


(azrafe7) #19

Thanks!

Are you VoEC??!?


(no-jo) #20

No, i was NastySprite.

You may remember…

The last problem i had was some issues integrating the pixelate transition effect. I was trying to do an ingame zoom in/out feature which i managed to do but this also zoomed the HUD too and i didn’t want that.

There was a tutorial in the forum that used a modified world class called Layers. You create layers for the HUD and another for the game play elements instead of a world class. You can then zoom the desired layer leaving the others unaffected. It worked but i had trouble pixelating all the layers in one go.

You fixed that problem Thanks. Although i ended up having some issues with the layer system and had to side line the zoom idea for a while then FP disappeared.