link to this article

Ray Tracing

fluxy - An Experimental Realtime 2d Path Tracer

2008-09-18

license

(C)2008 Sebastian Mach, phresnel[at]gmail[dot]com, http://phresnel.org: Licensed under GPL, Version 3, or later at your choice. PLEASE READ THE FILE 'LICENSE'.

download

what

http://phresnel.org/./gen-image/Ray Tracing/fluxy/screenshot0.png

http://phresnel.org/./gen-image/Ray Tracing/fluxy/screenshot1.pnghttp://phresnel.org/./gen-image/Ray Tracing/fluxy/screenshot2.png

fluxy is an experimental realtime path tracer in 2 dimensions. See [0] for an introduction to Global Illumination in 2d, thanks Thomas Ludwig (lycium) for that inspiring article.

To play with the light source, simply press the left Mouse Button, and Move the Mouse.

why

After reading [0] I wrote a 2d Path Tracer that rendered 2d-spheres (but with a bug in the reflection term, as lyc pointed out) with neat caustics, it can be found at [1]. It was a lot of fun to write that thing, and so I wanted to see how it works in realtime.

Well, the code is highly sub-optimal, and resided on my box for way more than a year, and I should not release it because I could do better today. But then, it would have been waste, so here's the release anyways :)

audience

This program has no serious industry use, it is more a show-off, or (at it's maximum) can be used for educational purposes (but I am not sure about the latter ;)).

build from source

Simplest way to build is to just <g++ `sdl-config --cflags --libs` *.cc>. Evident from that line is that you need SDL installed. Also note that with those parameters you get only half of the performance. There is a short script called src/bin/linux.native+sse/makeit with more decent optimization flags. It goes like this:


(ls amalgam.cc && rm amalgam.cc)>/dev/null
cp ../../*.cc ../../*.h ./
cat *.cc > amalgam.cc.tmp
rm *.cc
mv amalgam.cc.tmp amalgam.cc
g++ \
`sdl-config --cflags` \
-s -O3 -fexpensive-optimizations \
-combine -fwhole-program \
-ffast-math \
-ftree-vectorize \
-msse -march=native \
-funroll-loops -fvariable-expansion-in-unroller \
-ftree-loop-im -ftree-loop-ivcanon -fivopts -fvect-cost-model \
-fmodulo-sched -fmodulo-sched-allow-regmoves \
-funsafe-loop-optimizations \
-funswitch-loops \
-ftree-loop-ivcanon -ftree-loop-linear \
-ftracer \
-fprefetch-loop-arrays \
-freorder-blocks-and-partition \
-funsafe-math-optimizations -ffinite-math-only \
-fdata-sections \
`sdl-config --libs` \
amalgam.cc \
\
-o fluxy

As you can see, it cats together all source files into one file called amalgam.cc, which helps with the whole-program-optimizations (e.g. interprocedural analysis). Note that there are also other, generic builds included which run on most platforms (except when there is a "sseN" in the name than the target cpu must have support for that). Of course the most optimal program is produced if you run a script with "native", because that flag enables the compiler to generate code for exactly your machine.

Sidenote to me: Instead of writing shell-scripts I should write makefiles :|

That's all For now, have fun!

contact

phresnel / Sebastian Mach (*1983)