Wednesday, November 21, 2012

Game-off: Day 19

This morning I fixed the problem with the negative shadows. I decided to replace the clipping region with a back buffer that draws the gradient and then subtracts the shadows (using globalCompositeOperation). It fixes the bug and allows multiple light sources. Performance starts to drop in iPhone 4S when a second light source is added.

The second thing to fix is choosing the correct vertices to project the shadows from. I think the best way to do that might involve voronoi regions, but it still won't solve all cases.

A second idea is calculating the angle between the light source and each vertex in the shape. Recording the min and max of each. For more accuracy, I will have to use the radius of the light source instead of its center of mass. That's something I haven't really thought about.

No comments: