Tuesday, April 24, 2007

Ray tracing the future of Gaming

I love the Inq (the Inquirer). I'm not sure who their writers are but I usually seem to find out about new things there first. Last night I read this cool article about work going to support real-time ray tracing to render 3D graphics. After a Google search, I found the real article that this guy was referring to here on PC Perspective. It's based on research happening at Saarland University in Germany where they've developed an API called OpenRT, which of course is similar to OpenGL. They also have a prototype so that you can try it out.

I remember back in university almost 20 years ago now a couple of buddies of mine that were doing ray tracing for their graphics class. The images they produced were pretty cool and realistic for the time. But it took overnight to generate one frame. Mind you that was on good old Sun 3's, but you certainly wouldn't think of doing this in real time, even today.

The ray tracing demos you'll find in PC Perspective article and at the OpenRT site are amazing, though. From what I've read, doing shadows in current technologies like OpenGL or DirectX is very difficult and game developers almost always take short cuts, which leaves the scenes a bit unreal. But with ray tracing, it appears to be much easier and the scenes appear much more believable, which is the end goal for all 3D animation.

What's changing is the march towards many multi-core CPUs by Intel and AMD. One of the big advantages of ray tracing it the scalability of the algorithms to parallel threads. Each pixel is determined independently of the other pixels. All you need to do is partition the screen to the cores and you get almost linear scalability in performance.

Now, mind you, the demos I saw, especially the one from the OpenRT site, used a lot of cores, mainly 32 and one was even at 48. But I imagine there's opportunities for improvement given this early stage, and even for some hardware acceleration for parts of the algorithm. But if you were wondering what you were going to do with that quad-core furnace of a chip, here's one idea. And it's pretty interesting to see that Intel caught on to this idea a couple of years ago.

4 comments:

  1. this is why NVidia bought Larry Gritz's company, Exluna, and hired Larry Gritz himself. Larry is a former Pixar developer, he worked on PRMan, Pixar's implementation of their own Renderman scene description language.

    Given the sheer amount of specialized silicon on a modern high-end graphics card, real-time raytracing is actually quite attainable these days -- and relatively cheaply to boot.

    Performing real-time raytracing on general purpose CPUs like what Intel produces will probably never reach what is possible with GPU processing power during the same timeframe.

    ReplyDelete
  2. Actually, I had a line in an earlier draft of this entry mentioning NVidia's CUDA. I think that would be an awesome application.

    ReplyDelete
  3. The University of Saarland also developed a driver for accelerating ray-tracing with a special programmable FPGA [1]. The idea was to prove that with a special card (which should be quite similar to a graphic card: computing vectors of floating points number should be fast) ray-tracing can replace rasterization (which most games use now days).

    With that programmed FPGA (only clocked at 60 Mhz) and a special data structure to hold the objects in the space, ray tracing demos were able to run on a normal PC (with only one core!) up to a rate of 30 frames/s!. [2]

    Finally, the Cell processor (used by the playstation 3) is also very good at ray tracing.[3]

    [1] RPU: A Programmable Ray Processing Unit for Realtime Ray Tracing
    [2] B-KD Trees for Hardware Accelerated
    Ray Tracing of Dynamic Scenes

    [3] Ray Tracing on the Cell Processor

    ReplyDelete
  4. @jeremiah:
    You can't do conventional ray-tracing on a conventional graphics card - all it's specialized silicon is specialized to do fast rasterization. Sure you can pull some tricks, but it is not true ray tracing. Ref helloworld82's comment for some cool hardware based ray tracing implementations. Until that becomes mainstream, we'll be doing it in software. Thankfully, the algorithms parallelize nicely so with the current trend of CPU's towards hyperthreading and multi-core, it becomes a more and more realistic prospect to do it in real-time.

    mental images has been working on some really cool software to do real-time raytracing on arbitrarily large models. It's actually a really cool product with a lot of potential for web 2.0.

    RealityServer

    Candello

    Enjoy!

    ReplyDelete