I have a list of points that make up a polygon. I would like to know if there's an easy way to generate a shadow for this polygon in 2d, assuming there is only one light that's very far away. I have tried many methods, and even tried writing my own algorithm, but had limited success. I want to achieve an effect similar to this image: https://i.stack.imgur.com/0epC0.png or in other words, similar to the feMorphology filter in SVG.
Asked
Active
Viewed 91 times
1
-
1Doesn't this http://stackoverflow.com/questions/6088409/svg-drop-shadow-using-css3 answer your question? – Robert Longson Aug 12 '14 at 08:03
-
It's not going to be used on the web or SVG, but on a simple 2d game engine I am making. For performance reasons, I need to precalculate these shadows beforehand. – Ermir Aug 12 '14 at 08:26
-
1The algorithms for SVG filters are in the SVG specification. – Robert Longson Aug 12 '14 at 08:32
-
Google "webgl javascript library", have a number of javascript 3d and 2d library already written. – Alvin K. Aug 12 '14 at 15:50
-
1Your example is not a normal drop shadow, it is a 3D extrusion. Filters or feMorphology won't help you, you'll have to do some hard math. – Michael Mullany Aug 12 '14 at 16:11