Tilebased Light - kinda like Minecraft

For questions about using Classic.

Post » Mon Sep 05, 2011 10:31 pm

Thanks a million! :)
Thank you Animmaniac and Tokinsom, that's perfect! ;)

But how would you stop it from render through 1x1 tile(32x32) walls?

Like lights in a labyrinth...
If you have alot of small solid objects scattered about...


Thanks anyways! I will study this deeply! :)

/MJOneMJOne2011-09-05 22:33:02
B
5
S
1
G
2
Posts: 28
Reputation: 806

Post » Tue Sep 06, 2011 6:04 am

I took the challenge of adding occlusion to my example and came up with two different approaches: one uses raytrace and the other is similar to minecraft's method through propagation.

http://dl.dropbox.com/u/7871870/construct/tile-light-raytrace-01.cap

http://dl.dropbox.com/u/7871870/construct/tile-light-minecraft-01.cap

They are not very fast, specially the raytrace that could be a little more optimized.

The second method propagates the light every frame like if "calculating on the fly", so it doesn't look very good for moving lights. I tried to make it update instantaneously but it became to slow. I recommend using it for static illumination mainly.

Actually both can work better for static lights. They can be executed just once at the start of a layout (during a loading screen for example) just to set the illumination resulting in a better performance.
Scirra Employee
B
129
S
45
G
15
Posts: 705
Reputation: 15,413

Post » Tue Sep 06, 2011 7:05 am

I recently made something very similar to this for my game, except I only made it calculate the light when you change tile. Which helps keep the framerate higher.alspal2011-09-06 07:06:23
B
134
S
65
G
16
Posts: 1,765
Reputation: 19,188

Post » Tue Sep 06, 2011 11:47 am

Woah! You guys are amazing! :)

Im really moved by how fast I got help on this forum.
Thanks a thousand times!

Is it okey with you Animmaniac if I use this method in my game/s?

I will study these two examples as well, see what I can learn!


Thanks!

/MJOne
B
5
S
1
G
2
Posts: 28
Reputation: 806

Post » Tue Sep 06, 2011 4:05 pm

[QUOTE=MJOne] Woah! Is it okey with you Animmaniac if I use this method in my game/s?[/QUOTE] Yes it's ok, you can use it freely. If you came up with an optimized solution I would be happy if you share it here on the forums.
Scirra Employee
B
129
S
45
G
15
Posts: 705
Reputation: 15,413

Post » Tue Sep 06, 2011 8:04 pm

While reading this thread at work on a mobile and being unable to participate I came up with a method as well. Now that I have implemented it turns out it's quite similar to Animaniac's raytrace I guess (at least the look).

It's very rough, not optimized at all, but kinda works. Check it out (you can drag and drop the lights and use Numpad + and - to change their size).Somebody2011-09-06 20:05:13
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Tue Sep 06, 2011 10:17 pm

Sorry to bump my own last post, but I did a little optimization and the whole thing is now about 15-17 times faster (heh). For smaller things realtime raytraced light is fairly viable. It's still the same example, same keys and all that.

I'm fairly sure there's more to be squeezed out, but for now you get the latest example. Touch a light to start. It also doesn't render unless necessary now, so don't get too excited by the thousands of fps it shows while idle.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Wed Sep 07, 2011 12:33 am

Something similar can also be achieved by simply using lights and the shadowcaster effect like you are used to for dynamic lights. You'll get the "tilebased" light effect by applying the pixellate effect with the appropriate resolution to the layer.

Isn't too fast either, because of shadowcasters, but it's definitely useable. Here's the described method quickly applied to Somebody's example: http://dl.dropbox.com/u/2306601/TraceRay_dl.cap
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Wed Sep 07, 2011 11:50 am

Thank you for sharing your great solution! :)

If and I mean IF I can make it faster I will post it here! :)


Thanks again!


/MJOne
B
5
S
1
G
2
Posts: 28
Reputation: 806

Post » Wed Sep 07, 2011 11:53 am

Woaw thanks everyone for your great examples, I have alot to learn here! :)

Im pretty suprised over the positive and enthusiastic response I got here!
Man you guys are great!

Thank you all!

/MJOne
B
5
S
1
G
2
Posts: 28
Reputation: 806

PreviousNext

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests