This is an example showing the use of MPSRayIntersector Metal Performance Shader for ray tracing. It is a direct translation into swift from Objective C of the Apple example project MPSPathTracingSample. See that propject for more details: Metal for Accelerating Ray Tracing
Tested on macOS only.