联系
Knight's Tale » 技术

Approximately Realistic Rendering using Ray Tracing

2009-03-28 00:00

It’s really a pity that I havnt’ done any things for almost three months. :( However, I focus on the realistic and the real time rendering on graphics these days. And luckily, I have implemented a nice demo for this realistic rendering purpose using ray tracing .

As we all know, one of the most sought-for goals in computer graphics is to generate “realism in real time”, ie. The generation of realistically looking images at realtime frame rates. Using ray tracing algorithm in triangle rasterization is well-known for its higher in both model size and computer power. However, ray tracing is also computationally demanding and thus so far is used almost exclusively for high-quality offline rendering tasks.

Originally, I want to finish this task with GPU(HLSL code). Afterwards, I give up this way for two reasons: first is that the ray tracing algorithm code is so complexity on CPU, not to mention about GPU. The other reason is that I am not familiar with HLSL(DirectX) or GLSL(OpenGL), I have to spend more time to learn GPU code and It’s hard for me to write perfect code in a short time.

I also want to implement this goal with CUDA acceleration. But I also give up this idea for the same reaosn as GPU.

So, I implement the ray tracing algorithm on todays commodity CPUs. My demo has several features as follows:

1. Implement Phone Lighting.(include ambient, diffuse, specular, transmissive)
2. Support OBJ file format.
3. Support Material from MTL file.
4. Support Global illumination.
5. Support reflection and refracion.
6. Use Phone Shading to smooth the model.
7. Support Distance attenuation, spotlight for light. And one more lights are nice.
8. Support parallelogram and triangle mesh.
9. Support simple texture mapping. ( texture from .bmp file)
10. Support generating .bmp file while rendering.
11. Use Kd - Tree constructor acceleration .( referenced in book <>.)

One of the scene rendered by my RayTracing System is :

As we can see in the image above, there are 16616 vertexs and 30753 faces in this secne, and it takes about 5.236 seconds to construct KD tree and 1.827 seconds to complete the rendering.

It takes so few time to complete!!

Yes, you are right, My demo also support interactive rendering~ ( real time rendering)

we can rotate the camera direction real time to see different objects in the scene .

( real time rotate the camera to the right, and move the camera forward )

( real time rotate the camera to the left)

Why? Because when you rotate the camera , we don't have to reconstruction the scene KD tree, all we have to do is to travel the KD tree and find which objects is intersected with the ray. After this assignment, I will continue to update ray tracing project, because it 's intersecting to render any objects in the scene if you want to. :)

原文地址:http://knightliao.blogspot.jp/2009/03/approximately-real-time-realistic.html