III.2.5 Full image-source computation with ray-path validation
A complete image-source computation is achieved by combining all these together. Let us start by looking such a technique in action.

- Play around to see how the image-source computation works in more complex geometries as there are some pre-defined geometries available.
- By zooming out and selecting all the reflection orders and 'Ray extensions' you can see that only a minor fraction of the image sources will provide valid reflection paths.
- In addition, you can edit the geometry by dragging the vertex locations with the mouse.


Time:
Show outside Zoom:
Reflection orders: Direct sound 1st 2nd 3rd 4th 5th
Visualization: Wavefronts Full ray paths Ray extensions Raylets
Show image sources: OK On wrong side of reflector Out of reflector Obstructed

The same algorithm to construct the image sources as presented earlier is valid even in this case. The main difference to the rectangular room is the need for reflection path validation that is needed for construction of the impulse response. Actual construction of the impulse response from image sources will be discussed later and here we limit us only to finding out what image sources are valid for a given listener location. This needs reconstruction of the full reflection path for each image source and checking that each section of the path is valid. Those can be done combined in one algorithm, but here we show pseudo-code for each of them separately.

The first algorithm performs the actual reflection path reconstruction.

Algorithm: Reflection path reconstruction for a given image source and listener. Stores the path segments in 'path' array of the image source. 

It computes the path by traversing the image-source tree upwards order by order starting from the given image source. The first line segment to be investigated is defined by the listener location and this image-source, and the algorithm computes the intersection point of that segment with the reflector associated with the image source. After that the process continues to the parent image source in the tree. At each order an intersection is computed between the reflector of the current image source and the line segment from the previous intersection point to the image source. The results are stored in the path variable. This process is continued up to the first order reflection, and finally the actual source location is stored as the starting point of the reflection path.

The only required geometric operation in the algorithm above is intersect that computes the intersection point between a line segment and a polygon. It first computes intersection between the line and the plane on which the polygon lies. After that it checks that the intersection point is inside the polygon and on the line segment. If either of those checks fail it returns a value that will fail in an if statement to signal that no intersection between these two elements was found.

The second algorithm performs the occlusion checking where each segment of the reflection path is verified separately. For each such segment an intersection is computed against all other surfaces excluding the surfaces at the end-points of the segment. If there is an intersection point, it means that the path is occluded and, thus, should be discarded.

Algorithm: Validates the given reflection path by going through each segment and checking that none of them is occluded.

The final set of valid image-sources for a given listener position is formed of all those image-sources that pass the path validation test.