PDA

View Full Version : A real time ray tracer :)



Paulius
01-02-2004, 12:01 AM
I somehow got the idea to make a real time ray tracer, and it turns out it?¢_Ts one of the most fun things to write, you implement everything yourself and there?¢_Ts actually very little code. Right now it doe's Phong shading, shadows, reflections and sphere and plane primitives. Planning to (eventually) add texturing, more primitives, normal displacement and CSG.

http://legion.gibbering.net/paulius/IMG/Ray.jpg
Move about with FPS'ish controls, press L to see how adaptive sampling acts. You'll need a lot of CPU power.
http://legion.gibbering.net/paulius/RaytraceV01.zip

Traveler
01-02-2004, 01:08 PM
Wow that is so cool!! :shock:

There's something strange with the fps though, cause when I pressed L for the adaptive sampling, things movent noticebly more slower. The fps however stayed the same. (32~35).

Looking forward to see more of this!

Paulius
01-02-2004, 05:13 PM
There's something strange with the fps though, cause when I pressed L for the adaptive sampling, things movent noticebly more slower. The fps however stayed the same. (32~35).
I was predicting fps only from time taken by sampling, not including the actual rendering. The slowdown is strange, cause after pressing L the only thing that changes is that quads between sampled point's don't get filled, which theoretically could only improve performance :scratch:

Goliatus
01-02-2004, 05:14 PM
There are many skillful programmers on Litwa :D

Paulius
07-02-2004, 07:28 PM
Texture mapping done, with a big slowdown though.
http://legion.gibbering.net/paulius/IMG/Ray2.jpg
http://legion.gibbering.net/paulius/RaytraceV02.zip
Some new controls to play around with:
R - toggle reflections
1,2,3 - adjust maximum subdivision count

About the slowdown Traveler described, it seam's non existent on nVidia card's, small on intel's, and horrible on ATI's, at least on those I tried. Anyone knows how come OpenGl's GL_LINE glPolygonMode give's these strange results on different cards.

WILL
08-02-2004, 07:52 AM
Very nice. :)

Mind you it toggles between 2 and 3 FPS when I set it to 3 polyphony and turn on reflection.

It goes blank when I turn on the L function. But to explain all of this read my system specs below.

My NEC VERSA SXi:
CPU = Intel Pentium III 800 MHz
Memory = 512 MB SDRAM PC133 or 166, not sure
Video Card = "ATI RAGE MOBILITY-M1 AGP" 8MB of video ram(extended via AGP to 32)
OS = Windows XP Professional

Alimonster
11-02-2004, 11:00 AM
This is a very cool thing indeed. There's something unusually satisfying moving around a scene and have it accurately reflected in the objects, especially moving up close to a sphere.

I've not tried the texture mapped version yet, just the first one, but the speed on the first one was fine.

As for the speed hit on wireframe mode -- well, I've heard that some graphics cards emulate wireframe mode by making the lines out of small polygons, but FWIW I noticed no major speed decrease in wireframe mode with my ATI card. I'll try the later version and will let you know if that's still the case.

Momor
11-02-2004, 12:30 PM
Hmm I loooove these kind of topics !

That's a very impressive stuff. Do you plan, by chance, to release the source code ?

Now for my comprehension : how is OpenGL handy for such kind of thing ? As far as I know, a raytracer does not render using polygons, so a basic plain DirectDraw or GDI surface with a good SetPixel() function should be enough.

Perhaps are you using OpenGL to speed-up the final blitting to the screen ?

Paulius
11-02-2004, 04:11 PM
Do you plan, by chance, to release the source code ?
Sure thing, I'll release the source code when it'll be more complete and some cleaning up is in order.

how is OpenGL handy for such kind of thing ?
Classical, cheatless ray tracing, where ray's are traced for every pixel, is very slow and hardly doable in realtime. I cheat a lot here :twisted: . I exploit the fact that the color of an object doesn't change much in nearby pixels, trace fewer rays, if they didn?¢_Tt hit the same object then trace more ray's, otherwise I interpolate between them, and by using OpenGL I get almost free quad interpolation done by hardware, not to mention bilinear filtering and other cool stuff, and also a possibility to do polygonal rendering on top of it. Of course because of this some limitations are introduced and there are sampling artifact (like poor specular highlights on spheres from a far, and missing very small objects), but it's a sacrifice I'm willing to make.

Paulius
24-04-2004, 06:22 PM
I felt a little ashamed of not doing anything for a long time, trying to figure out some math somehow became really depressing, so at least I'll release the source code. http://legion.gibbering.net/paulius/Raytracev03.zip Not much new except infinite cylinders, and now 9 and 0 control field of view.