The Sweet Sweet Sounds of Radio-City
Be it in films, visual arts or computer games, photorealistic rendering of a virtual scene has been a hot topic for decades. The ultimate aim of my project is to create a photorealistic render of a simple scene like the one shown above using what’s known as radiosity. Let’s dive into a brief introduction to the whole thing.
Rend ‘er? I ‘ardly Know ‘er!
So what is rendering? Well, stored in the computer is only the description of the geometry. For the box shown below, only the location of the faces are stored. Rendering is simply the process of turning that description of geometry into an actual image you can see. Boom.
The standard way to render a scene is to choose a virtual camera position, take the geometry that the virtual camera is “seeing” and draw it to the screen. For a simple box, ignoring perspective, that looks like this.
Using perspective to make the box appear like it would in the real world look like this.
What about colour? Simply drawing solid colours looks a little strange, see?
What we really want is to be able to add a virtual light to the scene and give the box some kind of shading. Adding a light behind the camera produces this kind of image.
So What About the Rad Sounds of Radio-City?
The shading used for that last image uses a simple method called Gouraud shading. It’s straightforward and effective but all it does is calculate how much each bit of the geometry is directly affected by each light in the scene. Take a look at the room shown on the first picture, there’s only one light, a white light, and yet the box on the left is coloured a little bit red because of the red wall. Here we have a case of light bouncing off one object and affecting another and Gouraud shading doesn’t (easily) take into account. So, we turn to radiosity.
To give a quick definition, radiosity is simply a measure of how much light a little patch of a virtual scene is giving off. This amount of light produced is dependent on two things, how much light is hitting the patch and bouncing off, and how much light the patch itself is emitting. We use this to render a scene by considering how the light given off by each patch in a scene affects every other patch, taking into account how it bounces around the space. We can then properly colour a scene using the calculated radiosity.
And How Can I Tune In to The Visual Nectar That is Radio-City?
Calculating the radiosity of each patch in a scene comes in two parts. Firstly, the spatial relationship between any two patches must be found, this is called the form factor. It basically describes how much one patch can “see” another patch. If two patches are very far away from one another, the form factor between them will be very small, if they’re very close the form factor will be much bigger. If one patch can’t be seen at all from another patch, the form factor will be zero.
The second part comes here. With the form factors known, we can build a large linear system of equations in the form of a matrix equation that relates the outgoing radiosity of any one patch to the incoming radiosity from every other patch. By solving this equation we find the radiosity. Almost as simple as getting your car insurance through comparethemarket.com genericinsurance.com!
But How Can I Make My Own Radio-City?
A few different techniques and algorithms are used in the process of calculating radiosity. In order to calculate the form factors, a model-view-projection transformation must be set up, this allows the placement of a virtual camera on a patch in order to see which other patches that patch “sees”.
This transformation is used to project the geometry onto a half-cube sticking out of the patch (this is known as the hemi-cube approximation).
A z-buffer algorithm is then used to sort which patches are in front of other patches and then measure how much area the projection of each of the closest patches covers on the half-cube. This area is equivalent to the form factor.
Calculating the radiosity from the form factors can be done using numerical techniques for solving matrix equations but this requires the storage of n-squared numbers for n patches in the scene, which can end up being a massive amount of numbers, and a massive amount of memory, for complex scenes.
We can alternatively use a technique known as progressive refinement. This is where instead of finding out the radiosity of every patch at one time, the radiosity of a single patch is estimated based on approximate radiosity levels currently known in the scene and then we project that patch into the scene as if it were a kind of light. This process is repeated over the patches until the radiosity for the whole scene gets as close as we want to the true values.
And that’s all she wrote.
Dublin Though, Must Be Tough.
Seriously though, this city is wonderful. The people are as Irish as I was expecting, which is brilliant. There are parks everywhere, nice coffee places around every corner, a plethora of dynamite folk and traditional music happening in at least one bar on every street and to top it all off <suckup>I’ve been working with a bunch of pretty damn great folk at ICHEC </suckup, please offer me a job>. I’ve managed to get to at least a hundred pubs, Dublin Maker (an art/design/technology fair), the National Botanics, the National Gallery, the Natural History Museum (aka the Dead Zoo), a cinema to see the new Spiderman (pretty good, I give it 3.5 out of 5 parallel processes) and even Galway for a few days (didn’t find a Galway girl…). On top of that I managed to see a high speed chase down one of the main streets of Dublin AND I got to play the fiddle of possibly the nicest guy in trad, Cormac, the fiddler from Lankum, check them out below.
Keep it reel, folks.