Concerns with the Light/Shadow so far

Discussion and feedback on Construct 2

Post » Fri May 30, 2014 3:55 pm

*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.

Image

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

Image

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:

Image

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?
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
81
S
13
G
7
Posts: 969
Reputation: 10,898

Post » Sun Jun 01, 2014 11:47 am

Should I take it everyone agrees, and has nothing else to add? :lol:

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/
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
81
S
13
G
7
Posts: 969
Reputation: 10,898

Post » Sun Jun 01, 2014 3:32 pm

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.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,038

Post » Fri Jun 06, 2014 11:05 am

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.

@Ashley- 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! :)
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
81
S
13
G
7
Posts: 969
Reputation: 10,898

Post » Fri Jun 06, 2014 3:08 pm

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.
Scirra Founder
B
399
S
236
G
89
Posts: 24,519
Reputation: 195,361

Post » Fri Jun 06, 2014 7:59 pm

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.

Ashley wrote: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.
B
36
S
8
G
8
Posts: 532
Reputation: 6,903

Post » Fri Jun 06, 2014 10:55 pm

@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.

Image

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.

Image

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!
Last edited by AnD4D on Sun Jun 08, 2014 7:12 pm, edited 1 time in total.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
81
S
13
G
7
Posts: 969
Reputation: 10,898

Post » Sat Jun 07, 2014 4:13 am

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
B
32
S
6
G
5
Posts: 437
Reputation: 6,119

Post » Sun Jun 15, 2014 6:44 pm

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 :(
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
81
S
13
G
7
Posts: 969
Reputation: 10,898

Post » Thu Jun 19, 2014 3:17 pm

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-Soft - Custom Software and Indie Games
B
56
S
17
G
6
Posts: 748
Reputation: 9,420

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 5 guests