I too have been writing a raytracer in Rust[0] recently. I tend to use raytracers as my go to project when learning a new language, especially those that are OOP, since it touches a few different areas that are commo such as:<p>+ Protocols/traits/interfaces and using that for polymorphishm, think intersectable/primitve types.<p>+ It typicall involves both understanding heap and stack allocated memory in the language as well as understanding the general memory model to build scene graphs etc<p>+ Building a small linear algebra library usually touches things like low level operations and performance operations
as well as operator overloading if the language supports it.<p>+ Writing images to disks via pixel buffers<p>Primarily though I think raytracers are very fun projects because you can produce nice looking results quickly which I find helps with motivation and passion for the project. I'm pretty pleased with some of my renders already[1]<p>0: <a href="https://github.com/k0nserv/rusttracer" rel="nofollow">https://github.com/k0nserv/rusttracer</a><p>1: <a href="https://raw.githubusercontent.com/k0nserv/rusttracer/master/docs/bit-later-render.png" rel="nofollow">https://raw.githubusercontent.com/k0nserv/rusttracer/master/...</a>
> raytracing an image takes much longer than the polygon-based rendering done by most game engines.<p>Minor nitpick, but it has nothing to do with the fact that it renders polygons. Ray tracing can also render polygons. More precisely, game engines use rasterization which works by projecting triangles onto the screen rather than tracing rays through the screen.
I didn't follow this bit (from
Part 2):<p>"This requires a bit more geometry. Recall from last time that we detect an intersection by constructing a right triangle between the camera origin and the center of the sphere. We can calculate the distance between the center of the sphere and the camera, and the distance between the camera and the right angle of our triangle. From there, we can use Pythagoras’ Theorem to calculate the length of the opposite side of the triangle. If the length is greater than the radius of the sphere, there is no intersection."<p>The two sides he describes have the camera in common - so the "opposite" side of that triangle is the line from the center of the sphere to the right angle - I don't see how this helps....<p>Edit: ok I finally get it but I think he should just label some of these lengths on the diagram with letters (a,b,c etc) and then just show how they are related by stating Pythagoras theorem explicitly...
> Despite that, it also happens to be the simplest way to render 3D images.<p>I'm not sure I would claim that -- with a line drawing routine in hand (a for loop), you can have 3D perspective renderings of objects with a few matrix vector multiplies.
It's be really cool if someone wanted to port this raytracer[0] to Rust and compare benchmarks.<p>[0] <a href="http://www.ffconsultancy.com/languages/ray_tracer/benchmark.html" rel="nofollow">http://www.ffconsultancy.com/languages/ray_tracer/benchmark....</a>