## Introduction:

Hi guys!

I have not written anything here since a long time, I had exams, professional mission in C++ with Qt and too many things to do. Don’t be afraid, activities in this blog will be start again soon.

In computer graphics, I didn’t do beautiful things, except a little ray tracer with photon mapping. I’m going to explain how to make a little photon mapper. Firstly, we’ll see the it on the CPU side, after we’ll try to implement it in the GPU side.

We will see several points :

- Explanations about rendering equations
- A raytracer
- A photon mapper
- A GPU side with Photons Volume

Perhaps, some chapters will be divided into several parts.

## Rendering Equation :

Source : Wikipedia Scheme relating to the equation

The rendering equation is :

### What is it burried into this equation?

- is the outgoing radiance. It will be our pixel color in R, G, B space. It is exprimed in .
- is the emmited radiance. It should be zero for almost all materials, excepting those that emit light (fluorescent material or lights for examples).
- is the Bidirectional Reflectance Distribution Function(aka BRDF). It defines how light is reflected on surface point . It is exprimed in . Its integral over should be inferior or equal to one.
- is the incoming radiance. It is like the light received by in a direct or indirect way.
- is the lambert cosine law.
- is the differential solid angle. It is exprimed in .
- is differential irradiance. It is the radiant flux (or power) received by a surface per unit area. It is exprimed in .
- is the radiant flux(or power) passing from and have for direction . It could be seen as one of our photons. It is exprimed in R, G, B space as well. It is exprimed in .
- is the area which received the radiant power.

### Manipulate rendering equation for an approximation

This part is going to be a bit mathematical with « physical approximation 😀 ».

#### Simplification of irradiance

Zack Waters : Irradiance and flux.

Assuming the « floor » of the hemisphere is flat and photon hitting this floor is like hit , we have :

.

So, to have a better approximation, you must have to reduce the hemisphere’s radius and increase the photons number.

#### The rendering equation simplified

### Direct Illumination

Direct illumination need an accurate quality, so, we will not use the simplified equation seen above but the real one. The main difficulty is to compute the solid angle. For example, a point light with power :

We remind that with the solid angle.

### Photon tracing, reflection and refractions

The photon tracing is easy. Imagine you have a 1000W lamp, and you want to share all of its power into 1 000 photons, each photon should have a 1W power (We could say the colour of this photon is (1.0, 1.0, 1.0) in RGB normalized space). When photon hit a surface, you store it into the photon maps and reflect it with the BRDF :).

If you didn’t get it all, don’t be afraid, in our futur implementation, we are going to see how it works. We will probably not do any optimization, but it should be good :).

Bye my friends 🙂 !