How do I pixel perfect shadows for animated sprites

Get help using Construct 2

Post » Thu May 18, 2017 7:34 pm

I have planned lot of enemies and other stuff that i want have some shadow. I need a "pixel-perfect" shadow, this is an image of what i mean:

Image

My idea was: On start layout create the same sprite in a bottom layer with a tint to black, 50% opacity and pin position-angle that automatically does that for all the sprites in a family.

I tried it but is all a mess, any idea of how do that in a correct way?

EDIT: Maybe a plugin like the "Shadow Caster" for cases like this will be great...
B
23
S
10
G
3
Posts: 538
Reputation: 4,426

Post » Thu May 18, 2017 8:52 pm

Why was it a mess ? It seemed like a good idea. I tried it and doesn't look messy to me, maybe I just don't understand what you expect. :P

https://www.dropbox.com/s/ajhrcaggbdlv6 ... .capx?dl=0
B
67
S
27
G
24
Posts: 969
Reputation: 18,573

Post » Thu May 18, 2017 9:35 pm

Magistross wrote:Why was it a mess ? It seemed like a good idea. I tried it and doesn't look messy to me, maybe I just don't understand what you expect. :P

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


You did a great work and your execution is better than mine but this work for the sprite, the idea is do it for a bunch of sprites in a family.

I have it working for one sprite more easy, using the pin behaviour,etc... but the problem comes when you have lots of sprites of different forms. In my case the shadows are placed but some ones with incorrect sprite shadow or ones have two or more shadows...

Add some static sprites with a rhomb form, triangle or whatever, all inside the "Shadows" family, can you place all their shadows correctly?
B
23
S
10
G
3
Posts: 538
Reputation: 4,426

Post » Thu May 18, 2017 9:59 pm

I made a small shader some time ago. If you apply it to the object than it will cast shadow on top of other object based on Z position.
Image

But, also you can apply it to the layer and get something like this
Image

Never published it, cause I don't think it's finished (visible parameters do work as intended), If you want I can give it to you for a test ride ;)

EDIT: woah! sorry I did not expect those images to be that big..
ImageImageImageImage
B
157
S
64
G
41
Posts: 2,590
Reputation: 34,640

Post » Thu May 18, 2017 11:21 pm

Just updated the capx... But shinkan's shader looks amazing and require no events whatsoever. Seems like the choice is easy. :lol:
B
67
S
27
G
24
Posts: 969
Reputation: 18,573

Post » Fri May 19, 2017 1:25 am

If drop shadow effect doesn't do the job (sometimes your shadow might not be at the angle or position you want, depending on how you draw your sprites) - you can make a separate object for the shadow and add it to a CONTAINER with your main sprite. Using a container will always make sure the shadow is following the correct instance of the sprite without having to do any UID (or similar) comparisons.

Similarly, you can just draw your shadow onto the actual sprite using a 50% opacity brush or something - which is usually what I do - but again it really depends on how you draw your sprites if that way will work for you or not.

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
80
S
34
G
40
Posts: 3,029
Reputation: 30,393

Post » Fri May 19, 2017 7:23 am

Thanks for the reply guys!

@shinkan Yes i requested a shader like that to @Gigatron that did this one:
request-drop-shadow-plus_t191342
(That i guess does the same as yours. )

The problem was that on sprite animations on export(due spritesheeting) , the shadow overlaping with other objects and the shadow rotation on sprite rotation changes.

But as you pointed, adding the DropShadow to the layer works perfect! even with animations on expored!(no mater spritesheeting anymore) and the shadow is always on that Offset, no matters the sprite rotation :D .

---

@Magistross Thanks for the updated .capx maybe in some cases i will hade to do in this way to have more control over the shadow. BTW, you again add an event to each sprite that needs shadow, that is like give shadow for each srite one by one. If i have 50 enemies i will have to make 50 events... the idea was make general, so simply add the sprite on the Shadow family and this one gets shadows automatically, without add into events.

---

@SoldjahBoy Yep! i know, but you have to use containers, add for each sprite a container with a shadow,etc... i was looking a more automatic process. Now time to test better all this but seems is working that i need.
B
23
S
10
G
3
Posts: 538
Reputation: 4,426

Post » Fri May 19, 2017 1:49 pm

I made mine over a year ago for something I was working on.... But just downloaded the one Gigatron made and he made it a bit different.
So if you want here's my version of it shinkan_DropShadow but probably they do work the same way ;)
ImageImageImageImage
B
157
S
64
G
41
Posts: 2,590
Reputation: 34,640

Post » Fri May 19, 2017 1:58 pm

@matriax That's unfortunately impossible to make a generic approach to creating specific objects from a family... unless you use a plugin like nickname from rexrainbow.
B
67
S
27
G
24
Posts: 969
Reputation: 18,573

Post » Fri May 19, 2017 3:01 pm

@shinkan Thanks i will download too, never knows!

---

@Magistross Then thats why my one was a mess XD, because seems is impossible :P . Well, now with the effects at least will works for my actual needs.

I'm testing in deepth and the problem of the effect in the layer is that all the shadows will have the same properties, i can't set specific offset or opacity depending the zone on the lgame level, all is applied in the same way fo all them but is the unique form to get working correctly.

So, i guess the best solution for this is having a behaviour on a family that do the shadow on you can specify in which layer show the shadow and on you can set different variables for each sprite.
B
23
S
10
G
3
Posts: 538
Reputation: 4,426


Return to How do I....?

Who is online

Users browsing this forum: blackhornet, Hadyurik and 7 guests