Index |
Raytracing |
Tutorials |
Gallery |
Source Files |
Links |
|
The image that we see of the world is mostly formed by light reflected by objects. To generate realistic images on a computer, this reflection as it occurs in nature can be simulated. One of the techniques used for this is called raytracing. Raytracing can be seen as a computermodel or -simulation of how we see the world around us, for which the goal is to create photorealistic 3D images. To understand and design a model like this, it is useful to study reality first. |
|
|
In reality, the sun emits millions of light rays; a fraction of these rays hits our planet after a long journey through space and a very small part of that hits an object that we're looking at. For example, the object we're looking at is a blue box. Because of the physical properties of the box, all non-blue light is absorbed and only the blue part is reflected. Some of these reflected light rays finally reach our eyes and form an image of the blue box on our retina (see pic. 1a). |
![]() |
|
This model of reality, where light rays are being followed, is called forward tracing. To build a model like this on a computer might seem simple, for we only need to define the location of an object, a light source and a camera (an alternative for the eye).Then the computer can calculate the path of the light rays and give a pixel on the screen a certain color, in case a ray hits the camera. Simple, isn't it? Unfortunately, there is a slight problem concerning this method: the major part of the simulated light rays will never reach the camera, while tracing the rays will take an endless amount of time. | |
|
Now, let's turn the whole thing around. What if we don't trace the rays coming from the light source, but instead follow the 'viewing rays' from the camera until we hit an object? Picture 1b displays such a back tracing model. From a so-called projection point, the viewing rays are being shot at the virtual outside world through a virtual screen. Each viewing ray corresponds with a certain point (pixel) on the screen. If the ray hits an object, the pixel gets a color (in case we're still watching the blue box, it will be blue); if it doesn't, it will be black. This process is repeated for every pixel on the screen (for example, for an image with a resolution of 800x600 pixels, 'only' 480.000 rays need to be shot). The result of this method is shown in pic. 2a. |
![]() |
![]() PICTURE 2A: A box without shadow. |
![]() PICTURE 2B: A box with shadow. |
![]() PICTURE 2C: A box with shadow and ambient light. |
|
Well, this isn't a sensational result. The main reason for that is the lack of shadow. Calculating shadow in the back-tracing model isn't too difficult, though. The only thing thing the computer has to check when a viewing ray hits an object is whether a light source is visible from that point. If a light source is visible, the pixel is colored, else it remains black (pic. 2b). For some extra realism, we need some ambient light. See pic. 2c for the result. |
|
Apart from shadows, objects can have many other characteristic features, like highlights or reflections for shiny or polished objects. The difference between the characteristics of different materials is clearly visible in pictures 3a to 3c. The principle of reflection is based on the physics law: the angle of reflection is the same as the angle at which the light is hitting the object (viewed from the surface normal). |
![]() PICTURE 3A: A dull sphere. |
![]() PICTURE 3B: A shiny sphere. |
![]() PICTURE 3C: A shiny sphere with reflection. |
|
The only other thing we need now to create a realistic 3D image is some depth. Objects that are far away need to be smaller than objects that are nearby. To accomplish this, raytracing needs nothing extra besides the model already shown in pic. 1b. The computer simulates depth by forming an image of the virtual world (the scene) in a way displayed in pic. 4. The red and green parts of the screen show the height of the objects A and B in the formed image. |
![]() |
|
Now, knowing all this theory isn't really necessary to create magnificent pictures in POV-Ray, but it might help you understand what you're actually doing when you're building a scene. Knowledge isn't everything, but it sure is useful now and then! If you want to know more about POV and you're a beginner: there are many tutorials available on the web and the POV documentation is an excellent resource as well. If you've already done some renderings, you might want to take a look at my advanced tutorials. | |