Wednesday, 27 August 2008

Ray tracing defined

For some of you guys who still don't quite get the concept of ray-tracing, it's basically a rendering technique, ie, a way to draw stuff onto your screen.

The good thing about ray-tracing is that it produces photo-realistic images, but requires a lot of computation. So, it's not suitable for games, since it'll lower down the frame rate, thus causing jerky video. However, there are some people out there that are willing to tackle this problem, for example, the OpenRT project. Even so, the computer nowadays aren't quite fast enough to do real-time ray tracing.

But what is ray-tracing, really? Is it some kind of hard-to-understand rocket science? No. Actually, it's all mathematics. Before you actually get started with ray-tracing, you should know what are:
  • Vectors
  • the 3D Cartesian Plane
  • Linear, Quadratic and higher degree equations
  • your basic operations, +, -, x, /, and all those stuff
Actually, you need to know a couple more than those listed above. you got to know how to program as well. If not, how are you supposed to program a ray-tracer? But don't let the list of requirements intimidate you. If you want to learn about ray-tracing as well, you should get started by now. I've been programming for 3 years already, so I could say I'm more of an intermediate programmer now. Even so, I still need to refer to tutorials. It has already became a passion, so it's easy for me to follow. And for the maths? Well, I've been learning quite "advanced" maths since standard 5, and I've got experience with Vectors and Algebra already, so it shouldn't be much of a problem. Well, I'm not trying to brag or anything.

I've also got exposed to Vectors when learning how to make 3D games. But anyway, if you wanna start learning about ray tracing and programming, it's never too late.

So, let's get back to the main topic, what's ray tracing actually? Ray tracing, as the name implies, is tracing the light rays that enters our eyes, in this case, the camera that is viewing the virtual world. In the real world, we see things because light reflects off the objects around us and enters our eyes.

In ray tracing, normally, we trace the light rays backwards, ie, from the camera, back to the light source. And since light can be refracted and reflected, ray tracing is a good way to create stunning effects by using the properties of light that we all know. Now, how does this work?

Imagine there is a viewpoint (the camera, or the eye) at one side, and a screen in front of it. The resulting image will be projected onto that screen. First, a ray is fired from the viewpoint to one of the pixels on the screen. This ray will keep going straight until it intersects with an object in the virtual world. The colour at the point of intersection is then returned and placed at that pixel. For more complicated ray tracing, if reflection and refraction is incorporated, then more rays are fired from the point of intersection to other parts of the virtual world. The colour of the pixel of the screen that has the ray fired through it will then be calculated. After all that, it'll move on to the next pixel, and so on, and so on. I know it sounds complicated, so it's best describe with pictures. Unfortunately, I'm not a good artist, so you've got to google it up.

And that's about ray tracing.
-----------------------------------------
Now, let's get on to what happened today. Today, I went marching. It's actually for Hari Kemerdekaan. I know, I'm not really a marcher, but then, I just wanna at least participate in something for scouts, since I rarely do so. I actually find it a little fun. Odd, right? But then, I got to work on my arm swing. It seems that my arm is a little bent while swinging. So, that's it!!

1 comments:

Tenyume Kasumi said...

Wow... You know how to program... Whereas, I don't know a shit about even HTML. XD