Java raytracing float vs double

There is pretty much no difference between float and double when it comes to speed of calculation, as far as desktop processors are the platform. The difference can only come from the increased memory bandwidth requirements because doubles require twice as much space.

Its different for GPU based calculations, those are more tailored for float and e.g. Nvidia GPU's break down considerably for double.

I'd go with a mixed approach; store data like polygons with float precision, but do all calculations in double. Small memory footprint, high precision - win-win.


I'm answering so late that this is probably irrelevant to you, but perhaps helpful to others. I'm also working on a ray tracer in Go as a personal project (also using the PBR book), and had the same question...32 or 64 bit floats. I think I'm going to go with 32 bit mainly for one reason: SIMDizing ray-triangle intersection tests. No matter which instruction set your processor can use (eg SSE4, AVX2, AVX512), it can perform 2x the amount of 32-bit fp ops per instruction vs 64-bit.