Shadows problem

Get help using Construct 2

Post » Sat Apr 13, 2013 9:26 pm

Hi guys

Im making an orto game where i plan object to have shadows.

I guess all shadows have to be in one layer and the layer to become transparent, so the different shadow sprites wont overlap, and get darker.

But here lies my problem. If the layer is placed below the main layer, no objects will be shaded, only terrain. And if the layer is placed above, objects will be always in the shade.

So anyone knows how to deal with this?

Maybe there is another way to blend shadow sprites transparency, so it's always 50% transparent for example?

Thanks
B
12
S
3
G
1
Posts: 120
Reputation: 1,829

Post » Sun Apr 14, 2013 1:41 am

Hi Pakot, nice looking game you are working on.

I actually think it looks ok with the shadows overlapping each other, but one possible way would be seperating the shadow from the units and then either setting them invis or transparent when overlapping.

Or maybe you could achieve it with one of the webgl effects? Im not sure.
ImageImage
B
73
S
16
G
6
Posts: 1,038
Reputation: 10,473

Post » Sun Apr 14, 2013 1:59 am

Plugins to shadow 2D objects.

http://www.scirra.com/FORUM/player-position-based-dynamic-shadows_topic62613.html?KW=shadow+plugin

http://www.scirra.com/FORUM/effect-2d-dynamic-lighting_topic59130.html?KW=shadow

By the way, you can use a set of detectors, moving the desired shadow up or down on the same layer, like you did with the player, but dealing with the overlapping issue would require one of that special effects to setup it.

Destination Out is the way to go..

https://www.scirra.com/manual/146/effectsTELLES08082013-04-14 02:22:40
ImageImageImageImageImageImage
B
92
S
19
G
12
Posts: 1,192
Reputation: 18,276

Post » Sun Apr 14, 2013 2:15 am

[quote=Pakost]And if the layer is placed above, objects will be always in the shade.[/quote]

Can't see why it's a problem... Isn't it what usually happens in the real world? object in the shade... are in the shade?
Now maybe your shadow shape covers too much of your object? you might get away with just cutting the shadow around the object?

Maybe an illustration of the problem could help (:

Anyway I like what you did. Especially with wall construction.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sun Apr 14, 2013 2:29 am

@Yann
How long, I missed your posts!

Shadow overlapping each other is a common issue on the real world, he just need to send the character shadow up or down on the Z order like he did with the player to get a nice and real effect.
ImageImageImageImageImageImage
B
92
S
19
G
12
Posts: 1,192
Reputation: 18,276

Post » Sun Apr 14, 2013 3:00 am

@TELLES0808
hey thanks

Well, was busy with the C2 class and some other stuffs.

I get that shadow overlapping each other is an issue but he seems to have the right work around: lowering the layer's opacity instead of the individual shadow's opacity.

and as far as the character's shadow is concerned, he merely talked about "objects being always in shade" vs "no objects will be shaded, only terrain".
So as much as I understand why only shading the terrain would be bad, I don't understand why "object being always in shade" is a problem if they are supposed to be shaded by another object...

So I think I'm mostly misinterpreting the problem and ask for an illustration of it just to be sure.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sun Apr 14, 2013 1:44 pm

Thanks for the answers guys. And for all the praises. I'll try to explain better what my dilemma is.

I'm using z order plugin for all the sprites. The best way is to cut the shadows and let them arrange along with all the objects. Even better, if I left them with the object (most of the objects are with their shadows atm) they usually get good results.



But the problem is that when you get 2 shadows on top one of another, you get double dark shadow. So my best option atm as i see it is to leave it like that(the object count drops x2).

@TELLES0808, I hope there is something i really dont understand about blending modes, but i dont think if all stuff are at one layer, the shadows, even seperated from objects, can blend correctly, cutting only other shadows out.

So my second option is to gather all shadows and place them in a layer, and the layer gets 50% opacity, so the overlapping of shadows look good but there are another issues. Z order plugin works only per layer, so all the shadows would be over or beneath the sprites in the main layer.

@Yann here are some examples of the downsides of that option:

Shadow is in upper layer:



Shadow is in lower layer:



And last @GenkiGenga i dont think hiding shadows on overlap is good idea... it will result some popping. My best hope is that it can be achieved with some kind of blending mode or something, but i really dont see how.

B
12
S
3
G
1
Posts: 120
Reputation: 1,829

Post » Sun Apr 14, 2013 5:29 pm

You can make a Z order system using events, without any plugin, let me find the post and show you how.

by the way, it\s very easy to achieve using events.

http://www.scirra.com/FORUM/rpg-games-and-the-overlapping-issues_topic51274.html?KW=order

http://www.scirra.com/forum/plugin-isometric-z-ordering-based-on-y_topic46247.html

Also, you can setup your buildings to have more points, and check the points on the bottom, middle, etc, by using different families.TELLES08082013-04-14 17:32:15
ImageImageImageImageImageImage
B
92
S
19
G
12
Posts: 1,192
Reputation: 18,276

Post » Sun Apr 14, 2013 7:15 pm

here's my idea
shadowMasking.capx
you have all the shadow in one layer which is at 40% opacity, so they blend well
And they shade units on layer main if they don't have masks

I'm not at home so I don't have all my image editing tools, but you can even try to make the tower mask fade toward the bottom to get some subtle casted shadow.
(Edit: hmmmm nah wouldn't really work, the shape of the shadow wouldn't make the cast on the tower good)

I don't think you'll get better result than that without going 3D

On thing that might not be obvious is that the shadow layer has "force own texture" to yes for proper masking.
Last edited by Yann on Sun Sep 14, 2014 7:24 pm, edited 2 times in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sun Apr 14, 2013 9:46 pm

OMG @Yann thats a brilliant idea you got!

You are right the towers dont shade each other correctly but i got a solution.

Here

Instead of getting all masks on top of the shadow layer i let them along with the shadows to arrange in the layer the same way as the main layer stuff.

So now when the object is infront of another, the mask of the front object is over the shadow of the object in the back so it doesnt shades.

That works as a charm. There is one major problem though.... That way i got all the objects in the game multiplied by 3, as object count and as sprites. Even more i got them all ordering by Y (not sure if this affects the performance).

Btw is there a way to make the mask out of the object sprite in construct2, so i dont have to double the sprites in game?

Anyways for my project i think i'll stick with the simpliest way. Have all sprites along with shadows and live with the overlapping glitch. Sadly but i think that technique will get too much for the performance.
B
12
S
3
G
1
Posts: 120
Reputation: 1,829

Next

Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 26 guests