Skip to content

SIMD (AVX) and multi threaded simple raytracer

License

Notifications You must be signed in to change notification settings

Lightning2X/RaytracerSDL19

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 

Repository files navigation

RaytracerSDL

Port of @Lightning2X's and @Krien's old 2018 C# Raytracer in C++.

Code ported by @Krien, in a few days. So some functionality is missing such as camera movement or mirrors.

Code then optimized for the INFOMOV course by @Lightning2X and @PhoenixThrough. Leading up to a 31x performance improvement compared to the original. Optimization was done primarily through SIMD and multithreading. Using a lot of early outs in SIMD dramatically speeds up the code in multiple places. This code is still not fully optimal (what code ever is?) so if you see further improvement feel free to send me a message. Switching between the old and new code is possible through setting the SIMD definition to 0 or 1 in precomp.h.

See the table below for detailed results:

STAT AVG MIN MAX
NEW 116.50 81.30 141.24
OLD 3.83 3.54 3.88
X FASTER 31 23 36

RUNNING THE CODE

This repo (currently) only contains the logic itself. This will NOT compile without adding libraries and setting a few settings. The instructions for this are described below

You first need to install SDL on your system from Here (add it in your Program Files and add to PATH).

You then need to grab 3 libraries:

  1. SDL's Development Library
  2. Agner Fog's Vector Class
  3. Agner Fog's Vec3Df from vector class add ons

You then need to place SDL's include, vector class and vec3d in Raytracer/deps/include: image

Finally, place SDL's lib/x64 from the development library in Raytracer/deps/lib

Then include these folders in VS2022 by going to Raytracer -> Properties -> VC++ Directories. Now add all the 4 folders from ./include and ./dep and the program should run.

EXAMPLE RENDER

image

About

SIMD (AVX) and multi threaded simple raytracer

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 96.2%
  • C 3.8%