Long ago I had an artist make me a simple cyberspace/Metaverse background.

I’ve not yet been able to get any artist to make a similar one for me yet, and so it looks like I’m going to have to make it myself. Since I can’t draw worth a damn, I’m going to have to do it myself using programming and mathematics instead.
So I’m writing a ray tracer. In Ruby. Yeah, it sounds insane, but the idea is to write the framework of the stuff in Ruby and then write the performance-intensive parts as a C extension. I’ve gotten this far…

This takes 88 seconds on my AMD Ryzen 7 5800U to render, 848×480, 16-subsample/pixel antialiased, but in pure Ruby using Ruby’s built-in matrix/vector libraries with the most straightforward, naïve algorithms. I later rewrote most of the matrix and vector maths parts as a Ruby-C extension (making these is something I needed to review anyway) and got it down to 11 seconds. There are likely algorithmic enhancements that can be done further here, and then improved with judicious use of C extensions. Ruby helps to be able to see the algorithmic and mathematical structure of the code more clearly without getting bogged down with too many low-level details that I would have to deal with in pure C. As Knuth once said, premature optimisation is the root of all evil.
The grid floor is basically a plane, with a procedural texture that defines the grid. A ray from the eye through the ray tracer viewport has to be tested if it will hit the plane of the grid first, and then if it lands on one of the grid lines. I plan to do the other shapes similarly, the hexagons will not be that hard. Might be nice to add in more weird shapes like Penrose aperiodic tiles. The walls my old artist evidently based on Hilbert or Peano curves, and those too can be rendered with a procedural texture just like the grid. Other similar fractal objects might also be neat.
I think this has more claim to being real art than simply poking around with generative AI prompts/
Leave a comment