Grid based lighting/field of view

Discussion and feedback on Construct 2

Post » Sun Sep 18, 2011 9:18 pm

Hi,

Here's an example of my lighting/field of view test I've been working on. It uses a custom plugin I wrote which uses Bresenham's line algorithm. This was all done using events and is still not very optimised (at the moment) and needs a semi decent system to get a decent frame rate. Eventually I will turn this into a grid based lighting/fov plugin AND optimise the hell out of it!

Original grid based lighting example (not optimised)

(Move the mouse to move the light)

- Rez

PS I'm a fan of roguelikes, can you tell?

Edit 5 (24/09/11): Here is the latest pretty example. This is a bit more decorated example, it has skeletons which don't do anything! It crashes at the edges so I wouldn't go there! (Forgot to put a barrier.) Seems the rendering can slow alot of computers down so try the speed test below.

Edit 6: Here is a speed test. You can change the radius with +/-. The grid is 60x60. Please if you can, post your fps at each radi and your computer spec e.g. high, medium, low! Thanks.

Edit 7: Here is an alternate way to render the shadow and light which is a bit faster.00Rez2011-09-27 00:07:50
B
21
S
7
G
2
Posts: 185
Reputation: 3,280

Post » Sun Sep 18, 2011 9:37 pm

Hey, this is pretty cool and the performance is quite good (steady 60 fps or so). I was just making a raytracer of sorts in CC, this looks super-similar, although I slightly cheated with the shadow part, just doing some distance-based point checks.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Sun Sep 18, 2011 9:47 pm

Thanks! The radius is pretty small so not much of a performance hit at the moment. Trying to think of ways to optimise it using maybe a pre fov test for every coord in the grid done when the game starts then using that as a look up. Do this for all the static objects then use a dynamic version for moving objects!
B
21
S
7
G
2
Posts: 185
Reputation: 3,280

Post » Sun Sep 18, 2011 9:56 pm

Not sure what you do for the values here - whether it's distance based or such, but for me doing a pre-calculated array of the light circle gave some pretty crazy performance gains.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Sun Sep 18, 2011 10:07 pm

It uses rays which stop as they hit blocks. Think I will definitely try the pre-calculated way.
B
21
S
7
G
2
Posts: 185
Reputation: 3,280

Post » Sun Sep 18, 2011 10:20 pm

Using FireFox 6.0.2 the FPS goes as low as 3 and as high as 24 :( Unusual as most other HTML 5 demos I've tried have been more than OK.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
120
S
28
G
68
Posts: 4,844
Reputation: 48,289

Post » Sun Sep 18, 2011 10:27 pm

Yeah it is a bit low in Firefox, I get between 18-30 in Firefox and 40 or more in Chrome which isn't that bad. It's quite performance hit until I get it optimised further.
B
21
S
7
G
2
Posts: 185
Reputation: 3,280

Post » Sun Sep 18, 2011 10:33 pm

Cool example. So you plan to release this plugin after its complete?
B
31
S
6
G
7
Posts: 140
Reputation: 5,983

Post » Sun Sep 18, 2011 10:55 pm

Thanks Danny! If I can optimise it enough then yeah! Got a few other plugin/behaviour ideas in the pipeline as well basically geared towards grid based role playing games. Already tested a container behaviour for an object so you can add/remove other objects. Basically I want to simplify the common needs of an rpg so anyone can make and focus on the creative side of the design process.
B
21
S
7
G
2
Posts: 185
Reputation: 3,280

Post » Sun Sep 18, 2011 11:33 pm

Hey 00Rez. Awesome stuff! I tried to do something similar with events but I couldn't get an FPS above 5 A plugin would rock!
B
55
S
12
G
8
Posts: 339
Reputation: 9,314

Next

Return to Construct 2 General

Who is online

Users browsing this forum: Lof and 0 guests