pygame is
Simple DirectMedia Layer is
Site Swing
Sphere Ray Trace

Sphere Ray Trace - 2.0.0

Ian Mallett (geometrian)



Lately, I've realized that while PyOpenGL is fast and powerful, it may not be quite powerful enough to create the realism I want easily.

Ray-tracing is a way to create super-realistic lighting effects, among other things. In this screenshot, for instance, you can see refractions and reflections.

Anyway, this is more of a tech demo than anything--it only works with spheres, as they are mathematically simple. There are a few bugs here. The refraction code is based off of my circle refraction program: The circle program, which currently just ignores internal reflection produces artifacts in the image. They're errors, since the refraction method is not implemented. Any problems show up magenta here. I'll fix all this later in perhaps another release.


Home Page:
Source: Ray


click to view original size


Sphere Ray Trace - 6.0.0 - Jun 12, 2008
Sphere Ray Trace - 4.0.0 - Jun 5, 2008
Sphere Ray Trace - 2.0.0 - Jun 5, 2008 account Comments

If you wish to leave a comment with your account, please sign in first.

June 22, 2008 4:34pm - Ian Mallett - nickname: (geometrian)
Sorry about that. It appears to be fixed now. It can now be found on my website.
June 13, 2008 12:44am - Ian Mallett - nickname: (geometrian)
Ooooo dear. Scratch that. The server of my site is having issues. You can download this latest release at this temporary download location:
June 12, 2008 11:23pm - Ian Mallett - nickname: (geometrian)
Version 6.0.0 released! (Version 5.0.0 was pre-release work).
June 8, 2008 2:19pm - Ian Mallett - nickname: (geometrian)
I have come upon a dark secret of ray-tracing. Refractions and shadows cannot be done together exactly. One or the other can be done, but together, they are imperfect.
June 7, 2008 5:44pm - Ian Mallett - nickname: (geometrian)
No. And I will use it forever.
June 6, 2008 10:10pm - Paul Davey - nickname: (technomancer)
ever heard of the string method strip() ?
June 6, 2008 12:58pm - Ian Mallett - nickname: (geometrian)
It is possible that certain operating systems might work differently. On mine, "\n" is one character. I think in this case, changing the indexes in the scene loader could solve the problem. [x:-1] -> [x:-2] or something.

I added a gallery of ray-racing images online:
June 6, 2008 12:55am - RB[0] - nickname: (roebros)
It doesn't appear to run for me.
It seems you aren't stripping the values correctly, ie: it is trying to float("0)"), instead of "0".
Also I got a "\r" in there - instead of no value :(

Looking good regardless though :D
June 5, 2008 10:34pm - pymike - nickname: (pymike) - 5/5
Woah. Nice work. Looks pretty dang cool :D
June 5, 2008 10:28pm - Ian Mallett - nickname: (geometrian)
Version 4.0.0 released! (Version 3.0.0 was pre-release work).
June 5, 2008 7:05pm - Emanuel Berg - nickname: (metabaron)
Very cool.
June 5, 2008 10:54am - Ian Mallett - nickname: (geometrian)
June 5, 2008 10:53am - Ian Mallett - nickname: (geometrian)
Good idea. I was having trouble with last night (see pygame_users) but the problem was my download link. I deleted it, and haven't put it back since.
June 5, 2008 10:46am - pymike - nickname: (pymike)
Cool. :) You might want to include a direct link to the download though. Took a while to find it on the projects page.
June 5, 2008 8:00am - Francesco Mastellone - nickname: (effeemme)
Very interesting =)
June 5, 2008 1:38am - Ian Mallett - nickname: (geometrian)
Version 2.0.0 released! (Version 1.0.0 was pre-release work).

our projects welcomes all python game, art, music, sound, video and multimedia projects. If they use pygame or not.
recent releases
Feb 21, 2017

Jan 31, 2017

Jan 24, 2017

Jan 18, 2017

Jan 7, 2017

Dec 30, 2016

Dec 8, 2016

Nov 28, 2016

Nov 27, 2016

... more!
for pygame related questions, comments, and suggestions, please see help (lists, irc)