Submitted by , posted on 16 November 2001



Image Description, by


Hi all, here are some pics of my realtime hi-res raytracer. If you didn't think it could be done u were wrong :)

Here's some info from the website:

Features:
  • subdivision subsampling: this is one of the main optimisations which allows it to run in hi-res and realtime. This allows detail to be calculated only where needed.

  • Hardware acceleration using OpenGL: The image is divided up into small squares, each of which is drawn as a textured quad in OpenGL, with the colour at each vertex determined by the ray-tracer lighting calculations. This is the other main optimisation.

  • Phong lighting: The lighting model is a simple ambient + diffuse + specular thing.

  • Geometry: Objects currently included are spheres, planes, rectangles, and cuboids.

  • Light flares: Somewhat gimmicky flares around the light sources, and around primary reflections of the light off objects in the scene. Done with an additive blended OpenGl quad sprite of course :). The positions of the flares are solved analytically.

  • Quick approximate Sphere intersect test: This is my own invention, an approximate test for primary ray/sphere intersection that requires only one dot product and then a scalar compare.

    Another optimisation is that not all objects need to cast shadows. In this way the ground plane does not need to be involved in shadow checks.

  • Nice code: Code still uses operator overloading on my Vec3 class in most places and uses object-orientated polymorphism on the different types of primitives. == readable code. Of course this is slower but it shows that high-level algorithmic optimisations are sufficient to acheive hi-res realtime raytracing.
  • About the images:

    The top image shows a simple scene with a textured plane, 2 spheres and 2 light sources. The bottom pic is the same scene rendered in line mode, showing the subdivision scheme.

    As u can see from the image it is running at about 5fps on my p3-450 and geForce2, this framerate varies greatly depending on the image complexity.

    The default subdivision depth, which is used in the image above, is 3, and as the screen is originally tessalted into a 40*40 grid, that means each quad is about 25 / 2^3 = 3 pixels wide at maximum subdivision.

    I've put up a website for this at

    http://homepages.paradise.net.nz/nickamy/raytracer/raytracer.htm

    You can get a demo there. I may release the src if enough people want it.

    Most of the optimisation ideas that made this possible I got from a fantastic article by some guy called Lycium. I originally read the article (called Real Time Ray Tracing) in Hugi 23. He posted something in the flipcode news recently as well.

    You can see the article here: Real time ray tracing

    Cheers bro!

    Also thanks to NateMillar for glTexFont and some tga loading code.

    Shout out to all NZ coders!!!!

    Ono-Sendai



    [prev]
    Image of the Day Gallery
    www.flipcode.com

    [next]


     


    Copyright 1999-2008 (C) FLIPCODE.COM and/or the original content author(s). All rights reserved.
    Please read our Terms, Conditions, and Privacy information.