Skip to content

Zero-dependency, concurrent raytracer written in Swift.

Notifications You must be signed in to change notification settings

anthonynsimon/raytracer-swift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

raytracer-swift

Example image 64 samples per pixel

Zero-dependency, concurrent raytracer written in Swift. A simple weekend experiment following the excellent book at https://raytracing.github.io/.

Features:

  • Positionable camera with Depth of Field and Field of View.
  • Three kinds of materials: Lambertian, Dielectric and Metal.
  • Configurable antialiasing.
  • Optimized to make use of all available cores.
  • Outputs Portable Bitmap Format files.

This raytracer runs entirely in the CPU. At some point I might add SIMD or GPU support for learning purposes, but being ultra-performant is not the main priority.

Usage:

Setup your scene in the main.swift file and run:

$ swift run

[12/12] Linking raytracer
Rendering using all available cores: 8
Rendering took 2622 ms
Writing image in Portable Bitmap Format
Done, result at ~/src/raytracer-swift/result.ppm

Samples per pixel

You can configure the quality via the samplesPerPixel parameter.

Samples per pixel: 2

Example image 2 samples per pixel

Samples per pixel: 4

Example image 4 samples per pixel

Samples per pixel: 16

Example image 16 samples per pixel

Samples per pixel: 32

Example image 32 samples per pixel

Samples per pixel: 64

Example image 64 samples per pixel

About

Zero-dependency, concurrent raytracer written in Swift.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages