Tutorial   improve your OpenFX skills... >>
  Scope   Tutorial... >>

<< Prev   [1]   [2]   [3]   Next >>

step 6 Step 6: Renderer Ray-Tracing Tab Page
The Tracing page of the Renderer enables Ray Trace rendering to be used. Turning on any of the Tracing options instructs the Renderer to use ray tracing where appropriate. Note: These options and settings only apply to the Software Renderer.

Trace Shadows - All shadows will be ray traced, this increases the rendering time significantly..

Trace Reflections - All reflective surfaces will be ray traced, this also increases the rendering time.

Trace Glass - All glass surfaces will be ray traced, this included normal glass, like windows, as well as refractive glass.

Algorithm Parameters - Ray tracing a sene with 10,000 of polygons requires some optimisation to be undertaken before the scene is rendered. This is explained more fully in the section on "Setting the ray tracing parameters". There are no 'hard and fast' rules for chosing which approach to use. If you have a very complex scene then you may wish to increase the "Polygons per Voxel" setting. Up to 1000 polygons per voxel will still be acceptable if you have a scene with several hundred thousand polygons. It would be unwise to increase the Recursive depth beyond about 10 as this will hugely increase the amount of time it takes to optimise the scene before ray-tracing begins, and will also increase the amount of memory used to store the data.

To understand how to use the ray-tracing setting we need to explain a little of how Ray Tracing is optimised. Depending on what the scene is, one of these algorithmic approaches may work better.



step 7 Step 7: Status Information
The reported information in the status line of the renderer window can be very useful in making subsequent renderings of the same scene go faster.
  • F = (Number of faces in scene)
  • V = (Number of vertices in scene)
  • Dp = (Maximum octree depth used)
  • Th = (Target number of faces to be assigned per voxel)
  • F/V = (The maximum number of faces assigned by the optimisation algorithm per voxel)
  • Size = (The [maximum(and minimum)] dimension (in internal units) of any voxels created by the optimisation)
  • Vox = (Number of voxels created by the optimisation)
  • Fc = (Total number of face assignments made to voxels in the spatial subdivision)


Some of the terms used above may be unfamiliar to you but in order set the optimisation parameters you will need to understand these terms which arise in the standard ray tracing algorithm and how it is optimised to enable scenes with very large numbers of polygons (faces in the jargon) to be rendered.



step 8 Step8 Ray Tracing Basics:
Ray tracing may be a slow procedure but it does give superb photographic quality images. There are many books that describe the theory of ray tracing in detail. A full description of a complete package is given in [1] and there are also many available freeware and shareware ray tracing programs. One of the most comprehensive is POV-Ray which is available from a large number of WWW locations. The idea on which ray tracing is based seems almost too simple to be true but - here it is:

Follow the paths taken by particles of light (photons) on their journey from light source through the scene (as they are scattered back and forth between objects) and on until they are either captured by the camera or head off to infinity.

In practice this is a hopeless task because of the huge number of photons emitted by a light source and the fact that all but a minute fraction of them will ever be scattered into the camera or eye. So ray tracing does it in reverse. It sends feelers or rays along the path of the photos from the camera out into the scene. If the feeler rays find anything they work back towards the sources of illumination and give us a path for the photons to follow from source to photographic plate. Sometimes these feeler rays may encounter reflective surfaces and when that happens they follow a new path and continue their journey. There are lots of other things that can happen to feeler rays. Sometimes they may divide with each sub-ray following separate paths. The way in which the ray tracing algorithm handles such situations and the sophistication of the mathematical models it uses for light/surface interaction governs the quality of the images produced.

The standard algorithm for ray tracing can be summarised in five steps:
  • Load the data describing objects in the scene to memory.
  • Move each model into its appointed position.
  • Apply the viewing transformation.
  • Calculate the direction of a feeler ray from the viewpoint so that it passes through the point in the projection plane equivalent to a pixel in the display raster.
  • The feeler ray is followed (traced) out into the scene until it intersects a polygon. Once the point of intersection is located the surface properties can be determined and the pixel set to the appropriate colour value. If when a ray first hits something in the scene it isn't totally absorbed we can continue to trace its path until it reaches a final destination or is so attenuated that there is nothing to see.

