HardwareRay tracing made possible on 42-year-old ZX Spectrum: ‘reasonably fast, if you consider 17 hours per frame to be reasonably fast’When you purchase through links on our site, we may earn an affiliate commission.Here’s how it works.

HardwareRay tracing made possible on 42-year-old ZX Spectrum: ‘reasonably fast, if you consider 17 hours per frame to be reasonably fast’When you purchase through links on our site, we may earn an affiliate commission.Here’s how it works.

When you purchase through links on our site, we may earn an affiliate commission.Here’s how it works.

(Image credit: Future)

The ZX Spectrum with a colourful background.

It takes around 17 hours for the ZX Spectrum to render a single ray-traced frame. That’s one frame every 61,200 seconds, or 0.000016 fps.

As detailed in hisblog post on the project, Gambetta ported the basic ray tracing code from his book into BASIC—the programming language that powers the ZX Spectrum. Without too much tweaking, he found that this code produced a basic image even on the ZX Spectrum’s limited hardware—a 3.5MHz Z80A chip with often as little as 16KB of RAM.

The image is just four blobs of colour: yellow, red, green, and blue. This process took nearly 15 minutes. On a modern PC, the same scene would take a fraction of a second.

Image1of2A ray-traced image on the ZX Spectrum.(Image credit: Gabriel Gambetta)A ray-traced image produced using the CGFS raytracer.(Image credit: Gabriel Gambetta)

Image1of2A ray-traced image on the ZX Spectrum.(Image credit: Gabriel Gambetta)A ray-traced image produced using the CGFS raytracer.(Image credit: Gabriel Gambetta)

Image1of2

A ray-traced image on the ZX Spectrum.(Image credit: Gabriel Gambetta)A ray-traced image produced using the CGFS raytracer.(Image credit: Gabriel Gambetta)

A ray-traced image on the ZX Spectrum.(Image credit: Gabriel Gambetta)A ray-traced image produced using the CGFS raytracer.(Image credit: Gabriel Gambetta)

A ray-traced image on the ZX Spectrum.(Image credit: Gabriel Gambetta)

A ray-traced image on the ZX Spectrum.(Image credit: Gabriel Gambetta)

A ray-traced image on the ZX Spectrum.(Image credit: Gabriel Gambetta)

A ray-traced image on the ZX Spectrum.(Image credit: Gabriel Gambetta)

A ray-traced image on the ZX Spectrum.(Image credit: Gabriel Gambetta)

A ray-traced image on the ZX Spectrum showing different colour blobs.

A ray-traced image produced using the CGFS raytracer.(Image credit: Gabriel Gambetta)

A ray-traced image produced using the CGFS raytracer.(Image credit: Gabriel Gambetta)

A ray-traced image produced using the CGFS raytracer.(Image credit: Gabriel Gambetta)

A ray-traced image produced using the CGFS raytracer.(Image credit: Gabriel Gambetta)

A ray-traced image produced using the CGFS raytracer.(Image credit: Gabriel Gambetta)

A ray-traced image using the standard CGFS raytracer.

“From the beginning I knew implementing some sort of raytracer was possible because the theory and the math are relatively straightforward,” Gambetta tells me. “But I didn’t know if it would run in a sensible amount of time, because this thing was slow for modern standards (…and even for the standards of the time!)”

Ray tracing is computationally expensive. It’s the process of casting a ray out from the camera through a grid of pixels until it interacts with an object in the scene. Casting further rays from that point can generate lighting effects, such as shadows, reflection and refraction. To produce a high resolution image with realistic lighting using even just a single ray per pixel demands millions of rays per frame. It takes clever algorithms, bounding boxes, and heaps of acceleration to do this in real-time for today’s ray-traced games.

The biggest gaming news, reviews and hardware deals

Whereas the ZX Spectrum is capable of producing only a handful of colours—fifteen in total, including two brightness levels and black—and has a total resolution of 256 x 192 pixels. It’s unable to display any colour in any pixel at any one time, either. It uses blocks, 8 x 8 pixels in size, in which it’s able to store information of just two colours at once. This was done to minimise memory use; overall a great decision as it hugely brought down costs at a time when computers were not known for being affordable, but a bit of a nightmare for displaying much more than text.

The ZX Spectrum in its usual garb. There were many variations, including those with more RAM, in its lifetime.(Image credit: Future)

