A simple real time ray tracing

Despite its realistic, Ray tracing is not the leading technology in the computer graphic field. The main disadvantage is the lack of speed which makes it impossible to generate real time graphic using current pc. But without doubt it will all change when pc start to have enough power to handle ray traced graphic in a reasonable speed, everyone will use it because it simply can make the most realistic graphics!

The program below is a simulation of ray tracing technology, but much more simpler. The only deflectable material is the floor in this case. And because it is much simpler than a real ray tracing, your pc will be able to run it in real time. Hit your arrow keys to change the view direction, and “w” to move forward, “s” ro move backward.

Chilc the link below to start the animation.

http://www.freewebs.com/phu004/run.html

here is a shot

http://www.freewebs.com/phu004/untitled.JPG

the full source code (since i am not a English speaker, some of my comments can be massy or make no sense, hope you
guys dont mind)

http://www.freewebs.com/phu004/ray%20tracer%20demo.zip

Hey I’m not alone ! :wink:

Your algorithm won’t scale well, you’ve avoided the complexity of raytracing by limiting the number of objects of the scene… but it’s a good start.

I wish you to find some nice tricks of optimization, to be able to draw a more complex scene…

here are some :

  • first pass rendering in opengl : one color for each primitive : avoids you the cost of finding the initial ray intersection, use standard GL speedups (bsp…)
  • skip pixels to find intersecting objects and go back when they change (works if your primitives are big enough)
  • limit field of view (don’t scan primitives too far away)
  • space partitioning (divide space in cubes, affect primitives to one or more cubes, and have the ray walk through the cubes) : much much harder but some examples can be found on the web (i haven’t published my version… which is far from perfect and unreadable)

I’ll update bubbleracer one day with those two tricks (which are in another raytrace engine of mine).

Good luck !

Lilian

To Lilian,

The tricks you mentioned are definitely worth trying if one wants to make 100% ray tracing grapics. But the world is never perfect, i am thinking the idea to combine the ray tracing algorithm with polygon modeling, that is first sort all the polygons using a BSP tree, then perform ray tracing on the pixels that belong to a polygon which is visiable to the camera and has special porperties (eg. transparent, deflectable …). In this way we can greatly reduce the number of rays. In your bubble racer program, it will be faster just to trace the pixels bounded by the circles not the entire screen. The shadow somehow is a problem since we dont trace the pixels from the ground any more, but we still can make pretty realistic shadow using other methods.

I know the resultant graphic will be less impressive than the real ray traced graphic, but we will gain a lot more frame rate while still keep half
of ray tracing properties. I will consider this a big achievement.

I hope these make sense.

cheers!