So that's the basic algorithm, but if you have ever experimented with ray tracing software you probably found that at most you could use about 100 primitive shapes. Your main observation probably was the hours it took the computer to trace even an image of moderate resolution. What is worse is that the rendering time increases as the number of models in the scene increases thus if you need to render a scene with models made up from thousands of polygons a basic ray tracing renderer is virtually useless.

So the main question is: Why is ray tracing so much slower? The answer is in the algorithm, in particular the step: For each pixel test every polygon and find the one closest to the origin of the ray. This is potentially an enormous number of operations. For example to synthesize an image of size 640 by 480 using a 2 by 2 anti-aliasing supersample with a scene of 20,000 polygons requires 24 billion tests.

To try and reduce the time it takes to render a scene with a ray tracer some attempt must be made to try and reduce this enormous number of calculations. A technique we call optimisation.



step 9 Step 9: Ray Tracing Optimisation:
It is the job of an optimisation routine to divide the scene up in some way so that every ray does not have to be tested against every polygon. Optimisation usually requires two modification to the ray tracing algorithms:

A scene evaluation step that takes place before the scene is renderer. As each ray is traced the scene evaluation data is used to reduce the number of polygons that must be tested against it as the ray passes from point to point. There are two approaches that have received much investigation:
  • Bounding volumes
  • Spatial subdivision

    The renderer uses the spatial subdivision method and we will look at that.

    The idea here is to break up space into a number of small boxes so that only a few polygons actually lie in each little box. Then as the rays are traced through the scene we follow them from box to box and check to see if a ray hits any of the polygons lying inside the boxes. If there are only a few polygons in each box we will have considerably reduced the number of calculations and hence the time it takes to render a scene! Ideally putting only one or two polygons in each box (in technical terms the "boxes" are know as "voxels") should be the goal of the first part of the optimisation scheme. A two dimensional illustration of this principle is given below, it shows a collection of objects and a series of rectangles that divide up the region in which the objects lie so that so that only one object is in each little rectangle:

    It is the job of the first optimisation step (scene evaluation) to divide up the scene into the boxes to be used in the later tracing step. There are conflicting goals here, each voxel should have as few polygons (faces) inside them as possible. This implies that they should be small - but if there are too many boxes then the tracing step will not be very fast because as the ray is followed it will have to travel through a very large number of boxes. This is a "balancing act" - technical term "Optimisation". It requires quite a bit of processing to find the best arrangement of the voxels but since many hours of processor time might be saved during rendering it is usually well worth the effort. One comment worth making: The time it takes to optimise a scene is dependent on the number of polygons in the scene not on the number of pixels in the output picture. So it takes just as long to optimise a scene when rendering a 60 by 40 image as it does for a 1024 by 768 image. However it takes much much longer to trace the image for the larger raster. Thus here again is another very profitable reason to do the best possible job at optimising the scene prior to tracing any rays.



  • step 10 Step 10: Octrees
    The optimisation step starts by calculating the volume of space occupied by all the faces in the scene to create a bounding box to enclose all the faces in the scene (the so called root node in the octree). If this box contains more than the minimum number of faces it is divided into 8 smaller volumes. These child volumes are checked and any faces assigned to the parent and also fall inside them are put into to a list for each child. If any child box contains more than the minimum number of faces it is further subdivided into 8 sub-volumes, just as its parent's box was. This process is recursive and gives us a tree like structure called an octree, because at each branch there are 8 subdivisions. This subdivision process for a cubic region of space is illustrated.

    The big cube has been divided into 8, one child node is further divided at each stage. In hierarchical terms the octree resembles:

    The numbers in the circles represent an example of the number of faces inside the box associated with that node in the octree. You can see that as the subdivision is refined the number of faces in each box decreases. In this particular example the subdivision process is stopped when the number of faces in each box falls below 10.

    Once the octree is fully built ray tracing can proceed. Thus when the ray-tracing part of the algorithm follows a ray through the scene it moves from box to box and only a maximum of 10 faces have to tested in each box. A big saving in computation time. The tree structure of the octree makes the task of following a ray through the scene quite quick.

    There is a bit of work involved in calculating the movement of the ray and in getting a fairly quick test to see in which box the current position of the traced ray lies but we don't need to worry about this to understand the setting of the optimisation parameters.



    Tutorial written by Stuart

    << Prev   [1]   [2]   [3]   Next >>