Algorithmic outline of a ray-tracer can be very simple as written out below.
The pseudo-code above creates a given number of rays and for each of them performs a given number of reflections. For each ray path segment an intersection with the listener is also computed. If there is such an intersection, the ray passes through the listener volume and must be recorded for the resulting response. Computationally the most heavy part here is the search for the closest intersection point.
This algorithm loops through all the surfaces in the geometry and computes intersection between the given line segment and the surface. If there is such an intersection, then it is compared against the minimum distance that has been found so far. If the distance is shorter, then the current surface and intersection point are recorded as the closest one so far. In the end, those variables will have the information of the closest reflection event and those are returned to the caller of the function. This search can be accelerated by the use of some spatial data structure that aims to minimize the number of required intersection computations. Those structures can be thought of as directories that are able to tell what are the possible surfaces that may give the shortest reflection distance and will skip all the other surfaces.
|III.5.2 Main differences to the image source method (previous)||III.5 Ray-tracing techniques (up)||III.5.4 Registration of rays (next)|