RayTracer

Basic RayTracer


What it is ?

Full Software (CPU/FPU, no ASM acceleration, no SSE specific development) RayTracer using multi-threading, diffuse (lambert), specular (blinn/phong), reflection, refraction, 2d map texturing (point and bi-lerp filtering), bump-mapping, horizontal supersampling (only on edge boundary) and hard shadows.

The SSE2 binary is only a VisualStudio compiler option (gain is variable, very minus on Pentium4 = 1%, higher on Core2 = 20%).

It's wrote in C/C++ with VisualStudio 2005/2008, but I keep portability on my mind using SDL.
Only Multi-Thread code is windows compliant, but can be removed without probleme.

How it look ?






Download

download.pngClick here to get sources and binaries

What's new in 0.1.3

  • fix octree structure accelerator for mesh
  • add octree structure accelerator for node
  • add diffuse reflection... too slow : move between commentaries
  • use better point light distance attenuation (pow2 distance)
  • add 64bits executable (SSE2 option seem to be disable in VisualC then compile in x64 mode). But performance under intel Core2 is better in 64bit without SSE2 than x86 with SSE2 ! But, warn please, the automatic core detection don't work in 64bit (not yet ported ASM stuff)
  • update SDL_ttf for using FreeType-2.3.7 as static lib
  • add VisualC++ 2008 SP1 projects (and reorganise VisualC++ 2005 SP1 ones), VisualC 2008 SP1 produce speeder SSE2 optimisation (near 3%)
  • add transform in XML scene


In the future ?

  • fix this stupid bug in dot3 bump mapping
  • fix this stupid bug in triangle shadow intersection
  • fix this stupid bug in refraction
  • mip-mapping and other classic texture filterings
  • diffuse refraction/reflection
  • lighting emitter materiel for object
  • better multi-threading
  • debug structures accelerators for meshes...


Real-time... Are you sure

Get realtime with default setting and build-in benchmark :
(fps = frame per second, mrps = millions of ray per second)
  • intel Core 2 Duo E6850 3.0Ghz (winXP SP3 32bits, 3.4Go)
    - 320x240, 2 threads, SSE2 : 13.4 fps, 1.556 mrps
    - 320x240, 2 threads : 9.9 fps, 1.145 mrps
    - 320x240, 1 thread : 5.1 fps, 0.585 mrps
    - 640x480, 2 threads, SSE2 : 3.6 fps, 1.622 mrps
    - 640x480, 2 threads : 2.6 fps, 1.173 mrps
    - 640x480, 1 thread : 1.3 fps, 0.594 mrps
  • intel Core 2 Duo E6650 2.33Ghz (win2008 sp1 32bits, 2.0Go)
    - 320x240, 2 threads, SSE2 : 10.4 fps, 1.206 mrps
    - 320x240, 2 threads : 7.6 fps, 0.878 mrps
    - 320x240, 1 thread : 4.0 fps,0.462 mrps
    - 640x480, 2 threads, SSE2 : 2.9 fps, 1.287 mrps
    - 640x480, 2 threads : 2.0 fps, 0.914 mrps
    - 640x480, 1 thread : 1.1 fps, 0.472 mrps

Old version (in french description)


Voici mon petit programme de raytracing comme vous en trouverez plein sur Internet.

Le but de la chose etait d'experimenter le RayTracing temps-rel de faon 100% logiciel (pas d'acceleration particuliere).
Je fourni les sources (et les bugs qui vont avec ) pour Microsoft VisualC 2005.

Au niveau binaire, on trouvera un executable SS2 qui n'est qu'une simple option du compilateur (VC2005).

J'utilise la librairie SDL pour l'affichage (et son extension TTF pour les fonts utilises).

Il y a un petit bench fourni avec.


raytracer010_640x480.jpg

Resultat du bench pour la version 0.1.1

