light and shadows... drawing

Discussion and feedback on Construct 2

Post » Sat May 31, 2014 12:13 pm

@ruskul - you might need to put the shadow light on a transparent layer with 'force own texture' set for inverting alpha to work, otherwise it will be rendering to an opaque surface and the alpha will never be different.

As for detecting objects in shadows: how do you actually define if an object is in a shadow? There are a variety of ways to do it: is the hotspot in the umbra, is the entire collision polygon in the umbra, is the entire bounding quad in the umbra, etc - and then what about penumbras? If it ever so slightly edges in to a very wide penumbra that probably shouldn't count as suddenly visible, but on the other hand an object just inside the light edge of a very wide penumbra should probably count as visible. I don't know how to accurately define that. The line-of-sight behavior can already make visibility checks, and it only looks at origins but you can make it do multiple checks around the edges of objects to come up with your own solution, so I don't think there needs to be a shadow-specific feature for that.
Scirra Founder
B
397
S
236
G
88
Posts: 24,412
Reputation: 194,516

Post » Sun Jun 01, 2014 8:19 pm

@Ashley I am not sure how I can describe it, I'm not quite sure what is it that I miss from the current state and functionality of the shadow caster. I'll try my best to make my self clear:

1) The system draws shadows, so in essence it finds areas that are behind (in relation to the light source) the polygons of the shadow casting objects and draws stretched dark shapes to simulate shadows. So far so good. But what happens when an object should cast its own shadows, be visible but gets behind an other object that is "taller" than it, so it should be shaded by the taller object? How can we achieve that? I have a workaround with the line of sight, but it's far from ideal.

ShadowedByOtherObjects.capx


2) We can colorize the shadows but the other way around would be more useful. I know that we can use other sprites with blending modes to fake the color and add falloff, but I believe that if the system worked by darkening everything out except for the parts that are in direct view with the light source, it would be more evident and useful. At least as an option. Again, I understand that we can do that by using a white layer, but then things are getting more complicating and as I mentioned many times in the forums already, masking in general is not Construct's best virtue. Using blending modes to mask layers with other layers is... a sore to say the least.

I hope that I make sense! :D
You do not have the required permissions to view the files attached to this post.
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Mon Jun 02, 2014 8:18 am

Isn't possible to recreate this http://ncase.me/sight-and-light/ with Construct 2?
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,421

Post » Thu Jun 05, 2014 9:24 pm

@Joabbesalfa - I believe it is possible to create that image. You wouldn't be able to get the cell shaded effect with the "not quite lit, but not in shadow areas" (if that makes sense) it would have to be a soft shadow. You would need several layers to do it. Right off the top of my head it would be something like this:

(drawn from top to bottom) There are probably better/more efficient ways to do this...

1. Layer with the characters normal "lit" sprite. Include other stuff here to that needs to be covered by the shadow.
2. Shadow layer. Put the shadow/light plugin in this layer. The layer needs to have it's own texture forced. The light/shadow plugin must be drawn first. After it is drawn everything that you want drawn in the shadows needs to have blend mode set to source atop. the characters bones would go here in this manner

What it all does: First the game renders the scene as you would like it to normally appear. Then in another layer the shadow is drawn. Because this layer is set to force it as a texture it draws everything in the layer and then draws that layer to the main canvas. Shadows are drawn in this layer and after they are done the game draws stuff that should appear in the shadow. Because the blend mode of these other things is set to source atop, only areas that have already been drawn on (in this case, shadows) will be drawn on. Effectively, the shadow acts as a mask and only where it exists will stuff be drawn in this layer. Does that make sense?
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,153

Post » Thu Jun 05, 2014 9:32 pm

@Ashley - thanks for the suggestion! I tried that already though. The weirdest thing is that it works no matter how shader is used on a sprite. Regardless of how I set up the layers I can't get it to work the way I expect it to on the light plugin. If I use the set color shader on the plugin before flipping alpha it works. I'm going to have to dig around to see whats going on/make sure I even wrote my shader correctly.
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,153

Post » Thu Jun 05, 2014 9:44 pm

@Ashley, I forgot to mention one thing. Do you think it would be possible to have directional vs point based options. Right now the light plugin is point based.
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,153

Post » Sun Jun 08, 2014 8:01 am

It may be due to my relative lack of knowledge when it comes to how any of this actually works, but I'm with ruskul on this. It makes more sense to me to implement a light-caster, rather than a shadow-caster. Where everything is in shadow, unless it is hit with light. I hope this kind of thing is technically feasible, as I am running into a few issues while trying to implement a solid lighting system that makes sense to me.

That said, the current shadows are really good at what they do, and are a million times better than nothing at all. Ideally I would only want to use sprites (light-blobs) for coronas or baked in static lighting, rather than using them for lighting the entire world. Or at least, have the ability to cast point light and light cones with fade off and whatnot to have a more solid interactive lighting system. I think the limitation of having to create separate layers for lights is what is causing me the most trouble.

Some examples of what I've hacked together. You might be able to see where this would be improved if the lighting system didn't work backwards, as it were.

lighting-test-1.png

lighting-test-2.png

lighting-test-3.png
You do not have the required permissions to view the files attached to this post.
B
30
S
7
G
7
Posts: 102
Reputation: 6,548

Post » Sun Jun 08, 2014 3:51 pm

@plauk I really like your art style! And the first photo with one light source looks amazing! :D Do you use the tilemap object in your game?
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Mon Jun 09, 2014 12:08 am

Thanks, @eli0s. I'm still kind of learning how to do pixel art. This is the first time I've tried isometric, and unfortunately you can't do isometric tilemaps (yet?), so it's all individual sprites set out on a grid. It would be amazing if the tilemap plugin could eventually do different types of tiles like isometric and hexagonal, but even if it did eventually do that, I'd be a bit concerned about the limitations with using shadows on a tilemap anyway. I still have to do some tests with tilemaps to see if it would even be worth using one.
B
30
S
7
G
7
Posts: 102
Reputation: 6,548

Post » Wed Jun 11, 2014 1:08 am

@plauk - good job, neat perspective. You could use a tile map for orthogonal tiles - you just have to set the collision polys to angles and such (if that makes sense), it might be faster to make the world, idk
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,153

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 7 guests