In the replies underneath, someone ran it on a real Acorn Electron computer (6502 at 1 MHz), where it completed in 8 hours and 40 minutes. Not too bad really.
BBC BASIC raytracer in 432 characters
51–60 of 96 posts
Re: BBC BASIC raytracer in 432 characters
#52Earlier quoted context omitted.
…to elucidate a bit, when tracing the rays on the left side of the image, the sign of u is -1, so we're trying to intersect a sphere at (x-1, y-1, z), and on the right side similarly one at (x+1, y+1, z). This works because none of the left-side rays can even in theory hit the right-side sphere and vice versa. It's a very simple version of space partitioning optimization. And when tracing the reflected rays, we flip…
these comments were extremely helpful, thank you
Re: BBC BASIC raytracer in 432 characters
#53Can anybody provide de-obfuscated/minified source so those of us who understand the principle (tracing rays of light around a scene) can understand the maths?
here's my attempt 10 REMĀĘĆĞ$Č*Ēĉ!ăě-ĕ'ď rem dithering table in comment above consulted by GCOL line? rem raytracer from https://bbcmic.ro/?t=9ctpk by https://mastodon.me.uk/@coprolite9000 rem deobfuscated and possibly broken by kragen javier sitaker (untested) 20 MODE 1 VDU 5 30 FOR N = 8 TO 247 : rem loop over rows (n) and columns (m) of pixels FOR M = 0 TO 319 40 X = 0 : rem three-dimensional vector Y = -.1 Z = 3…
I'd maybe phrase this a bit differently – in both cases it uses the v coordinate to calculate the shade but whereas the sky is a simple gradient, the plane has a "ground fog" type effect that can be adjusted with those +.3 and +.2 magic constants.
Re: BBC BASIC raytracer in 432 characters
#54https://www.pouet.net/prod.php?which=78045 Incredible raytraced demo in 256 bytes.
last year i wrote a tetris in arm assembly https://asciinema.org/a/622461 and was pleased to get it down below 1024 bytes then i looked and rrrola's 4is256 https://www.pouet.net/prod.php?which=29286 is a working tetris in under 256 bytes, and it's better than mine because it has colors and scoring. i could blame a little bit of inflation on arm being 32-bit rather than 16-bit, but not 4×
Re: BBC BASIC raytracer in 432 characters
#55In the replies underneath, someone ran it on a real Acorn Electron computer (6502 at 1 MHz), where it completed in 8 hours and 40 minutes. Not too bad really.
that's astounding; i would have guessed months or years
Re: BBC BASIC raytracer in 432 characters
#56Earlier quoted context omitted.
last year i wrote a tetris in arm assembly https://asciinema.org/a/622461 and was pleased to get it down below 1024 bytes then i looked and rrrola's 4is256 https://www.pouet.net/prod.php?which=29286 is a working tetris in under 256 bytes, and it's better than mine because it has colors and scoring. i could blame a little bit of inflation on arm being 32-bit rather than 16-bit, but not 4×
You could try using Thumb instructions, they are 16 bit.
Re: BBC BASIC raytracer in 432 characters
#57Earlier quoted context omitted.
here's my attempt 10 REMĀĘĆĞ$Č*Ēĉ!ăě-ĕ'ď rem dithering table in comment above consulted by GCOL line? rem raytracer from https://bbcmic.ro/?t=9ctpk by https://mastodon.me.uk/@coprolite9000 rem deobfuscated and possibly broken by kragen javier sitaker (untested) 20 MODE 1 VDU 5 30 FOR N = 8 TO 247 : rem loop over rows (n) and columns (m) of pixels FOR M = 0 TO 319 40 X = 0 : rem three-dimensional vector Y = -.1 Z = 3…
> rem if instead y component is negative, make a checkerboard of pieces of sky I'd maybe phrase this a bit differently – in both cases it uses the v coordinate to calculate the shade but whereas the sky is a simple gradient, the plane has a "ground fog" type effect that can be adjusted with those +.3 and +.2 magic constants.
Re: BBC BASIC raytracer in 432 characters
#58Earlier quoted context omitted.
I'm running this on a BBC micro emulator running at period-accurate speed, and it's taking just under a minute to draw one line. So I think it's going to finish in about 4 hours, which would make sense - approximately twice as fast as the Acorn Electron.
Update: Finished in only 2 hours 30 minutes.
Re: BBC BASIC raytracer in 432 characters
#59https://www.rustexplorer.com/b#Zm4gbWFpbigpIHsKICAgIC8vIHJvd...
Re: BBC BASIC raytracer in 432 characters
#60a thing that puzzles me is how https://bbcmic.ro/?t=9ctpk is only 4× faster in emulation (about 30 seconds per scan line and so on the order of 2 hours for the whole image) i'm running this on a ryzen 5 3500u at 2400 megahertz. the acorn electron which supposedly takes 8 hours and 40 minutes is a 1 megahertz 6502 when running from ram, roughly, 262144 instructions per second. at 2 ipc one core of the ryzen should be…