Introducing my first offline renderer.

Haha, first post! Today, I am going to introduce Photon, a simple piece of software which main function is to draw pictures. It is written in Java from scratch by me. Technically, Photon is a physically-based Monte-Carlo path tracer for light transport simulation. Scary name, huh? No worries! I will go through this later. Here are some pictures generated by Photon:

image rendered by photon
Lamborghini car model from TF3DM.com
image rendered by photon
dragon model from Stanford University Computer Graphics Laboratory
image rendered by photon
Sponza model by Crytek; (sorry I forget where the cups were downloaded from, probably TF3DM.com)

These pictures are much more realistic than ordinary game graphics (hope you think so too). The reason behind it is that game graphics often lack of something called “global illumination.” To understand what global illumination is, let us first talk about direct illumination. Imagining light as hundreds of thousands of small light particles emitting from a white bulb on the ceiling in a room, once they hit an object, they bounce off from that object and reach your retina so that you can see it. This is how an object would be lit by the bulb in most video games. Notice that the particles only bounced once before reaching your eyes, and what you are seeing currently is called direct illumination (or direct lighting).

image rendered by photon
single bounce lighting, rendered by Photon-v2, most video games do this

But this is not how real world works. If the wall of the room is painted green and the floor is in white, you would see that the floor is tinted green. It is because in real-life, light particles not just bounced once; when they bounce off from an object, they keep traveling in the room until another object is hit, and they bounce off from that object, and they keep traveling… till reaching your retina. This is called global illumination. Every time a light particle bounces, some portion of its energy is absorbed by the object (e.g., green wall is green because green paint absorbed red and blue energy from the light particle). So here is the real-life scenario:

  1. Light particles emit from the white bulb and hit the green wall. All particles were white before hitting anything.
  2. All colors except green are absorbed by the wall, and some of the particles bounced off from it hit the floor later.
  3. The particles are green now. No colors are absorbed by the floor since it is white, and some of the particles bounced off from it reach your eyes.
  4. Your retina picks up the light information from the particles. They are green, so you can see that the floor is greenish.
image rendered by photon
infinite bounces lighting, rendered by Photon-v2

This is a recursive process where a light particle can bounce infinite amount of times. If we can simulate this on a computer, generating life-like images will not be a dream anymore. Remember the aforementioned scary name “physically-based Monte-Carlo path tracer”? Photon tries to simulate the real, physical world hence the “physically-based” term, where “path tracer” means tracing light particles’ path like the above example. And the core numerical method used by Photon to solve the recursive light particle bouncing problem is Monte-Carlo integration.

Many people wrote tutorials or blog posts about these lighting simulation stuff. Since I had no experiences on this before, I googled a lot and wrote Photon as an exercise to see if I have picked up what I read correctly. Sadly, I am not developing Photon anymore, but the good news is I have started another project called Photon-v2, the second version of Photon, which is actively being developed. Stay tuned!

The complete engine source is here: [Source Code]