davepagurek / raytracer

A Monte Carlo 3D renderer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Raytracer

This is a Monte Carlo style 3d renderer (so the more samples you use, the closer to a perfect render it gets.) Here are some images I've rendered with it so far:

Features

  • Shapes
    • Sphere
    • Plane
    • Triangle
      • Rectangle
      • Rectangular prism
    • Volumes of any other shape
  • Materials
    • Diffuse
    • Reflective
    • Refractive
    • Light emitter
    • Volumes
    • Subsurface Scattering
  • Lens blur
  • Motion blur

Usage

Edit Sources/Raytracer/main.swift to change the size of the image, objects, etc. Then run the raytracer:

swift build
.build/debug/Raytracer

Explanation

A general overview of ratracing: http://www.davepagurek.com/blog/how-raytracing-works

Subsurface scattering: http://www.davepagurek.com/blog/volumes-subsurface-scattering

Antialiasing

Antialiasing works by first rendering an image, then applying a find edges filter, and then rerendering edge areas at a sub-pixel level.

Here is a detail of the original depth image:

Edges are found by subtracting a blurred version from the original:

Then, those areas are rerendered at double the pixel density to smooth the edges:

About

A Monte Carlo 3D renderer

License:MIT License


Languages

Language:Swift 100.0%