Since I am experimenting with my new ray casting code, I decided it might be worth trying to implement a 2D version of the instant radiosity algorithm. The results are very pretty.
The strategy is really simple. From the light source, you cast out rays in several directions, and store the intersection points. In the above capture, there was 64 of these points, but its more reasonable to have less, since there is an big performance penalty the more you have. The next step is to iterate over all the tiles on the map performing a ray cast from the center of the tile, to each of these initial sample points that we captured. The percentage of hits we gather determines the brightness of the tile, the more unblocked ray casts then the brighter the tile. Simple as that.
An unfortunate aspect of the vanilla algorithm is that it produces many noticeable blocky artifact which can be quite off putting to the overall effect. A solution I propose to this problem is to add jitter into the algorithm. For each of the ray casts from a tile to one of the irradiance samples we add noise to the position of the irradiance sample. This noise actually improves the overall accuracy of the algorithm which is a strange phenomenon. It also looks much more pleasing to the eye in my opinion.
Could you please release the source? I would love to check it out