Concerns with the Light/Shadow so far

0 favourites
From the Asset Store
professionally animations with Brashmonkey Spriter !
  • *Please note, this thread is for discussion of the plugin and improvement/recommendations. Last time I did a thread like this, it stretched on for 50 pages, as people started using it for troubleshooting their own projects.

    Hey there! Just wants a quick post about peoples concerns with the new light/shadow feature so far.

    A while back I shelved the development of a pretty fun game purely because it relied on the shadow features granted by the paster plugin. It looked and played great, but I had issues in regards to the speed. You had to have a pretty decent machine to run what otherwise was a very simple game... and sadly, that just wasn't worth while.

    In any case, since the feature has come back to me in a form that is faster (can be used on mobiles), I thought I would pick the project back up... but very quickly shelved it again, and here's why.

    Multiple Light Sources

    My game relies on multiple light sources. Before, I was able to touch a button on the keyboard and spawn in new light sources using the same light over and over. With this one, I notice that for each light source you wish to introduce, you need to have a new object (ShadowLight1,ShadowLight2,ShadowLight3). If you don't, then the light sources appear to cancel each other out, and will only appear where they are zero shadows at all.

    *EDIT - Turns out you do not need multiple objects. My bad!

    It looks like you need to set the transparency to 50% or so if you have 2 lights to avoid each one washing the other out... but that's not of use to me sadly. I want anything in shadow to be completely dark, and anything in light to be completely light. I'm amazed that shadows are more dominant than light with this plugin.

    This is an example with 3 lights with 33% opacity.

    This is an example with the same 3 lights with 100% opacity.

    As far as I can tell, it's impossible for me to get the effect I want. If I was to set this up in real life, using real lights, I would be able to see the middle of the area without any issues.

    Light Colours

    I'm not sure why anyone would be interested in having different coloured shadows. Who know, maybe they will. It doesn't interest me though. In my original game, when a green light hit a red light, I'd get a yellow light. Looked cool.

    Seeing as this was almost a year ago, I can't remember exactly how this was achieved... but very well may have simply been an addition effect added to a coloured sprite. In any case, I suppose there's no reason not to have it, but like I said... it doesn't interest me, as I don't see the benefit.

    Shadow Length

    I want my shadows to go on forever. If there's no light, I want darkness. For some reason, if I have my level with 1 light, without height, without WebGL soft edging, without radius... I still end up with random glitches similar to, but not exactly like this:

    Final Thoughts

    I love the fact that we're getting this. This has been on the top of my list for about a year and a half, so I'm really happy we're seeing it being developed now. I'm not interested in putting anyone down, as I really am happy... but I just wanted to gauge peoples feedback on it to see what is impossible to change, and what we can really make use of. I'm hoping this plugin is actually something that can be improved on, and isn't just a simple drop in plugin.

    Anyone else have anything to add?

  • Should I take it everyone agrees, and has nothing else to add? <img src="{SMILIES_PATH}/icon_lol.gif" alt=":lol:" title="Laughing">

    I'm able to proceed with my game at the moment by using just 1 light, but ideally I'd like to use at least 3 in each level.

    Is this what our light and shadow plugin is based on, or is this more advanced?

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

  • I have to agree about the multiple light sources. That is a problem. In game where light is used for strong atmospheres say a dungeon. Then the light sources creating proper multilight layout is important. The situation where C2 Light system is designed for primarly a single source lighting need to be reworked from proper multi light source.

  • I'm afraid I don't see any improvement in the lighting in the last beta release

    I'm still seeing random lighting appear when I get to one side of the screen, and I still can't get decent looking multiple light sources.

    Are these this like to improve over the coming months? I've just continued a game that requires these 2 in place. If it's unlikely, I'm happy to shelve the project again in favour of another I'm working on!

  • The 'shadow length' problem is difficult to solve. As I noted in the original release notes: "Avoid placing radius-based lights very close to, or even over, shadow caster objects. The algorithm can fail to render a full shadow in this case.". The way the algorithm works is by extending the edges of the objects by a length and filling in the resulting polygon. As you can see from your screenshot the object is very close so the shadow extrudes at a very shallow angle either side of the wall (almost horizontal). This means it doesn't quite end up below the bottom of the screen, then fills across horizontally, not fully filling the shadow area on the screen. I've extended the extrude distance a bit further for the next build, but it's difficult to 100% solve this without extending the polygon for tens or even hundreds of thousands of pixels, which seems like a bad idea (some GPUs might struggle if you send them ridiculously enormous geometry). As the release notes say the best thing to do is just avoid putting lights with a radius that close to the shadow caster, e.g. by putting the light inside an object with an even bigger radius, and only moving the light where the bigger radius is clear of shadow casters.

    The multiple lights problem can be solved with a shader (which I've added for the next build). Is what you want is to have 2-3 lights and have shadows only appear where none of the lights can reach them, otherwise having full visibility? If so you can do it (from the next build) like this. For simplicity I've used an example of having 2 lights.

    • place 2 lights on the same layer with 50% opacity
    • notice that the areas that neither light can reach have 75% opacity (which is what you get when rendering 50% opacity on top twice)
    • apply the (new in the next build) Alpha Threshold effect to the layer, and set the threshold to 70
    • now you get 0% opacity (transparent, full visibility) where either light can reach, and 100% opacity (opaque, no visibility) where neither light can reach.

    With 3 lights, rendering 50% opacity three times results in 87.5% opacity, so a threshold of 80 should work. However the result is, although correct, very strange. I'm not convinced it's what you really want. You get a very unusual pattern of scattered black triangles in odd places, which just so happen to be the intersection of shadow for all three lights. IMO the original example of just using ordinary opacity looks better, but then it doesn't fully obscure areas none of the lights can reach. This again is achievable using additive blend. If you have 2 lights on a layer with 'force own texture' set to yes, opacity 50, and each light using additive blend, then you get a build up to opaqueness instead of just becoming less semitransparent. In other words 50% opacity rendered over 50% opacity with additive blend results in 100% opacity (opaqueness), instead of 75% opacity like you would get with normal blend. IMO this result looks better: instead of weird scattered triangles, you get a clear distinction of full visibility where both lights can reach, 50% opacity where only one light can reach, or fully opaque darkness where neither light can reach. Adding a third light and dropping the opacity to 34% would create a similar three-stage effect and so on. This is already possible in the current build.

    In short with creative use of blending, opacity and layers, you can already do some interesting multi-light effects - and with shaders (such as alpha threshold in the next build) you can do even more.

  • This sounds exactly like what I want.

    I'm using the system to simulate fog of war. If I have only one actor, the current system works just fine, I just pin a light to the player character and the obscured areas are out of LOS. Combined with the LOS plugin, this makes for an effective system.

    The problem is when you are controlling a team/multiple actors. The solution seems simple enough: just pin a light to every actor. It sounds like a design problem that shadows take precedence over light.

    You get a very unusual pattern of scattered black triangles in odd places, which just so happen to be the intersection of shadow for all three lights

    The intersection of all shadows, in this context, means none of your actors can "see" in that spot, therefore it should remain black (obviously black polygons are weird, but nothing that a bit of semi-transparency can't fix).

    It should be clear that, in this mode, light sources need a "maximum radius", to simulate a maximum LOS distance.

  • Ashley - Yeah, I figured I should have added the correct image. I couldn't remember when I'd saved the image, so used another example.

    As you said, it's probably the range, but you can see in this example that the light sprite is pretty far away from the walls.

    Might it be possible to allow us to set the extrude distance ourselves? If I'm making a game for an iPad, I'll want it pretty large, but if I'm making a lower res game I want it smaller. If that's too tricky to add in, then not to worry. I imagine if it's off screen it won't cause many problems with processing anyway?

    The shader for the next build... will I be able to use that without WebGL? Unfortunately I can't use WebGL for my next project.

    I've just tried out your other method so I could better visualise it, and while I'm getting solid black shadows now where no light reaches, sadly it's still not the effect I want. Personally, I just want solid white for light, and solid black for shadow. I imagine I'll be able to do that next build.

    This is with 34% opacity on each light. For some reason I'm getting pitch black shadows where there should be light... but in any case, I don't need transparent shadows, so it doesn't worry me too much. With this new effect you've created, will other people be able to get transparent lights? It doesn't sound like it, but in any case I intend on adding a fall off sprite that overlays the light source so it will slowly fall off into darkness.

    Can you tell what they made this light system using? http://ncase.me/sight-and-light/ Is it HTML5? Flash? It appears to run great in a browser, and the code appears to be open source. I don't understand how this all works, so I'm not sure whether or not the same system is possible... but it appears to work with multiple light sources brilliantly!

  • Im also waiting a solution for that problem, in my game there will be multiple source of lights (player, torch, etc) and when the ''light ray'' touches a shadow from another source it should become visible, good to know there is a solution for that in the next build

  • Just to answer my question from earlier in case anyone else is searching... the new shader that Ashley created DOES require WebGL, so anyone working on a platform that doesn't allow WebGL can NOT use this.

    Back to the drawing boards

  • Hi! Just a quick question regarding the new shadows. It seems there is no way to get the Height of the Light to change it with an action like: Every x Sec > Set Heigt to Light.Height+10 to cast longer shadows over time. And you cant "read" if an object is in a shadow or not (Is in Shadow True/False)? This would be very useful but I couldnt find it, yet. Did I just miss it or ist it possible with a workaround?

  • Bl4ckSh33p - Shape.ShadowCaster.Height+1

    It's the object, not the light.

  • Thanks. I will try it.

    But the Light object has a Height too and it works if I create a global var and increase it every second and set its value as light Height. It's missing?

  • I started playing around with the Shadow Light and Shadow Caster some today to see how well it worked to see I could utilize it for the shadowing effects. Wondering if anyone has been able to test it out and find a way to deal with shadows starting from transparent parts of sprites. Tried playing around with Shadow Height but didn't seem to change it from the shadow cast or using it as an action.

    [attachment=0:mih6ifcr][/attachment:mih6ifcr]

    If I could get the shadow to start after X pixels from the top to where it started around shoulder height might be better. I've turned down the opacity while playing with it for now and it can hide it down some, but you can still see the shadow is starting based around the outline of the sprite and not based on the content within the sprite finding where the transparency ends and then content of the sprite begins.

    But I do agree that the length of the shadows is an issue. If could make it based on the height of the object making the length of the shadow. Or a setting/action where you could set it from 1x/2x/4x/8x/32x/Custom the height of the shadow cast object as the length choosing one of those values / being able to change the values through actions.

  • daehawk , the shadow object already can do what you ask. Not with soft shadows though. Use webGL blurs if you want to soften the shadow's edges.

    Have in mind that:

    1) The outline of the shadow depends from the collision polygon of the sprite (you'll have to use convex polygon shapes).

    2) Each sprite can have different shadow heights. No need to mess with the light's height. You can use multiple lights with the tagging system for more complex setups however.

    See the attached capx for an example.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • daehawk Have you correctly set up the collision mask?

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