Optical ray tracing for photovoltaic devices and luminescent materials