I modeled index of refraction as a function of heat in 3D space. This is what causes mirages and the shimmer in the air behind a jet's engines.
Mirages and heat shimmers occur do to changes in the index of refraction due to air temperature. Because rays no longer travel in a straight line, the current grid accelerator no longer worked. I decided to stay with grid.cc since I liked the idea of using the grid structure in computing the new path of the ray as it enters a new voxel and because this way I could regain some of the grid acceleration at no extra cost since I'm already traversing a grid.
The algorithm used first sets up the voxels to contain a certain amount of heat. It does so by finding the position of the ground at each voxel and setting that voxel to a certain temperature. If required, specific voxels can also be given a special temperature. Once the initial temperatures are set, the temperature is diffused out of the voxels into neighboring voxels for a specified number of steps.
When Intersect is called, the ray traverses the grid. At each voxel the gradient is calculated from the interpolated voxel heat fields and used to find the normal. Snells's law is then calculated with a check for both refraction and reflection. The ray is then given a new origin and direction and sent off.