Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A Haskell port of the C++ smallpt path tracer
Haskell C++
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
Smallpt Initial commit.
cbits Initial commit.
LICENSE Cabalized.
Makefile Initial commit.
README.md Cabalized.
Setup.hs Added Setup.hs for good cabal carma.
bench.hs
profile.hs Initial commit.
smallpt-hs.cabal Cabalized.
smallpt-hs.hs Initial commit.

README.md

smallpt-hs

This is a port of smallpt, a global illumination path tracer written in 99 lines of C++. The port is written in 99 lines of Haskell.

There are two major differences: performance and argument parsing. The Haskell code compiled with GHC 6.12.1 is about 4.5 times slower than the C++ version. (I only tested on my anemic Atom N450-powered netbook...) The C++ code takes an optional argument, which should be a integer greater than 4.

Give it a spin

The complete package contains more than the 99 lines smallpt-hs.hs file. There are other variants with a criterion wrapper to benchmark the code. The cbits directory contains the original smallpt.cpp file modified to be expose the main entry point as a C symbol callable from Haskell via FFI.

Every attempt so far use the vector package. The 99 lines file is derived from Smallpt/Mutable.hs. The Storable code doesn't improve the performance and is less convenient to use. The Unboxed code lose in performance because the Vec type can't benefit from an explicit unpack pragma.

If you can make the code faster or easier to read, please let me know!

License

Although the LICENSE file is a BSD3 license, I should contact Kevin Beason (the original author of the C++ code) to make sure it is ok. The linked site above has the original LICENSE.

Something went wrong with that request. Please try again.