I'm making a game where the game's size varies, so I want to make my own shadows. The api i'm using can fill rectangles, make ellipses, horizontal lines etc. And supports rgba. Given this, how could I make a drop shadow? I tried making a black to white gradient and setting the alpha to 20%, but it didnt look very good... I'm not sure how they are done. Thanks
+2
A:
I would suggest:
- copy the object,
- move it in the opposite direction of the light source and use its distance as a weight,
- turn it totally black,
- blur it using the light source's distance as a weight, too,
- put it behind the object,
- lower the alpha if you want.
- ?????
- profit.
Camilo Martin
2009-12-18 05:10:33
And use a multiplying blend mode, if you have the choice.
Mark Ransom
2009-12-18 05:13:20
multiplying is a photoshop thing that is not easy to implement, in fact it can be very expensive CPU-wise if badly implemented since you have to deal with pixel calculation.
Camilo Martin
2009-12-18 05:51:35
@Camilo: A lot of APIs that do multiply blending (such as Cairo and OpenGL) push it to the graphics card whenever possible, and implementations tend to be quite fast.
greyfade
2009-12-18 07:29:05
Oh, I was thinking it the brain-dead way :) But those APIs also must have some useful shadow effect or at least make it trivial to implement, right?
Camilo Martin
2009-12-18 08:38:51