The ZX Spectrum with a colourful background.

This thing was slow for modern standards.

This thing was slow for modern standards.

The downside of the ZX Spectrum’s memory-savvy block-based solution is what’s called attribute clash. This is essentially the inability to display any more than two colours within an 8 x 8 pixel block.

Gambetta’s next step was to up the resolution to near-maximum at 256 x 176, effectively drawing individual pixels, but this means bumping into attribute clash.

“Increasing the resolution is easy. Dealing with attribute clash, not so much.”

There’s no solution to attribute clash. It’s an inherent and idiosyncratic part of the ZX Spectrum. In the end, Gambetta’s higher-resolution image is near enough perfect—he used a simple algorithm to try and minimise the effects of attribute clash as much as possible—just don’t look too closely at some of the points where three colours meet.

Image1of2Look closely at the blocks that should contain three colours. Slide the gallery for the full image.(Image credit: Gabriel Gambetta)(Image credit: Gabriel Gambetta)

Image1of2Look closely at the blocks that should contain three colours. Slide the gallery for the full image.(Image credit: Gabriel Gambetta)(Image credit: Gabriel Gambetta)

Image1of2

Look closely at the blocks that should contain three colours. Slide the gallery for the full image.(Image credit: Gabriel Gambetta)(Image credit: Gabriel Gambetta)

Look closely at the blocks that should contain three colours. Slide the gallery for the full image.(Image credit: Gabriel Gambetta)(Image credit: Gabriel Gambetta)

Look closely at the blocks that should contain three colours. Slide the gallery for the full image.(Image credit: Gabriel Gambetta)

Look closely at the blocks that should contain three colours. Slide the gallery for the full image.(Image credit: Gabriel Gambetta)

Look closely at the blocks that should contain three colours. Slide the gallery for the full image.(Image credit: Gabriel Gambetta)

Look closely at the blocks that should contain three colours. Slide the gallery for the full image.(Image credit: Gabriel Gambetta)

Look closely at the blocks that should contain three colours. Slide the gallery for the full image.(Image credit: Gabriel Gambetta)

A ray-traced image on the ZX Spectrum showing attribute clash.

(Image credit: Gabriel Gambetta)

(Image credit: Gabriel Gambetta)

(Image credit: Gabriel Gambetta)

(Image credit: Gabriel Gambetta)

(Image credit: Gabriel Gambetta)

A ray-traced image on the ZX Spectrum showing attribute clash.

The strain of going from a 32 x 22 image to a 256 x 176 one is evident in how much longer this secondary image took to render. From 879.75 seconds (nearly 15 minutes) to 61,529.88 seconds (over 17 hours). Luckily, some optimisations and time-saving tweaks meant this could be brought down to 8,089.52, or near-ish two and a half hours.

(Image credit: Gabriel Gambetta)

A ray-traced image on the ZX Spectrum showing attribute clash with optimisations to improve performance.

And we haven’t even got to the really cool bit yet! As I mentioned before, ray tracing can be used to generate the pixel colour, but it can also be used to produce various effects. Think of Alan Wake 2 and how vibrant and realistic some of the lighting is in that game. The ZX Spectrum could never get close—it only has a handful of colours to work with—so instead Gambetta simulates how light interacts with a scene through the use of dithering.

The result is genuinely awesome for a lil’ machine like this. A ray-traced 3D-like image that works somehow despite all the limitations on colours and how they’re used.

(Image credit: Gabriel Gambetta)

A ray-traced image on the ZX Spectrum showing dithering to created shaded colour.

“I ran this iteration, and honestly, I stared at it in disbelief for a good minute,” Gambetta said.

What’s more, he uses a further tweak to his ray tracer code to implement shadows in the scene. Using a ray to trace any intersections between a sphere and the directional light source, he was able to produce the final image in this experiment, which is genuinely incredibly impressive. Sure, even with optimisations, it takes around 17 hours to render a single frame, but hey, I’m wholly impressed.

Image1of2A ray-traced image on the ZX Spectrum with shadows!(Image credit: Gabriel Gambetta)A ray-traced image produced using the CGFS raytracer.(Image credit: Gabriel Gambetta)

Image1of2A ray-traced image on the ZX Spectrum with shadows!(Image credit: Gabriel Gambetta)A ray-traced image produced using the CGFS raytracer.(Image credit: Gabriel Gambetta)

