#RayTracerChallenge

2026-01-29

Some belated #weeknotes on my #raytracerchallenge in #ocaml - I did some performance work to try speed up how it was rendering large amounts of unstructured triangels, and then undid that by making it easier to load yet more triangles by implementing STL file reading - which included the surprise that STL files often have colour information stashed in them via unofficial usage of an unused field!

https://digitalflapjack.com/weeknotes/performance_and_stl_files/

A ray traced image showing a guitar amplifier sat on an infinite checkerboard pattern plane. The amp is a typical box coloured blue with a black panel in it with a grey speaker and a control panel.
2026-01-19

Another #weeknotes update on getting through the #raytracerchallenge in #ocaml - https://digitalflapjack.com/weeknotes/raytracing_progress/

  • Adding groups, bounding boxes, and triangles
  • Adding 3D model support (using X3D rather than OBJ)
  • Tweaking it to let me make small animations
  • Using instruments to work out why it's slow (or at least confirm my assumptions)
An image of a 3D ray traced scene showing a chess board from the perspective of being behind one of the sets of pieces looking over at the other 'team'. Both teams are made up from rainbow coloured glass, and the board is made from white and mirrored tiles.
2026-01-16

I guess it was bound to happen at some point in the #raytracerchallenge - the classic teapot. In the end I implemented a minimal reader for X3D files to load this, as they are just XML and can handle colour per surface (not used here, but useful for my other test files).

A screenshot of a ray tracing of a relatively low polygon teapot (the classic "Utah teapot") sat on a reflective checkerboard surface.
2026-01-14

Did a little restructuring of my #raytracerchallenge code to make it easier for me to make little animation loops.

2026-01-10

Not a lot to show for recent #raytracerchallenge in #ocaml work, as I took time out from the book to use OCaml domains (aka multithreading) to accelerate the rendering, as it gets quite slow when you throw in a lot of transparency and reflection (and I've not made any other efforts to optimise things yet).

Still, here's a bunch of coloured glass tubes. I quite enjoy mixing the techniques I learned from #genuary and #tcc to generate scenes for my ray tracer.

A screenshot of a square window that has a series of pale, rainbow coloured lines coming in from the edge to the centre of the window radially, but not meeting in the middle, leaving a circular void.
2026-01-08

Next on the #raytracerchallenge was the humble cube. A little boring on it's own, but solved by application of a loop and some random.

A screenshot of a ray traced scene. In the middle is a sphere made of many dozens of random overlapping cubes to make a chaotic mess. Around it is a rainbow tinted circle of glass spheres, all of which is floating over a checkerboard plane.
2026-01-07

Got through the transparency part of the #raytracerchallenge - not the best test scene, but it's impressive how quickly this is starting to chug now compared to before.

A screenshot of a ray traced scene with a large opaque orange sphere with light and dark stripes, surrounded by a set of floating smaller spheres that are the colour of the rainbow but also transparent, so you can see the shadows and the floor distorted through them. The floor is a classic light grey/dark grey checkerboard pattern.
2026-01-05

It's still my breakfast coffee and I've not started work, so I got reflections working for #raytracerchallenge over the break after all :D

Don't like the way the reflections look on the gray panel on the ground, not sure if that's just the limitations of the simple reflection model or I've fluffed the math somewhere. Alas that definitely will need to wait as it's back to work now!

Still, it was nice to do some #ocaml for a bit, as I don my waders for getting back into Python again :)

A screenshot of a raytraced scene of a large orange striped sphere surrounded by a ring of smaller, rainbow coloured, spheres, all floating over a checkerboard patterned infinite plane. You can see the shadow cast by the spheres on the plane, and you can now see the plane and spheres all reflect each other. In the lower right though the purple bit of the rainbow is being reflected a bit much and is eye catching in a weird way.
2026-01-04

Not sure I'll make it to reflectivity in #raytracerchallenge before the break time runs out, but at least I have a classic checkerboard pattern working now, which is half the look and feel of old school ray tracing demos :)

A screenshot of a ray traced scene of a large sphere with a ring of smaller spheres around it floating over an infinite plane. The large sphere has alternating light and dark orange stripes on it, the smaller spheres form a rainbow of bright colours around it, and the ground is a light and dark grey checker board pattern.
2026-01-02

Today's progress with #raytracerchallenge in #ocaml. We have planar surfaces and I bumped my viewer up to retina resolution. Still a lot of the book to go and the break is almost over, but it's been nice to exercise my OCaml muscles again for a bit.

A screenshot of a ray traced scene of a large orange sphere with a series of rainbow coloured spheres surrounding it. Below the spheres is a neutral grey ground plane with the shadow of the spheres cast upon it.
2026-01-01

My test scene isn't a great example, but finally added shadows! #raytracerchallenge

A screenshot of a ray traced orange sphere with a ring an smaller rainbow coloured spheres around it. The scene is lit from the top left, and yo can see that the smaller spheres cast a shadow on the larger one, and the large one is shading the far side ring spheres.
Lord Doctor Olle Wollej@hachyderm.io
2025-12-17

Last year I started to implement the raytracer from the book The Ray-Tracer Challenge from Pragmatic Programmer by Jamis Buck. It describes all concepts very well, and the implementation is done through cucumber test cases, so it can be followed in any language you want.

raytracerchallenge.com/

My implementation is coded in Rust and renders the images using the game library Macroquad.
github.com/ollej/macroquad-ray

#Rust #RustLang #Macroquad #raytracer #gfx #RayTracerChallenge

