[Suggestion] Dynamic Lighting plugin/behaviour

Discussion and feedback on Construct 2

Post » Fri Dec 16, 2011 1:48 pm

Edited: Better title, and check my latest post for more thoughts on this. I'm mainly advocating polygon-based dynamic lighting now, due to computational reasons and it's kinda how the old lighting stuff worked in Classic.



I know you guys have a massive to-do list, but I don't think one more can hurt, really. Lighting can do a lot for mood and atmosphere, and while there are methods to create lights manually, as seen in the lighting example that comes with C2, there could be much more in the way of options, especially with WebGL.

In Construct Classic, lights were objects of their own, not I think they would work better as a behavior. Not only because sprites themselves can act as light sources, but also to allow particles to emit light, as well. While this could theoretically be done with making additional sprites as lights, like in the lighting example, it results in more objects to take up CPU usage. There also needs to be options that are more friendly to side-scrolling games, where shadows work differently to how it works in a top-down environment.

For an example, I'm gonna have to pull out Terraria. As a game, it's decent, but it's not that great. For the most part, I'd rather look at its engine rather than its game design, mainly due to how it can have two layers of potentially thousands of individual tiles on-screen at once, and its lighting system. For those who don't play Terraria, I'll throw up a couple of screenshots to demonstrate.




Terraria's lighting is designed around a side-scrolling environment. When light hits an object, it passes through it, and for every consecutive object it passes through, it gets dimmer until it reaches pure black. Certain lights also have their own colours, which go onto other objects, including not-solids. During the day, the above-ground world is lit by the sun. Many engines call this type of light a 'directional light', as sun's light shines down on the world from a certain direction depending on the time of day.

Until recently, dynamic lighting in 3D and top-down environments could have a problem of shadows being pure black, if a single light source is produced. This is unrealistic, as light bounces. Even trying to emulate the effect of indirect lighting would go a long way for more natural lighting.

A list of features for Lighting/Shadow behaviors that I'd like to see, on top of features already in the Construct Classic equivalents:

- Multiple options for light colours (white, RGB, using the object's own colours, etc)
- Transitioning between two light colours over time (times of day, etc.)
- Options for allowing light to pass through multiple objects
- Directional lighting for emulating the sun/moon's rays
- Light strength and range
- Emulating indirect light for top-down lighting

I'll add more things as I think of them. I hope we get to see something like this in a future build... Eventually. :)Candescence2013-07-11 13:06:31
B
94
S
37
G
11
Posts: 404
Reputation: 11,275

Post » Fri Dec 16, 2011 1:56 pm

There's many ways to simulate lightning. I don't know how it works in terraria but it seems that it's a highly tweaked system specific for their case. Seems not to be shader based but more like an alpha blending based one. It's not difficult to implement in the simplest form. Now that we have WebGL this is all doable without framerate drops, shader based or not. Canvas is just too slow for this. Great lagging on Chrome and Firefox, even with HWA enabled. Smoother in IE9 but IE9 is broken right now , i don't know if it's on C2 side or on IE side.
Anyway i think we are all waiting for the day when Construct2 will be on par with Classic supporting effects, color tint, advanced blending etc. Kiyoshi2011-12-16 14:02:09
B
58
S
13
G
10
Posts: 632
Reputation: 12,505

Post » Sat Jun 08, 2013 8:46 am

Is there a way for me to make Lighting like this? I know this is an old post but i really need lighting for my project that is similar to terraria.
GMO FOOD = DEATH
B
17
S
4
G
3
Posts: 514
Reputation: 4,524

Post » Sat Jun 08, 2013 12:34 pm

Terraria lighting is definitely possible using WebGL, even possible without WebGL. But Actual shadow casting like in the game Gish, I don't think that's currently possible.
You MAY be able to pull this lighting off using the Pathfinding plugin/behaviour (I haven't looked at Ashleys pathfinding myself so much), as everything is gridbased, though I'm not entirely sure.
B
45
S
19
G
10
Posts: 562
Reputation: 9,543

Post » Thu Jul 11, 2013 1:03 pm

Looking back on this thread, I've been playing Mark of the Ninja lately, and what strikes me is how it uses dynamic lighting. Finding examples is pretty easy, google images has plenty. The lighting itself is somewhat cone-based and has a 'textured' look, but it can be 'blocked' by solid objects, like the lighting from Construct Classic.

Remember how the light object and the shadow behaviour from Construct Classic worked? I've already stated how I think they could be greatly expanded upon in concept in Construct 2, but I also think Using polygon-based lighting instead of cell-based is a reasonable compromise. Since sprites in Construct 2 already use polygons for collisions, it would probably be far less computationally expensive and much easier to do than cell-based lighting.

I know I like to keep bringing up Starbound, but this is incredibly cool stuff:






And you don't really need cell-by-cell lighting to replicate the same results (aside from the way the light 'penetrates' into the ground, but still).

Now, the thing is with such lighting solutions, good luck trying to make them work with just events. I think it would be a good idea for an official or unofficial plugin to be developed for polygon-based lighting, with as many options as possible for what developers want with lighting in their games, whether it be pitch-black darkness in absence of light, or just low light for stuff like stealth-based games.

I'd also like stuff like specifying image points for the 'origin' of the light itself, like a light attached to a gun, for example (as shown in Mark of the Ninja), and also being able to adjust the angle of the light without changing the angle of the object itself (those last two suggestions I also want to see applied to the Line of Sight behaviour).

So, yeah. Polygon or grid-based, I don't mind as long as it works well, I just want a good lighting solution, dangit.
B
94
S
37
G
11
Posts: 404
Reputation: 11,275

Post » Thu Jul 11, 2013 7:43 pm

I posted this before, but basically you are looking for a shader that does shadow casting.
http://greweb.me/2012/05/illuminated-js-2d-lights-and-shadows-rendering-engine-for-html5-applications/

This guy has a head start on it.
B
30
S
10
G
7
Posts: 416
Reputation: 7,239

Post » Thu Jul 11, 2013 8:54 pm

@Jase00

There's multiple examples on shadowcasting , if you do a small search

[Quote=Rojohound]
They've been possible but there is no plugin to make it simple.

Here is a way to implement it using the canvas object to draw the shadows.
http://dl.dropbox.com/u/5426011/examples14/shadow_cast.capx
[/Quote]

Cheers !Whiteclaws2013-07-11 20:55:04
B
34
S
16
G
16
Posts: 2,222
Reputation: 16,564

Post » Thu Jul 11, 2013 9:30 pm

[QUOTE=firebelly] I posted this before, but basically you are looking for a shader that does shadow casting.
http://greweb.me/2012/05/illuminated-js-2d-lights-and-shadows-rendering-engine-for-html5-applications/

This guy has a head start on it.[/QUOTE]
Okay, Illuminated.js looks amazing. Considering it's an open-source plugin, I imagine all Ashley would have to do is integrate it into how Construct 2 does things. If he doesn't already know about it, he should.
B
94
S
37
G
11
Posts: 404
Reputation: 11,275

Post » Thu Jul 11, 2013 9:44 pm

@Whiteclaws Wow that's awesome! I never understood how they worked but I assumed they were difficult. Still, awesome :P
B
45
S
19
G
10
Posts: 562
Reputation: 9,543


Return to Construct 2 General

Who is online

Users browsing this forum: shinichild, veeru5656 and 10 guests