How do I pixel perfect shadows for animated sprites

0 favourites
  • 10 posts
From the Asset Store
Particles support animations, collisions, effects and etc.
  • 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:

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

  • 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. <img src="{SMILIES_PATH}/icon_razz.gif" alt=":P" title="Razz">

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

  • 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. <img src="{SMILIES_PATH}/icon_razz.gif" alt=":P" title="Razz">

    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?

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

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

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

  • Just updated the capx... But shinkan's shader looks amazing and require no events whatsoever. Seems like the choice is easy.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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

  • Thanks for the reply guys!

    shinkan Yes i requested a shader like that to Gigatron that did this one:

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

    ---

    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.

  • 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

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

  • shinkan Thanks i will download too, never knows!

    ---

    Magistross Then thats why my one was a mess XD, because seems is impossible . 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.

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