Compress Ray Buffer
In a non-sequential raytrace, the rays do not follow a pre-defined sequence of intersection events through the system. Rather, the geometry layout and the surface properties assigned to the geometry dictate where the rays propagate through the system and which surfaces the rays interact with. A consequence of this non-sequential raytrace philosophy is that usually only a small fraction of the total rays input into the system will arrive at your detector.
The ray data is stored in a "ray buffer" and the ray data is accessed when requested by the user (ex. an irradiance calculation). FRED then needs to process all of the rays in the buffer in order to identify the rays on the detector which contribute to the requested analysis. If the number of rays on the detector is a small fraction of the total rays in the buffer, this processing of the ray data can be inefficient (particularly if the data gets processed multiple times for different analyses).
The example file below demonstrates an embedded script that performs a raytrace, identifies the rays of specific interest using the ray selection filter criteria of an analysis surface, and then moves the rays of interest to their own ray buffer. The resulting ray buffer is 100% efficient in the sense that the buffer only contains rays that are of interest to the user.
Additionally, this compacted ray buffer can be written out to a *.frbs file (Fred Ray Buffer Serialization file format) if needed. Lines at the end of the embedded script in the example file are commented out, but show how the *.frbs file can be created.
Example FRED file: FilterRaysToCompactBuffer.frd