Week 68: rendering shadows (Patreon)
Downloads
Content
I worked on shadows this week… yet another explorative task. Rendering shadows correctly is one of the biggest technical challenges still to solve in the game, as the levels are 2D and shadows tend to give away the 3D shape of objects. The solution I prototyped is based on shadow maps. The idea is to construct, for each (point-like) light source, a shadow map. This map is basically a table that tells how far a light ray departing from that source travels before hitting the first object, for all possible directions (angles). So I wrote some C++ code that takes a level from the game and spits out the shadow map. It took me 1.5 days to do that, half coding and half debugging. I could then produce the plot below:
Which looks more meaningful once you plot it in polar coordinates:
I incorporated this in the game engine, which took a couple of more days and required adding a bunch of extra functionality to manipulate floating-point images. I wasn’t very happy with the final result, though. It showed a number of artifacts. A bit depressed, I continued working on this stuff. In particular, I added some hacky code to update the shadow maps when the doors close. The idea is to project the silhouette of the door (a bunch of segments) into the shadow map. I attached a video that shows the final result.
I also took the chance to adjust some lighting parameters. This made the whole thing look a bit better and alleviated my initial depression a bit.
Overall this was a useful experiment. It gave me a better idea of the amount of work I still need to do on the rendering code. But I will now move to adding more content and gameplay, rather than continuing working on graphisc problems. I think it is wise to work in “passes”: one week on sounds, one week on rendering, one week on gameplay, … and then cycle again.