Image1of2

A ray-traced image on the ZX Spectrum with shadows!(Image credit: Gabriel Gambetta)A ray-traced image produced using the CGFS raytracer.(Image credit: Gabriel Gambetta)

A ray-traced image on the ZX Spectrum with shadows!(Image credit: Gabriel Gambetta)A ray-traced image produced using the CGFS raytracer.(Image credit: Gabriel Gambetta)

A ray-traced image on the ZX Spectrum with shadows!(Image credit: Gabriel Gambetta)

A ray-traced image on the ZX Spectrum with shadows!(Image credit: Gabriel Gambetta)

A ray-traced image on the ZX Spectrum with shadows!(Image credit: Gabriel Gambetta)

A ray-traced image on the ZX Spectrum with shadows!(Image credit: Gabriel Gambetta)

A ray-traced image on the ZX Spectrum with shadows!(Image credit: Gabriel Gambetta)

A ray-traced image on the ZX Spectrum showing ray-traced shadow effects.

A ray-traced image produced using the CGFS raytracer.(Image credit: Gabriel Gambetta)

A ray-traced image produced using the CGFS raytracer.(Image credit: Gabriel Gambetta)

A ray-traced image produced using the CGFS raytracer.(Image credit: Gabriel Gambetta)

A ray-traced image produced using the CGFS raytracer.(Image credit: Gabriel Gambetta)

A ray-traced image produced using the CGFS raytracer.(Image credit: Gabriel Gambetta)

A ray-traced image using the standard CGFS raytracer showing ray-traced shadow effects.

The end result exceeded the expectations I had at the beginning!

The end result exceeded the expectations I had at the beginning!

Reflections are basically impossible with the limitations on colour blending, and perhaps there’s more to be done to increase performance, but ultimately this is not something I would have previously thought at all possible on a ZX Spectrum’s measly 3.5MHz processor.

“The interesting part of the project was figuring out how to work around all these limitations to make something that ran reasonably fast, if you consider 17 hours per frame to be reasonably fast, and looked reasonably good,” Gambetta tells me.

“In that sense, the end result exceeded the expectations I had at the beginning!”

Why the ZX Spectrum?

Later versions of the ZX Spectrum improved upon the base specification, including this ZX Spectrum +3 with a floppy disk drive. Drool worthy stuff!(Image credit: Future)

The ZX Spectrum with a colourful background.

The ZX Spectrum was a massively popular computer in the early ’80s. Affordable, entertaining, surprisingly good-looking, and even quite educational. Part of its popularity came down to how it was possible to code your own games using its programming language, BASIC. But one had to get around the limitations of the hardware first.

“To make it so cheap its designer, Sir Clive Sinclair, cut all sorts of corners,” Gambetta tells me. “It was a limited computer even for its time.”

“I grew up with one of these at home (in Uruguay of all places). It had some apps but also tons of videogames, so it was a gateway drug into programming for an entire generation of people like me; you got it for the games, but it was very very easy to accidentally slide into programming it yourself, because it “booted” not into a command line, not into an user interface, but into what we would call an IDE (or development environment) nowadays.”

Learn a bit of BASIC and you could makesomethingon the ZX Spectrum. Not fast, nor with too many colours, but something.

“You could have some kind of visual thing moving around the screen in something like 5 lines of code, which is unthinkable these days.”

Gambetta tells me he doesn’t believe there’s anything quite so simple to dip your toes into the world of graphics programming these days—even the most basic programs take more lines of code than anything the ZX Spectrum ever did. Yet he does plug thePICO-8for retro gaming fans looking to mess around with getting coding themselves, and of course his own book (available for free on hiswebsiteor for money onAmazon), Computer Graphics from Scratch.

“That requires nothing but a browser and a text editor, which pretty much any computer comes with out of the box. But even that takes more steps than what we had in the ’80s.”

More about hardwareIs the new RTX 5070 really as fast as Nvidia’s previous flagship RTX 4090 GPU? Turns out the answer is yes. Kinda.It’s time for me to admit that AI-accelerated frame generation might actually be the way of the future and that’s a good thingLatestMarvel Rivals’ latest update quietly killed the game’s burgeoning mod sceneSee more latest►

