Ray Tracing, Apple Metal, Swift Programming, Gpu Rendering, Wwdc 2020.
color = HemisphericLighting(ray: ray) //6 preparing the writing to the ppm file let r = Int(256*color.x) let g = Int(256*color.y) let b = Int(256*color.z) out.append(“\(r) \(g) \(b) \n”) } } //7 writing the file do { try out.write(to: filename, atomically: true, encoding: String.Encoding.utf8) }