Friday, October 30, 2009

Shadow Boxer

I've been chatting recently with The Ron about doing some computer stuff with the art. Mostly I had the idea to do some kinds of simple transparency. Nothing too fancy, or making use of alpha channels or anything like that, just some basic color modification.
What this led to was the idea of using a Shadow Map - another image that would display the differences in light, where beams of light are and where light sources are. This could then be compared with the normal screen render and a new lit up version of the screen would be spawned.
Thinking about it further, I concluded that this Shadow Map could be animated. By drawing things onto that screen and averaging the tints, I could get the lights to move and animate. I just need to run the color average function again for each time I add an item.
This seemed like a good idea at the time.

So when I got home, armed with proof of concept art and pseudocode, I got cracking and about 10 minutes later I'd gotten a basic color averaging schema scheming. A bright red box plus a bright blue box gives me a purple box with the same absolute brightness value (which would appear the same gray color if in gray scale). So, that was pretty cool.

With that out of the way, I got to the next part. I built another screenbuffer and drew a great big rectangle on it. I think I made it green. Then I built a loop that checked the color of each pixel on each and added the color averaging function. Then I told it to draw it out and...nothing. That's not quite right, there was something, but it was, and I'll add emphasis, soooo...fuggin....ssloooooowwwww. Like old people dropping a deuce only with slightly less blood.
So I spent the next hour trying to figure out the why of it. I tried alternate functions, alternate methods all to zero avail. The stupid thing is, according to the design of the shadow map software that needs to run about 5-6 times per frame. Instead it runs 1 frame per 15 seconds which is unplayable by every stretch of the imagination.
Granted, there are ways to make the basic pieces quicker. I don't need to run the whole screen every time I add something, just the parts the image is touching. So I think that it may go faster with images drawn to the shadow map. But no matter what, the whole screen does have to be drawn eventually. I'll give it a little more effort and see what happens. Hopefully speed.

No comments: