light and shadows... drawing

Discussion and feedback on Construct 2

Post » Wed May 28, 2014 11:04 pm

Hey all,

@Ashley - I have been playing around with the shadows and lights in the new beta release. Its really cool. however, I have one request so far (a simple one I think). Great work so far on it!


Currently, it is the shadows that are drawn, rather than the light. I think the reverse would be better in many situations. An option to choose what is drawn (either light or shadow) would be awsome. The way light effects had normally been done in the past in construct required a layer set to black (or whatever color shadows were going to be...) the layer would be set to force own texture and then the lights would be added to the layer with destination out. Basically lights cut a hole in the "darkness". If the darkness layer used multiply, you could make colored shadows and colored lights (blend mode is set to normal on the light and the light layer is set to multiply) the multiply method .

Essentially you can do the same when shadows are drawn but it takes more work than if the light is drawn. Mixing traditional lighting methods with the new shadow method is difficult due to the opposite workflows involved in each aspect...

If you use a normal method of lighting a layout and you draw the shadows, a few problems emerge. Namely one of them being that the tile map below the light gets shaded on blocks that shoudln't be. If you bring them up one layer then the don't get shaded by the overall light layer.

In cases where you wish to use screen or additive blending you have to use the shadow caster to cut out of an entire layer set to screen and filled with the light color of your choice. Sometimes, if complicated effects are desired it is impossible because you need to have layers within layers in order to get the desired effect.

This can all be solved simply by selecting what is drawn: Either light, or Shadow. No matter how you like to build up your effects, being locked in to drawing only shadow is difficult. If any one wants, I can post some capx demonstrating different lighting problems that would be better solved by drawing the light, rather than shadow. There are of course instances where drawing shadows is preferred, but so far I have found that I would prefer to draw the light so the it can be more easily combined with cutout lighting methods, multiply lighting methods, and screening/additive lighting methods. I hope this all made sense. It all ready requires 2 layers at least for reasonable lighting situations and having to have more doesn't make much sense if it can be avoided.

TLDR: Lights need to have the option to draw either light or shadow.. .
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,163

Post » Thu May 29, 2014 3:31 pm

So the light would draw an area of white where the light can reach instead of black over the shadows?

You should already be able to get that with an opaque white layer with the shadow light plugin on it. You can use multiply blend with that. It should be straightforward, what is wrong with that exactly?
Scirra Founder
B
399
S
236
G
89
Posts: 24,528
Reputation: 195,388

Post » Thu May 29, 2014 6:06 pm

@Ashley - the following scenarios should more effectively demonstrate what I mean. I also found out some other things as well.

Case:1 You want a situation where multiple lights are used. Because shadows draw instead of light you get an additive effect with the shadows. All the shadows draw despite that they are lit by another light. Using opacity to control the shadows doesn't really fix the problem because the shadows still build up even where they shouldn't. If light was drawn then you can use it to cut out of a black filled layer resulting in light falling how we expect it to.

SubCase 1a: This scenario also brings up another problem that indicates an additional feature is needed to the light and shadow behavior/attribute . Light fade distance and cutoff. You can easily do this at the moment by creating the black layer and using a sphere to stamp out a light circle. You then draw the shadows in and presto, you have a really neat area of light complete with awesome shadows. But then you want another light, and the whole model is broken. all of a sudden dark shadows cut across fields of light that they shouldn't. You can't even fix this by adding more layer.

Case 2: When using a layer to render light effects, including illumination areas and so on, the light layer usually has to be above, the tiles needing to be lit. A problem arises here in which the block that is casting a shadow actually gets covered by that shadow. You can't add in those blocks on the layer above light because then they will be just as light even in "dark areas". If light was drawn, you could draw it as black and then use draw the shadow casters as black on the same layer. Finally a white sphere sprite could be put on top of it all with appropriate blend mode to not cover any shadow area.

Currently, the shadow being drawn where the shadow caster is would be nice to toggle but not needed if you can draw light in stead of shadow.

----------------------------------------

In my mind, the addition of the light and shadow behavior is super awesome as it adds in a slew of professional effects to construct. It's very exciting. But adding in the ability to draw either shadow or light would make the system more robust and seems like an essential feature to me. It would really add to its flexibility. Other features such as light fade (linear fade at the least) and light effect distance would be really, really nice. I know you can do this via a build up of layers and sprites but wouldn't it be more cost effective to have it all together in terms of performance? Also it is imposible to have multiple lights behave as expected because of how you have to use layers to build them up. Including light distance/fade would solve this. Lastly, being able to reduce the arc that light shines would be cool to, but would be much more of a bell and whistle. Essentially being able to set the angle and radius in degrees of the light (for easily creating beams of light).

