Fundamental Python Ray-Tracer

Started by
4 comments, last by Geometrian 16 years, 1 month ago
Hi, Before you make any judgements: I'm going to try to make a ray-tracer without OpenGL. It will use only Python and Pygame. The idea is that the rays will be rendered to a Pygame surface and then the surface will be drawn. Again, no OpenGL, so no, this is not a graphics question. I have made a basic raytracer, just by sitting down and coding it. It renders as many objects (I've only got spheres) as you want, but it is very slow and it only does basic colors. As of yet, there are no shadows, reflections, refractions, lights, anti-aliasing, etc. These are, of course, the things which most attract me about ray-tracing, so they must be added now. As far as code goes, I get the feeling I'm doing it all wrong. So, I'm looking for a basic ray-tracer's code, in Python, which can render polygons, (triangles and/or quads) with shadows and color. After that, I think I can figure out how to do reflections, refractions, and anti-aliasing. Thanks, Geometrian

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

Advertisement
googled for 2 seconds and found this and this (spanish link)
Quote:Original post by Geometrian
Again, no OpenGL, so no, this is not a graphics question.
Of course it is a graphics question. OpenGL is just one option for hardware acceleration of graphics and vector processing in general. Moved.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Quote:Original post by Geometrian
Hi,

Before you make any judgements:
I'm going to try to make a ray-tracer without OpenGL.


Why do you think OpenGL should be a standard tool when dealing with raytracing? Actually, OpenGL has nothing to do with raytracing the 90% of the cases: the only two exceptions that come to my mind are using textures as target for the raytracing and then using OpenGL to show that texture, and experimenting a bit with raytracing on the graphic board. These cases aside, I don't see how OpenGL relates with raytracing...

Quote:
I have made a basic raytracer, just by sitting down and coding it. It renders as many objects (I've only got spheres) as you want, but it is very slow and it only does basic colors.


Depending upon which were your expectations, what you see is truly slow or simply what you get given the algorithm you choose. Compared with rasterization on graphic hardware sw raytracing is several times slower. In addition, python is not really what I would consider the best tool for this job, although nothing prevent from doing it (and they already did it).

Quote:Original post by thedustbustr
googled for 2 seconds and found this and this (spanish link)
hmmmm. The link works, but the file seems to be corrupted.


Quote:Original post by cignox1Why do you think OpenGL should be a standard tool when dealing with raytracing? Actually, OpenGL has nothing to do with raytracing the 90% of the cases: the only two exceptions that come to my mind are using textures as target for the raytracing and then using OpenGL to show that texture, and experimenting a bit with raytracing on the graphic board. These cases aside, I don't see how OpenGL relates with raytracing...
I wasn't sure, and I didn't want people to make assumptions.
Quote:Depending upon which were your expectations, what you see is truly slow or simply what you get given the algorithm you choose. Compared with rasterization on graphic hardware sw raytracing is several times slower. In addition, python is not really what I would consider the best tool for this job, although nothing prevent from doing it (and they already did it).
That's fine. I can do optimisations later. I realise that it will almost certainly not be realtime or anything. The goal here is to make something as realistic as possible. I'll start with basic scene renderings and work up to shadows and reflections.

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

Quote:googled for 2 seconds and found this and this (spanish link)
hmmmm. The link works, but the file seems to be corrupted.
Quote:Why do you think OpenGL should be a standard tool when dealing with raytracing? Actually, OpenGL has nothing to do with raytracing the 90% of the cases: the only two exceptions that come to my mind are using textures as target for the raytracing and then using OpenGL to show that texture, and experimenting a bit with raytracing on the graphic board. These cases aside, I don't see how OpenGL relates with raytracing...
I wasn't sure, and I didn't want people to make assumptions.
Quote:Depending upon which were your expectations, what you see is truly slow or simply what you get given the algorithm you choose. Compared with rasterization on graphic hardware sw raytracing is several times slower. In addition, python is not really what I would consider the best tool for this job, although nothing prevent from doing it (and they already did it).
That's fine. I can do optimisations later. I realise that it will almost certainly not be realtime or anything. The goal here is to make something as realistic as possible. I'll start with basic scene renderings and work up to shadows and reflections.

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

This topic is closed to new replies.

Advertisement