More about hardwareIs the new RTX 5070 really as fast as Nvidia’s previous flagship RTX 4090 GPU? Turns out the answer is yes. Kinda.It’s time for me to admit that AI-accelerated frame generation might actually be the way of the future and that’s a good thingLatestMarvel Rivals' latest update quietly killed the game’s burgeoning mod sceneSee more latest►

More about hardwareIs the new RTX 5070 really as fast as Nvidia’s previous flagship RTX 4090 GPU? Turns out the answer is yes. Kinda.It’s time for me to admit that AI-accelerated frame generation might actually be the way of the future and that’s a good thing

More about hardware

Is the new RTX 5070 really as fast as Nvidia’s previous flagship RTX 4090 GPU? Turns out the answer is yes. Kinda.It’s time for me to admit that AI-accelerated frame generation might actually be the way of the future and that’s a good thing

Nvidia RTX 5070 graphics card

Is the new RTX 5070 really as fast as Nvidia’s previous flagship RTX 4090 GPU? Turns out the answer is yes. Kinda.

Is the new RTX 5070 really as fast as Nvidia’s previous flagship RTX 4090 GPU? Turns out the answer is yes. Kinda.

Nvidia RTX 5090 Founders Edition rendered on a green background.

It’s time for me to admit that AI-accelerated frame generation might actually be the way of the future and that’s a good thing

It’s time for me to admit that AI-accelerated frame generation might actually be the way of the future and that’s a good thing

LatestMarvel Rivals' latest update quietly killed the game’s burgeoning mod sceneSee more latest►

Latest

Marvel Rivals' latest update quietly killed the game’s burgeoning mod scene

Marvel Rivals tier list - Wolverine

Marvel Rivals' latest update quietly killed the game’s burgeoning mod scene

Marvel Rivals' latest update quietly killed the game’s burgeoning mod scene

See more latest►

Most Popular

‘It’s simply impossible to make a difficulty level that’s just right for all players’: How Final Fantasy 14’s lead battle designer has been playing a precarious balancing game for Dawntrail’s dungeons and raids

Please join me in getting super excited for all the cool looking survival games coming in 2025 (and beyond)

Competitive shooters are at a crucial crossroads in 2025: ‘sweaty’ teamplay vs. casual fun

Call of Duty’s $28 Squid Game skins are the perfect crossover for our capitalist dystopia, and Activision knows exactly what it’s doing

These are the 14 biggest upcoming RPGs of 2025—get ready for another amazing year for the genre

Five new Steam games you probably missed (January 6, 2025)

I’ve seen enough: No more forcing singleplayer studios to make mediocre live service games

6 games that could be bigger hits than you’re expecting in 2025

What are your 2025 gaming resolutions?

The FBI put a $5 million bounty on the ‘Cryptoqueen’ last year but still hasn’t found her, so take your pick: Russia, South Africa, or murdered on a yacht in 2018

HARDWARE BUYING GUIDESLATEST GAME REVIEWS1Best Steam Deck accessories in Australia for 2025: Our favorite docks, powerbanks and gamepads2Best graphics card for laptops: the mobile GPUs I’d want in my next gaming laptop3Best mini PCs in 2025: The compact computers I love the most4Best 14-inch gaming laptop: The top compact gaming laptops I’ve held in these hands5Best Mini-ITX motherboards in 2025: My pick from all the mini mobo marvels I’ve tested1Thank Goodness You’re Here! review: An anarchic treasure trove of jokes and skits2Shiren the Wanderer: The Mystery Dungeon of Serpentcoil Island review—like juggling chainsaws on horseback3WD Black SN850X 8 TB NVMe SSD review4Ikea Utespelare desk review5Asus ROG Harpe Ace Mini wireless mouse review

HARDWARE BUYING GUIDESLATEST GAME REVIEWS1Best Steam Deck accessories in Australia for 2025: Our favorite docks, powerbanks and gamepads2Best graphics card for laptops: the mobile GPUs I’d want in my next gaming laptop3Best mini PCs in 2025: The compact computers I love the most4Best 14-inch gaming laptop: The top compact gaming laptops I’ve held in these hands5Best Mini-ITX motherboards in 2025: My pick from all the mini mobo marvels I’ve tested1Thank Goodness You’re Here! review: An anarchic treasure trove of jokes and skits2Shiren the Wanderer: The Mystery Dungeon of Serpentcoil Island review—like juggling chainsaws on horseback3WD Black SN850X 8 TB NVMe SSD review4Ikea Utespelare desk review5Asus ROG Harpe Ace Mini wireless mouse review