* intel core 2 duo E6850 3.0Ghz (winXP SP3, 3.4Go)
- 320x240, 2 threads, SSE2 : 17.9 fps, 1.88 Millions of rays per second ;
- 320x240, 2 threads : 14.6 fps, 1.53 Millions of rays per second ;
- 320x240, 1 thread : 7.8 fps, 0.82 Millions of rays per second ;
- 640x480, 2 threads, SSE2 : 4.7 fps, 1.91 Millions of rays per second ;
- 640x480, 2 threads : 3.9 fps, 1.57 Millions of rays per second ;
- 640x480, 1 thread : 2.1 fps, 0.84 Millions of rays per second.
* intel core 2 duo E6650 2.33Ghz (win2008, 2.0Go)
- 320x240, 2 threads, SSE2 : 15.0 fps, 1.58 Millions of rays per second ;
- 320x240, 2 threads : 11.8 fps, 1.24 Millions of rays per second ;
- 320x240, 1 thread : 6.2 fps, 0.65 Millions of rays per second ;
- 640x480, 2 threads, SSE2 : 4.1 fps, 1.64 Millions of rays per second ;
- 640x480, 2 threads : 3.2 fps, 1.28 Millions of rays per second ;
- 640x480, 1 thread : 1.6 fps, 0.66 Millions of rays per second.
* intel core 2 duo T7200 2.2Ghz (Vista SP1, 2Go)
- 320x240, 2 threads, SSE2 : 11.7 fps, 1.23 Millions of rays per second ;
- 320x240, 2 threads : 9.3 fps, 0.98 Millions of rays per second ;
- 320x240, 1 thread : 5.2 fps, 0.55 Millions of rays per second ;
- 640x480, 2 threads, SSE2 : 3.1 fps, 1.26 Millions of rays per second ;
- 640x480, 2 threads : 2.5 fps, 1.02 Millions of rays per second ;
- 640x480, 1 thread : 1.4 fps, 0.56 Millions of rays per second.
* amd athlon64 X2 4600+ 2.4Ghz (WinXP SP3, 3.4Go)
- 320x240, 2 threads, SSE2 : 8.2 fps, 0.86 Millions of rays per second ;
- 320x240, 2 threads : 8.5 fps, 0.90 Millions of rays per second ;
- 320x240, 1 thread : 5.4 fps, 0.57 Millions of rays per second ;
- 640x480, 2 threads, SSE2 : 2.2 fps, 0.88 Millions of rays per second ;
- 640x480, 2 threads : 2.3 fps, 0.92 Millions of rays per second ;
- 640x480, 1 thread : 1.4 fps, 0.58 Millions of rays per second.
* intel core 2 duo T2300E 1.66Ghz (WinXP SP2, 1Go)
- 320x240, 2 threads, SSE2 : 8.7 fps, 0.925 Millions of rays per second ;
- 320x240, 2 threads : 6.9 fps, 0.725 Millions of rays per second ;
- 320x240, 1 thread : 3.8 fps, 0.407 Millions of rays per second ;
- 640x480, 2 threads, SSE2 : 2.3 fps, 0.926 Millions of rays per second ;
- 640x480, 2 threads : 1.8 fps, 0.73 Millions of rays per second ;
- 640x480, 1 thread : 1.0 fps, 0.411 Millions of rays per second.
* amd Athlon XP 2600+ 2.0Ghz (WinXP SP3, 2Go)
- 320x240, 1 thread : 4.5 fps, 0.47 Millions of rays per second ;
- 640x480, 1 thread : 1.2 fps, 0.48 Millions of rays per second.
* intel Pentium4 D630 3.0Ghz (WinXP SP3, 2Go)
- 320x240, 2 threads, SSE2 : 5.6 fps, 0.59 Millions of rays per second ;
- 320x240, 2 threads : 5.9 fps, 0.62 Millions of rays per second ;
- 320x240, 1 thread : 4.3 fps, 0.45 Millions of rays per second ;
- 640x480, 2 threads, SSE2 : 1.5 fps, 0.61 Millions of rays per second ;
- 640x480, 2 threads : 1.7 fps, 0.67 Millions of rays per second ;
- 640x480, 1 thread : 1.1 fps, 0.46 Millions of rays per second.
* amd Athlon XP 2500+ 1.83Ghz (WinXP SP2, 512Mo)
- 320x240, 1 thread : 4.0 fps, 0.42 Millions of rays per second ;
- 640x480, 1 thread : 1.0 fps, 0.42 Millions of rays per second.