Shop Mobile More Submit  Join Login
A shadow generator I've been working on as part of a new game concept. Makes a nice visual effect and could introduce interesting gameplay mechanics..

HOW IT WORKS:
The way this creates a shadow for a shape is by drawing a quadrilateral for each pair of neighbouring vertices A and B in the shape. This quadrilateral is created by casting a line from the light source to vertices A and B and then onwards for (x) pixels to points C and D. A, B, C and D then form the 4 points of the shadow quadrilateral for that pair of vertices. Do this for each pair of neighbouring vertices in each shape and you have a shadow shape!

I went on further to make it so that rather than drawing the shadow, it uses the shadow shape to cut away at a 'light' image (a yellow radial filled circle in this case). This is achieved by setting the shadow shape's blend mode to 'erase' and putting it on top of the 'light' image. Now, the shadow isn't rendered, but it erases the image below it, giving the effect that the shapes are shadowing the 'light' image.
Add a Comment:
 
:icontherelentlessvoid:
TheRelentlessVoid Featured By Owner Jan 11, 2012  Hobbyist Digital Artist
Mind sharing the source? i've been looking everywhere for something like this, and an in the progress of designing one, but it's more than hard.
Reply
:iconjorjeade:
JorjEade Featured By Owner Feb 1, 2012
Mind showing your version? I'd rather not hand out the source, but I'd be more than happy to discuss techniques. (Updated description ^)
Reply
:icontherelentlessvoid:
TheRelentlessVoid Featured By Owner Feb 1, 2012  Hobbyist Digital Artist
I'd love to when i get it working, right now it's just a pile of classes. ( i've been pretty busy with other things ) I guess my first step from where i am currently would to be making a debug draw. Thanks for explaining how it works by the way, it's a lot faster than the way i was trying to do it. ( casting every line through every other line to find its closest distance. ( a LOT of trig functions. I ended up having to use the taylor series with > 40 vertices. )
Reply
:iconshepherdspie:
ShepherdsPie Featured By Owner Jan 10, 2012
nice!
I'm wondering, when you move the light to the inside of the walls, there's that subtle few pixels where the shadow wipes away. Is that intentional or just a byproduct of the engine?

Now if you could get a functioning bump map on that ground...
That would blow my mind!
Reply
:iconjorjeade:
JorjEade Featured By Owner Feb 1, 2012
Just an artifact or the engine really, I guess it should just turn off the light at the point it goes inside the wall because technically at that point the light source is embedded in it. Collision detection would remove this though I guess.

Hm, bump mapping...
Reply
:iconshepherdspie:
ShepherdsPie Featured By Owner Feb 1, 2012
you could do bump mapping by having 4 or 5 ground images with the light source at the 4 different angles and maybe 1 of the light coming straight down, then have it cycle between them depending on the location of the mouse. It could be a lot easier since the map doesn't move. I might even be able to use my 3D modeling to help with that!

The 'artifact' would be fine if the light source was supposed to be just barely above the walls.

And finally,
If you want to implement this into a game, here's an idea;
You're helping dogs escape from the pound (or some silly large dog prison with lots of guards, watchtowers, etc.)
leading them with your lamp. But you can't shine your light on the guards, or let them see the dogs. That or, the guards are holding lamps and you have to avoid the light.

I just had all the details of that game design pop into my head, so let me know if you actually want to try it and I'll share the rest of my ideas... ~_~
Reply
:icontherelentlessvoid:
TheRelentlessVoid Featured By Owner Feb 1, 2012  Hobbyist Digital Artist
When you're at the point of bump mapping, you might swell use stage3d to implement lights.
Reply
:iconshepherdspie:
ShepherdsPie Featured By Owner Feb 1, 2012
It's about the problem solving. It's like asking "Why paint a painting when there's Photoshop brushstroke filters..?"

That's what it's about for me anyways...
Reply
:iconjorjeade:
JorjEade Featured By Owner Feb 2, 2012
Exactly. If we wanted to make *real* games we'd ditch flash and use a language like c++, but the point of flash is seeing what can be done with limited technology. Like you say, we enjoy solving problems, not using other people's solutions.
Reply
:icontherelentlessvoid:
TheRelentlessVoid Featured By Owner Feb 1, 2012  Hobbyist Digital Artist
I mean i understand that, it's just that we're limited by the speed of the AS3 VM.
Reply
Add a Comment:
 
×




Details

Submitted on
January 10, 2012
Image Size
96.6 KB
Resolution
800×600
Link
Thumb
Embed

Stats

Views
508
Favourites
4 (who?)
Comments
10
Downloads
8
×