A C# port of Peter Shirley's Ray Tracing in One Weekend (book, version 1.55 and C++ code available for free).
Running the application generates a random scene:
If you feel a bit rusty on the math, you may want to start with a few posts I wrote while working through the book:
$ git clone https://github.com/ronnieholm/Ray-tracing-in-one-weekend-CSharp.git
$ dotnet run -c release > out.ppm
$ display out.ppm
On my Intel Core i7-7560U CPU @ 2.40GHz laptop running Linux and .NET, ray tracing takes about two minutes.
For benchmarking, writing to standard output should be disabled in
Program.cs
:
real 1m34.189s
user 1m34.720s
sys 0m0.222s
% git clone https://github.com/RayTracing/raytracinginoneweekend.git
% cd raytracinginoneweekend/src/
Comment out the last std::cout
statement in main.cc
.
% g++ -O2 main.cc
% time ./a.out > /dev/null
real 1m13.045s
user 1m12.789s
sys 0m0.056s
In terms of raw computation power, .NET doesn't come close to C++. At least not while staying true to the C++ code structure.