2D Instant Radiosity

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.

Radiosity

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.

RadiosityNoiseLow

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.

One thought on “2D Instant Radiosity

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s