HARDWARE BUYING GUIDESLATEST GAME REVIEWS1Best Steam Deck accessories in Australia for 2025: Our favorite docks, powerbanks and gamepads2Best graphics card for laptops: the mobile GPUs I’d want in my next gaming laptop3Best mini PCs in 2025: The compact computers I love the most4Best 14-inch gaming laptop: The top compact gaming laptops I’ve held in these hands5Best Mini-ITX motherboards in 2025: My pick from all the mini mobo marvels I’ve tested1Thank Goodness You’re Here! review: An anarchic treasure trove of jokes and skits2Shiren the Wanderer: The Mystery Dungeon of Serpentcoil Island review—like juggling chainsaws on horseback3WD Black SN850X 8 TB NVMe SSD review4Ikea Utespelare desk review5Asus ROG Harpe Ace Mini wireless mouse review

HARDWARE BUYING GUIDESLATEST GAME REVIEWS1Best Steam Deck accessories in Australia for 2025: Our favorite docks, powerbanks and gamepads2Best graphics card for laptops: the mobile GPUs I’d want in my next gaming laptop3Best mini PCs in 2025: The compact computers I love the most4Best 14-inch gaming laptop: The top compact gaming laptops I’ve held in these hands5Best Mini-ITX motherboards in 2025: My pick from all the mini mobo marvels I’ve tested1Thank Goodness You’re Here! review: An anarchic treasure trove of jokes and skits2Shiren the Wanderer: The Mystery Dungeon of Serpentcoil Island review—like juggling chainsaws on horseback3WD Black SN850X 8 TB NVMe SSD review4Ikea Utespelare desk review5Asus ROG Harpe Ace Mini wireless mouse review

HARDWARE BUYING GUIDESLATEST GAME REVIEWS

1Best Steam Deck accessories in Australia for 2025: Our favorite docks, powerbanks and gamepads

A bunch of the best Steam Deck accessories on a blue background.

1Best Steam Deck accessories in Australia for 2025: Our favorite docks, powerbanks and gamepads

1

Best Steam Deck accessories in Australia for 2025: Our favorite docks, powerbanks and gamepads

2Best graphics card for laptops: the mobile GPUs I’d want in my next gaming laptop

2Best graphics card for laptops: the mobile GPUs I’d want in my next gaming laptop

2

Best graphics card for laptops: the mobile GPUs I’d want in my next gaming laptop

3Best mini PCs in 2025: The compact computers I love the most

3Best mini PCs in 2025: The compact computers I love the most

3

Best mini PCs in 2025: The compact computers I love the most

4Best 14-inch gaming laptop: The top compact gaming laptops I’ve held in these hands

4Best 14-inch gaming laptop: The top compact gaming laptops I’ve held in these hands

4

Best 14-inch gaming laptop: The top compact gaming laptops I’ve held in these hands

5Best Mini-ITX motherboards in 2025: My pick from all the mini mobo marvels I’ve tested

5Best Mini-ITX motherboards in 2025: My pick from all the mini mobo marvels I’ve tested

5

Best Mini-ITX motherboards in 2025: My pick from all the mini mobo marvels I’ve tested

1Thank Goodness You’re Here! review: An anarchic treasure trove of jokes and skits

Thank Goodness You’re Here review

1Thank Goodness You’re Here! review: An anarchic treasure trove of jokes and skits

1

Thank Goodness You’re Here! review: An anarchic treasure trove of jokes and skits

2Shiren the Wanderer: The Mystery Dungeon of Serpentcoil Island review—like juggling chainsaws on horseback

2Shiren the Wanderer: The Mystery Dungeon of Serpentcoil Island review—like juggling chainsaws on horseback

2

Shiren the Wanderer: The Mystery Dungeon of Serpentcoil Island review—like juggling chainsaws on horseback

3WD Black SN850X 8 TB NVMe SSD review

3WD Black SN850X 8 TB NVMe SSD review

3

WD Black SN850X 8 TB NVMe SSD review

4Ikea Utespelare desk review

4Ikea Utespelare desk review

4

Ikea Utespelare desk review

5Asus ROG Harpe Ace Mini wireless mouse review

5Asus ROG Harpe Ace Mini wireless mouse review

5

Asus ROG Harpe Ace Mini wireless mouse review