DynaLight (alpha ver) for punk.fx


(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.


(azrafe7) #21

Hey… sorry, but I think I remember you NastySprite! It’s nice to have you back!

You were trying to implement a zoom in/out feature in your game and I promised to post something about it.

I came up with this (but never posted it, as the forums went down - a bit old but… use SPACE to zoom in/out | ZX to fire/change weapon | P to pause).

The code is somewhat messy, but if anyone needs it I can make it available.

PS: Any chance to test your game?


(no-jo) #22

Yeah that’s it!.

Pleased you remembered.

I think the source for a zoom in/out feature would be really useful to have in the forum. Especially one that takes a HUD into consideration.

I’d certainly like to have another stab at integrating it into my game.

I’d be really interested to know what you think of it. I’m trying to keep it on the quiet until released (getting close though) but when i’m ready i’ll post a link in the forum for general scrutiny and overall ego crushing.


Punk.fx - zooming game independently from HUD
(Kevin Graham) #23

Wow this looks awesome! I was amazed by the speed change after turning of the pepperflash plugin! Why is that?


(David Williams) #24

I’m also getting a solid 60 fps (Intel i7 3.4ghz, 8gb RAM, GeForce GTX 570).


ShapeBlaster (very alpha) + Vec2 class