[Tutorial] A real dynamic light system

1 favourites
From the Asset Store
Carousel Animation, make carousel of you image gallery or anything
  • Lol I'd settle for shadow casters that weren't additive like in Thomas was alone.

    http://store.steampowered.com/app/220780/

    With only one light source you can easily achieve this look by putting the light/shadow caster into a separate layer, have the light have 100% opacity and lower the layer's opacity.

    See the following example.

    https://www.dropbox.com/s/gatskbxmb1ogo ... .capx?dl=0

    You can achieve similar result with the alpha threshold effect also, but the first method is much easier.

  • Yeah that's a viable solution.

    Interesting that 100% doesn't mix.

    Thanks eli0s

  • newt , you are welcome!

    Since the shadow caster draws shadows and the 100% light is drawing pure black, there aren't any values mix. So, we get a matte black value. lowering the layer's opacity simply makes the matte black shapes see-trough...

    By the way, Ashley, have you noticed that if you apply a sine behavior to two or more lights everything break? If the sine is active that is. Pinning the light on a sprite that has the sine works fine!

    And thanks for the tutorial!

  • Hi everyone. I have recently begun to do some prototyping for a game that is going to be based a lot around light and darkness. I did some research with Construct2 and realized both the potential and limitations of the Shadow Light object.

    I did some experimentation and came up with almost identical solution as in Ashley's tutorial. And weirdly enough I posted my findings and suggestions to Scirra the same day as the tutorial was posted... Some kind of omen? Perhaps, but I rather believe in creepy coincidences.

    As I have already posted my suggestions to Scirra I thought it could be a good idea to post them here as well, to get feedback from you end-users.

    Following Ashley's principle of "putting light in the darkness", rather than putting "shadows in the light", would it not be the best solution if the Shadow Light object produced an opaque layer with the falloff gradient already in place inside the object? If the shadows and the falloff are just one object it becomes very easy to blend several lights together. You just Screen or Add/Dodge them and they will blend nicely on just one single layer. And this single shading layer is all that you need to blend with your background. Removing (or adding) shadows manually from unwanted areas becomes very easy by just placing something bright or dark on top of the Shadow Light objects in the same layer.

    The advantages of this is:

    • Only one single layer is needed for shading your levels.

    • No need for nested layers.

    • The amount of Shadow Light objects is not dependent on how many layers you have. This allows for easy dynamic creating and destroying of an arbitrary amount of Shadow Light objects.

    If the falloff is (internally inside the object) multiplying the shadows, that could lead to interesting effects. Like if the falloff had a bitmap like the Sprite object, that would allow for a custom shaped falloffs, like tinted colours and shapes. For example, imagine if you have a mounted lamp on a wall, and you want to place a light source on it, you would want the lamp to cast shadows on the wall. You could then have a customized falloff that matches your lamp sprite, creating the illusion that the lamp is also casting shadows on the wall. Perhaps even play animations, which would be handy for flickering light sources such as torches.

    Do these suggestions make sense?

    If you users out there would create a game with shadows and light, would you prefer a method similar to what I have described here?

    Would these features be helpful, both technically and artistically?

    At least I think so, but I'd love to hear other's opinion on this.

  • Anything that'll allow me too use multiple light sources and many shadows without WebGL is all I need. Been asking for this since 2014, along with an update to Sprite Font.

    Instead, we get more exporters which are removed months later.

  • the problem for me with c2 speaking for lighting system is this. someone starts a topic for lighting system. people try to find the best way to make a lighting system with better results when we add normals of the sprites..

    spritelamp, sprite dlight, and spriteilluminator's work is the inspiration and the goal here as i understand from the pictures of the topic starter. So people try to find a solution and give the best solution. LeuNoeleeste will upload a tutorial (20 pages) to make it easier for us how to use the Joannesalfa alternative.. so everybody who have the skills offer their time to help the rest of the community and i'm grateful for this.

    And then Ashley upload a cool tutorial with different light sources with different colors. that is almost ok cause some artifacts are here and there BUT with parallax enabled the whole thing doesnt work the shadows are running faster than lucky Luke i wrote about this yesterday no answer..so the tutorial is ok for something but not helpful for other situations.

    Sometimes when i wrote some problems I've got i think that dev's make me a favor to answer. Ashley you said that you dont see a reason why to upload a half hour video full of effects of a game. the reason is that i want normal maps and a better light system, bloom effects and sprite emitters that works actually everywhere without a problem like IN THIS GAME.if i cant do this with c2 i dont mind at least i know that i cant. if i need to make a metroid style game with parallax effect on and put in a level 10-20 lights (including spotlights, pointlights and a sun light ) i need 10 to 20 layers for this and if i put some normals inside the result will be correct? cause in a static game like this example you upload is working (with no normal maps inside) but with parallax on is chaos.

    if again you don't understand its simple what im asking for "is there any way to make it easier user friendly and better way to have a better lighting system with normal maps in c2 or c3? cause i see people try to find a way and help when you dont understand.

  • Ashleys example and tutorial are nice but "problem" is still here and will remain here because current editor was never build to handle that kind of things.

    Besides that it's not a solution to have more than 1 light in the layout but it's more like a someone said earlier a hack to make it work just to prove it can be done.

    1 light per 1 layer is idiotic and even more limiting. Forget about bigger layouts with dozens of lights or even having dozens of levels with more than 3 lights on each (well, unless you want to spend half of your life setting and managing it up,..), forget about spawning random objects that emit lights (can't create layers at runtime)...

    And there's still a Normal map textures issue - one of the main things in that post - which obviously don't work with more than 1 light source after all this years...

    so yeah. C5 maybe.

  • Anything that'll allow me too use multiple light sources and many shadows without WebGL is all I need.

    I don't think that you'll get that without WebGL. Ashley said that in the future, when 98% of devices will run WebGL they plan to drop the Canvas2D renderer because it's holding them back from implementing more advanced rendering features.

  • Yeah, Ashley's example is too "opinionated" solution, even it fixes issues for someone, not sure it would be another for possibilities.

  • I'm not arguing that my solution was perfect, I just think it shows that you can get quite far already with creative use of the available effects. I know there need to be new features to make this easier, but you are asking for some pretty sophisticated, almost 3D-engine grade lighting effects. Obviously it is great if we can support this but it is a great deal of work, and given our focus is on C3 right now we just can't spend a few months going back to C2 to work out how this kind of stuff can be done. We also have to balance this with the great many other feature requests we get in completely different areas, with people who also think their ideas are totally obvious must-haves, but we obviously can't do them all at once.

    would it not be the best solution if the Shadow Light object produced an opaque layer with the falloff gradient already in place inside the object?

    I don't like this kind of solution since it assumes everyone wants that. The current system is more flexible: you can avoid using a sprite and have infinite-range lights, you can use a custom sprite with a stepped/pixellated fade-out for different styles, etc...

    Anything that'll allow me too use multiple light sources and many shadows without WebGL is all I need.

    This is basically impossible. WebGL is a requirement for advanced rendering effects. canvas2d is very primitive in comparison and already effects like the penumbras with a shadow radius are only supported in WebGL mode. Why is canvas2d support so important to you still? As mentioned, we are likely to drop canvas2d support entirely at some point in the future, particularly because pretty much everything that people asked for in this thread is basically impossible to do in canvas2d, so only supporting WebGL opens the door to more advanced rendering features.

  • Ashley Can you not add those extra features as only webgl features?

  • megatronx - yes, we already have WebGL specific features, but in this case it doesn't make it any quicker to develop and there are still ~10% of users who fall back to canvas2d, so we want to hold off on those features until it's more like 2% on canvas2d.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • > Anything that'll allow me too use multiple light sources and many shadows without WebGL is all I need.

    >

    This is basically impossible. WebGL is a requirement for advanced rendering effects. canvas2d is very primitive in comparison and already effects like the penumbras with a shadow radius are only supported in WebGL mode. Why is canvas2d support so important to you still? As mentioned, we are likely to drop canvas2d support entirely at some point in the future, particularly because pretty much everything that people asked for in this thread is basically impossible to do in canvas2d, so only supporting WebGL opens the door to more advanced rendering features.

    Ashley I only consider it important because I work on NWF. Therefore, I am restricted only to canvas2d. For some reason, they can't be bothered to support WebGL, so I'm tethered to using less developed effects. I don't personally care about penumbras too much.

    I know in the end it boils down to it being their fault and not yours... but I swear I've seen decent shadows on canvas 2d with multiple light sources before.

    I know I've posted this before, but have no idea if it's HTML5 or Javascript.

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

  • I know I've posted this before, but have no idea if it's HTML5 or Javascript.

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

    That particular solution effectively brute-forces penumbras by having 11 separate lights! That's going to be quite a hammer on performance. The WebGL solution looks better with only a single light.

    I know the NWF is an exception, but I'd rather focus on the majority of platforms rather than just the one, even if it's Nintendo...

  • > would it not be the best solution if the Shadow Light object produced an opaque layer with the falloff gradient already in place inside the object?

    >

    I don't like this kind of solution since it assumes everyone wants that. The current system is more flexible: you can avoid using a sprite and have infinite-range lights, you can use a custom sprite with a stepped/pixellated fade-out for different styles, etc...

    That's why I asked if others find it useful. I don't assume everyone finds it useful, but I know I would benefit greatly from having a falloff with just one object.

    But why not make such feature togglable then, if possible? Then everyone can have it their own preferred way. Infinite range, or limited. It's the user's choice.

    It isn't creating the falloff that is the problem here, it's the limitations involved when doing the falloff manually.

    Doing it the manual way requires one layer per light. And like you explained in your tutorial, each layer requires significant extra computation. It would require to dynamically show and hide layers on demand, as opposed to just creating and destroying Shadow Light objects. And since layers can't be created or destroyed on run time, so I'm stuck with a limited amount of possible amount of light sources.

    So my point is more that my suggestion would allow an

    • Virtually unlimited amounts of lights on just one single layer.

    • You wouldn't need to have the background on top of the shading layer.

    • And no need for nested layers, which I assume would take more time and effort to add to Construct 2 than just adding a falloff to the Shadow Light object.

    But the reason why having it opaque is helpful is that the Shadow Light objects can then easily be blended (screened/dodged) without the need for limiting and complicated workarounds.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)