Hacker News new | ask | show | jobs
by s_gourichon 883 days ago
Excellent! A similar program, apparently from 3 years ago, did similar things, in Basic also, on the Amstrad CPC, a machine with the same processor, a little more RAM and more (27) colors or shades of green, depending on the screen it was hooked to.

* colored spheres (like you did)

* (one) checkerboard surface

* self-shadowing (like you did)

* cast shadows (like you did)

* partial or total specular reflection!

See https://www.cpc-power.com/index.php?page=detail&num=19283

The webpage displays the color (left) and green (right) versions on hovering your pointer over the ribbon (above). Image 1 and 2 are okay in both cases, image 3 is clearly tuned for color screen, image 4 for green screen.

Or direct links to the relevant variants:

https://www.cpc-power.com/extra_lire_fichier.php?extra=cpcol...

https://www.cpc-power.com/extra_lire_fichier.php?extra=cpcol...

https://www.cpc-power.com/extra_lire_fichier.php?extra=cpcol...

https://www.cpc-power.com/extra_lire_fichier.php?extra=cpcol...

https://www.cpc-power.com/extra_lire_fichier.php?extra=cpcol...

https://www.cpc-power.com/extra_lire_fichier.php?extra=cpcol...

1 comments

That's pretty impressive. The main difficulty with reflections in the ZX Spectrum is not so much the limited color palette, which can be dealt with, but the 2-color limit per 8x8 block. It's already a big issue with just lights and shadows as it is :-/
> the 2-color limit per 8x8 block. It's already a big issue with just lights and shadows as it is :-/

Well, you impressed me (and others) with your simple bet that "hey, what if I simply choose the two most popular colors" and just code that in simple BASIC. The same could be done with the shading. It would probably pick a good compromise when bright yellow meets dark red: by choosing to have the few should-be-red pixels become yellow, you avoid a bigger obviously-square-grid-based clash of colors.

Next step: error diffusion dithering would IMHO be a good bet. But maybe that becomes really to much for Basic.

I've been considering doing Raytracing on the Amstrad CPC, but in C. Perhaps using integers only, for speed.

Done that instead: https://cpcitor.itch.io/just-get-9

Hey, found this https://bbcmic.ro/?t=9ctpk via "BBC BASIC raytracer in 432 characters (mastodon.me.uk)" https://news.ycombinator.com/item?id=39023056#39023768