2D Casting Shadows?

Wondering how to accomplish a certain animation task? Ask here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
KickAsd
Posts: 2
Joined: Tue Sep 23, 2014 6:41 am

2D Casting Shadows?

Post by KickAsd »

Hi everyone,
I'd like to know the best strategy (if there is one) to get a 2D casting shadows effect, like this:
https://www.youtube.com/watch?v=7BBDP43SXkA
https://www.youtube.com/watch?v=UN1pyFVRed4
User avatar
hayasidist
Posts: 3834
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: 2D Casting Shadows?

Post by hayasidist »

what I'd do is masking. The examples you've shown do a run-time calculation using the position of the "light" to work out where the "mask" needs to be. AS could do this at run-time (layer scripts) but, IMO, it's a waste of effort to program that in LUA (and it'll almost certainly slug performance).

A quick test here achieves the desired result for the "simpler" example you posted - the light moving though "closed" shapes into an "outside" (but I haven't gone into the finer points of this such as reflectivity of walls etc). The following is the set-up:

vector layer - fixed walls
group layer - masking set to hide all
> vector light source (radial gradient filled circle, white to transparent) - mask this layer
> shadow area masking zones - subtract from mask - there may be lots of these - these are areas that are in shadow - use point motion animation to change the shape of these as the light source moves and/or just turn visibility on/off. Note that you can't "subtract" an area unless there's an "add" covering the area lower down the stack
> lit area masking zones - add to mask - there may be lots of these - these are areas that are lit - use point motion animation to change the shape of these as the light source moves and/or just turn visibility on/off

In short, you do the work at "animate time" that the maths would do at render time to decide where the shadow lines are.

((You can build more complex masking solutions - e.g. having groups to create masks by adding and subtracting vectors - and this would be what I'd use in the second example (the one with lots of shapes) you posted. ask if you're interested.))
o0Ampy0o
Posts: 62
Joined: Fri Jul 18, 2014 6:01 am

Re: 2D Casting Shadows?

Post by o0Ampy0o »

You could come close to these examples using one of a few simple and inexpensive 3D programs. A Photoshop type of program that handles 3D objects could do it. The main difference between the two examples is soft-edged shadows vs. hard edged. IMO a 2D animation program is not the way to go. I do not believe accurate shadows are important enough to cartoon animators where they are usually treated with a stylized effect that at least communicates the idea of shadow in rudimentary form so the technology does not support true to life shadow effects.
KickAsd
Posts: 2
Joined: Tue Sep 23, 2014 6:41 am

Re: 2D Casting Shadows?

Post by KickAsd »

Thank you guys.
The goal I want to achieve, is to show the gameplay of a 2D game that I'd like to develop in future.
So the soft-edged shadows vs. hard edged, is not a problem.
For a quick demo, of course it should be more simpler by simulating how the shadow casting works, instead of programming it from scratch.
I think the hayasidist's approach should work: I have to create some masking and move manually the shadows, instead to move them via algorithms.

However I'm open to any other suggestion :)
User avatar
hayasidist
Posts: 3834
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: 2D Casting Shadows?

Post by hayasidist »

if necessary you can get soft edge shadows in AS by having soft edges on the shadow masks... of course you'll need to take that into consideration when designing and positioning the base masking shapes
Post Reply