In conclusion I feel that the following options would really help create a strong light/shadow model thus increasing the behavior's value to the construct community. (in order of priority/need in my mind)

1. Draw either shadow or light (needed for flexibility and certain situations)
2. Light fade distance (Fade type (linear/expo/none), distance(in pixels) (needed for multiple lights with area of effect)
3. Angle of light (from 0-360) (for creating narrow beams of light)

I hope you will consider at least the first one (and the second would be super nice too), I shouldn't expect it would be too hard to implement and I think it is necessary. The list of found cases where drawing light would be better than shadow will only grow as people have time to work with it.
Last edited by ruskul on Thu May 29, 2014 6:08 pm, edited 1 time in total.
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,163

Post » Thu May 29, 2014 6:06 pm

I can post capx demonstrating the above when I get home if the description isn't clear enough. I do have them already
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,163

Post » Thu May 29, 2014 6:15 pm

Do you mean something like this?

http://ncase.me/sight-and-light/

Wouldn't this also fix the problems when a light source is too near a shadow caster? Plus when light appears to pass between the seam of two adjacent sprites?
B
9
S
2
G
1
Posts: 7
Reputation: 1,631

Post » Thu May 29, 2014 6:16 pm

If I understand correctly you can already convert the shadow plugin to render light by using a layer. Create a white layer, place the shadow light on it, and set the layer to additive blend mode. Bingo, a layer that renders light instead of darkness.

You can then customise that by further additive blending a circle on top (so shadows never appear within a radius), or cutting out a cone shape (to simulate an angle of light). You can do a lot with creative use of layers and blending, and I think it covers all those cases already.
Scirra Founder
B
399
S
236
G
89
Posts: 24,528
Reputation: 195,388

Post » Thu May 29, 2014 9:27 pm

Is it possible to recognize whether or not you are in shadow or light via events?
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
82
S
14
G
7
Posts: 974
Reputation: 11,035

Post » Fri May 30, 2014 5:08 am

@Ashley, I don't think I must have explained very clearly. I know you use a layer to effectively draw light instead of shadow. And I understand you can create a distance fade off with some clever blending, but because you already used an entire layer simply to convert the plugin so that it draws light, it becomes impossible to do other tricks given the way layers are applied.

Clever layering and blend modes (such as drawing bg last if you want it to be unaffected by light, with other blend modes on middle layers) creates cool effects. And you can certainly get just about any one effect. But that's just it, you can't get effects combined without a bit more flexibility. You can't have have multiple light sources with two light plugins, due to the way they draw shadow. I think my inability to clearly illustrate the problem via text is showing here. Unfortunately, I can't even show a capx demonstrating how to do the the cases I mentioned above because they are theoretical and I would need to be able to draw light straight from the plugin. You say you can solves those cases using creative layering and blendmodes/effects but the only thing that you said could be done was what I explained could be done. The key is that all the effects I mentioned can be done in isolation. But how can you have multiple lights that make sense given they way they are currently drawn? You need a layer for each additional light but that won't work unless you can group multiple layers and render them as one texture to whatever needs the light/shadow on top of .

Does any of this make sense?
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,163

Post » Fri May 30, 2014 8:21 pm

HEy, @Ashley I had an epiphany. Originally I thought I would change the plugin myself but realized it would take to long to figure out how you went about things, given its about 1000 lines of code. I've followed other tutorials on 2d lighting and understand the basics but I was lazy...

So instead I wrote a couple of lines of code and BLAM - I made a shader to invert the alpha channel. now prepare to be amazed by my ability ability to draw light. :)
____________________________________-
*EDIT***************

I'm not sure why but for some reason the shader doesn't work on the light plugin. It works on sprites but not the light. If I add the effect to the light plugin "set Color" followed by "AlphaFlip" then it works on the plugin... -> I may need to post this in another forum
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,163

Post » Sat May 31, 2014 12:20 am

Some very interesting stuff mentioned here.

@Dru this example is awesome! I'll be damned if I got half a line of math, but the logic is clear.

I think that if gray-scale masking were possible, most of those problems would have being solved.

I like the ideas for per-light falloff and light cone. I 'd also like to see a condition that checks if an object exists within a shadowed area. This will be incredible useful for covering/uncovering stuff when they are not in direct light view (hiding behind shadows).
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 8 guests