If you are using this together with the VolumeChunk: Beware of the possible scaling or other transformations you did on the Chunk! Do the inverse first on the ray origin. Example of a scaling with the factor 10: ray.setOrigin(ray.getOrigin() / (Real)10.0);

Serializes a volume source to a discrete grid file with deflated compression.

To achieve better compression, all density values are clamped within a maximum absolute value of (to - from).length() / 16.0. The values are scanned in this inner-loop-order: z, x, y. y last because there is usually the least isosurface intersection to be expected in the use case of terrain and so more often the maximum density value hit. The values are written as 16 Bit floats to save space. Note that this process is not lossless, the tradeoff is between accuracy of the source-reproduction (smaller voxelWidth) and smaller filesize (bigger voxelWidth).