Raytracing over grids