Raytraced image of an icecream cone with three scoops of different colored icecream. It’s floating above an infinite checkered plane with a shadow of the cone.Raytraced image of three balls of different sizes and colors.Raytraced image of the Standord teapot in golden yellow floating above an infinite checkered plane where it casts a shadow.Raytraced image with several balls of different sizes. One has a mirror surface and another looks like it’s made of glass. Under them is an infinite checkered plane where the balls cast shadows.
Lord Doctor Olle Wollej@hachyderm.io
2025-07-28

The fifteenth chapter of the ray tracing book is a bit more exciting as it adds the triangle and smooth triangle shapes as well as a parser for OBJ files. This makes it possible to load 3D models and add them to the scene.

I also made an optimization to cache the inverse of the transformation matrix which sped up the calculations a lot.

Here is an image of a smooth high polygon version of the Utah Teapot.

#RayTracer #RayTracerChallenge #Rust #RustLang #PragmaticProgrammer #3DModel

A ray traced image of a shiny yellow teapot at an angle over an infinite checkered floor.A ray traced image of a reddish shape made up of a few triangles floating above a checkered floor.
Lord Doctor Olle Wollej@hachyderm.io
2025-07-28

I had to do a lot of refactoring of my ray-tracer to get Chapter 14 working where Groups are added. Making it possible to combine shapes and translate them at the same time.

The end result is not very exciting though. This is a hexagon made up of six cylinders as edges and six spheres as corners.

#RayTracer #RayTracerChallenge #Rust #RustLang #PragmaticProgrammer

A ray traced image showing a red hexagon shape at an angle over an infinite checkered floor.
Lord Doctor Olle Wollej@hachyderm.io
2025-07-23

In chapter 13 two more shapes are added to the ray tracer. A cylinder and a cone.

#RayTracer #RayTracerChallenge #RayTracing #Rust #RustLang #programming #book #PragmaticProgrammer

Six long cylinders of different colors are crossing each other ij a sort of star shape above a checkered plane.A yellowish cone with three spheres in the colors light yellow, light green and light red in the opening making it somewhat resemble an ice cream cone. Below it is an infinite checkered plane that slightly reflects the cone.
Lord Doctor Olle Wollej@hachyderm.io
2025-07-22

In the twelth chapter of the Ray-Tracer Challenge book I've added a new kind of shape: a cube. This new scene is created using only cubes that are scaled and translated to make different shapes.

#RayTracer #RayTracerChallenge #RustLang #Rust #Graphics #RayTracing

A ray traced image made up of only cubes. The floor is a checkered pattern, the walls are striped horisontally with yellow and cyan. In the middle of the image there is a red table with brown legs. There is a small purple box on top of the table. To the left of the table is a transparent cube standing on the corner. To the right are three different sized boxes in green, yellow, and purple. Against the right wall behind the table is a tall mirror that reflects the corner of the table and the transparent cube.
Lord Doctor Olle Wollej@hachyderm.io
2025-07-22

My progress has been a bit slower, but I've now finished chapter chapter 11 in the Ray-Tracer Challenge. My raytracer now has both reflection and refraction and it's possible to generate images with mirrored and transparent objects.

#RayTracer #RayTracerChallenge #RustLang #PragmaticProgrammer

A ray traced image showing a four spheres above a checkered plane stretching out in the distance. The spheres cast shadows and are reflected in the floor. In the middle of the image is a large sphere with a mirror surface that reflects the other spheres and the plane. To the left is a small yellow sphere. Behind and to the right of the large mirror sphere is a slightly smaller green sphere. To the right and partially in front of the green sphere is a medium sized transparent sphere. The green sphere and the checkered floor can be seen through the transparent sphere.
Lord Doctor Olle Wollej@hachyderm.io
2025-07-19

I've now finished the tenth chapter of The Ray-Tracer Challenge book from Pragmatic Programmer. This chapter implements multiple different types of patterns to apply to the objects. There are stripes, gradients, rings and a checkerboard pattern. Next up is the chapter on reflections and refractions which is very exciting.

#RayTracer #RayTracerChallenge #RustLang

A computer generated image with three balls. The large sphere in the middle has a striped gradient between red and greeen. The smaller sphere to the right has stripes of cyan and blue. The small sphere to the left is yellow and green. The floor is a checkerboard pattern, and the wall behind the spheres has rings of light and dark gray.
Lord Doctor Olle Wollej@hachyderm.io
2025-07-19

Chapter nine of the book The Ray-Tracer Challenge introduces a new kind of shape in addition to spheres: infinite planes. These can be used as floors and walls.

#RayTracer #RayTracerChallenge #RustLang

A computer generated image of three colored spheres above an infinite gray plane that extends in the distance.A computer generated image of three colored spheres above an gray plane with a different gray wall behind them.
2025-03-31
I added the first non-sphere shape (infinite planes) to my Dart-based Ray Tracer Challenge implementation. I decided to illustrate shadow casting on multiple objects and object intersections. #programming #RayTracerChallenge #DartLang gitlab.com/HankG/raytracerchal…
Ray tracer image with shadow casting of three a large green sphere in the center, a smaller green sphere off to the right, and a smaller yellow sphere off to the left over an infinite horizontal plane.Ray tracer image with shadow casting of three a large green sphere in the center, a smaller green sphere off to the right, and a smaller yellow sphere off to the left. They are surrounded by three reddish-tinted off-white walls and a floor. The large center sphere is partially embedded in the floor. The yellow sphere is casting a shadow on both the center sphere and the back wall. The center sphere is casting a shadow along the floor and the walls. All spheres are casting shadows on the back wall.

Client Info

Server: https://mastodon.social
Version: 2025.07
Repository: https://github.com/cyevgeniy/lmst