In this part we will deal with HDR imaging and advanced lighting support for ray tracer. Until this week, we dealt with images that has color between 0 and 255. Also, pixel colors were integers. Thus, in the images, we couldn't get the realistic images. Colors were different from the real world. This week, firstly I will start with HDR imaging, then I will add advanced lighting support.
To get the HDR Image we don't clamp or round colors. What we get at the end of the ray trace is our pixel color. When we save it as exr we get the HDR image. However, our display devices(most of us) can't display these pictures. To do that we need to apply tone mapping. Tone mapping is a technique that maps large colors to 0 to 255 range.
In this picture we have a point light. Some parts are too light and some parts are too dark. If we apply tone mapping to this picture, we will get :
In this Light we have an angle. This angle represent the how much space that we illuminate. In here we have three different area. first one is outside of coverage angle. In this area there is no light contribution.
Actually, in this part I fix many bugs. You can see the errors. In the first error I couldn't understand the error source. It looks interesting. I can be about memory management (I don't know how I solved it).
Cube point light HDR tone mapped (Render time :0.15s)
We can see that we have smoother transitions in here.HDR image link.This Image looks more realistic because when we have a powerful light, around of the llight looks brighter. It is not like the first picture.
In this part I dealt with many errors because it is the first example of this homework. In tone mapping I fix many bugs. I added degamma to fix material colors. Many times I got brighter pictures because I misused this formula :
After I calculate L_d(x,y), I convert hdr images to png format I used. this formula : toneMappedColor = power( power(color, saturation) * L_d(x,y) , gamma)
This example is about reading an exr texture file.HDR image link
Firstly we read a texture from an exr file, then we apply it to a sphere. All other features were from the older parts.
Now, we can talk about the different lightinings. In previous weeks, we use only point lights. In this part we will add four different lights:
- Directional lights
- Spot lights
- Area lights
- Environment lights
Directional lights
This light is very common in the real games. It is like sun light. We have a very powerful light far away.
In the calculation we used radiance and direction. Radiance and direction are constant for every object.
(Render time :0.15 s)
In this light we can think like that every point has the same distance to the light. Thus every point gets the same light contribution.
Spot lights
Second area is between fall of and coverage angle. In this area light contribution is exists. It decreases very fast if you go to coverage angle. Third area is in the between 0 and falloff angle. In this area light contribution is high and depends on the distance.
(Render time :20 second)
Area Light
In area light, we use random points to enlighten. After we choose a random point, we have steps similar to point light. In this part I dealt with interesting errors. Firstly I will share these errors.
Correct Result (Render time :0.2s)
Second error also looks interesting. This is related to cos value between light direction and normal. You should take absolute value of cosine.
Fourth error is about the calculations. Before I fixed that error, I got random values between -0.5 and 0.5.
Then, I tried to get values between 0 and 1 and I subtracted 0.5 and problem fixed. However, I don't understand what is the difference.
Enviroment Light
To get this light we use random vectors. If it is in the unit hemi sphere , we accept the light vector.Then we calculate texture coordinates. After that we use texture color as light contribution. In this part I had many errors and steps. Firstly I misread exr textures. It was new feature. I fixed that. Than there is another mistake in the man. Actually, In this part I want to show the process. First iterations I worked on low sampling rates not to spend too much time. Firstly I rendered the man. After that I tried to get enviroment lightining. Then, fixed the reading of exr. Then, I switched it to left handed system.
Yorumlar
Yorum Gönder