Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 


Submitted by Ono-Sendai, posted on November 16, 2001




Image Description, by Ono-Sendai



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]

     
    Message Center / Reader Comments: ( To Participate in the Discussion, Join the Community )
     
    Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
     
    lycium

    November 16, 2001, 11:23 PM

    firstly, it's not groundbreaking (it wasn't even my idea even though i wrote it in that tutorial, it's been around for ages, check this: http://citeseer.nj.nec.com/bala98boundederror.html) and it's been done a lot before.

    secondly, it's very realtime on my crap celeron 750mhz (ignore the fps counter, it's definitely wrong).

    don't try to blow someone out of the water just because you don't understand what's going on.

     
    lycium

    November 16, 2001, 11:24 PM

    "some guy called lycium"... eesh...

    ah well, glad it actually did some good :)

     
    lycium

    November 16, 2001, 11:34 PM

    those polygons are not getting raytraced, those polygons are NOT modeling a sphere.

     
    lycium

    November 16, 2001, 11:39 PM

    some points to ponder:

    1.) the polygon counts he's referencing are NOT getting ray traced / rendered as polygons, they are being used to inperpolate the underlying image.

    2.) he's NOT just taking an NxN rendered window and blowing it up using bilinear. read my article (he's got a link to it at the top) to find out what it does before you start making claims about how much faster your ray tracer is if you were to just to blow it up.

    3.) i'm pretty confident that his fps counter is wrong :)

    4.) at 1024x768 a lot of time will be spent just drawing, so it's not a reflection of the ray tracer's speed (granted, it's a bit stupid to do ray tracing at 1024x768 just for the sake of it being "hires", but anyway)

    5.) no, he's not paying me to defend him ;)

    i'm quite astonished how people just slag this guy off without knowing what they're talking about...

     
    Impossible

    November 16, 2001, 11:45 PM

    Awesome, very cool technique. I get about 14 fps average on my PIII 733Geforce 256. Can't wait until I can run it on my Athlon 1.4Geforce 3 :)

     
    DirtyPunk

    November 16, 2001, 11:54 PM

    I think that this is actually a pretty neato implementation actually. Runs reasonably fast on my system and looks pretty good.

    Good job ono! I remember that first demo of yours I had with the wavy water simulation.

     
    Megahertz

    November 17, 2001, 12:07 AM

    First off i wanna say this looks really cool. I played around with it a bit and well its..... pretty cool =)

    Secondly, regardless of the FPS, this is 'realtime'. Its all dynamic and generated on the fly and not just a playback of pre-recorded/pre-rendered frames of animation. Yes, I'll agree its not 'fasttime' but this still counts as 'realtime'.

    In any event, its good to see projects that are exploring the possiblities of RTRT. Granted we dont have the hardware to generate complex images at 60+ FPS today, but perhaps this is where the future of 3d graphics lies, a future where everybody is running 100+ GHz machines and possibly hardware accelerated raytracing gfx cards. =)

    Gerald Filimonov
    -=[ Megahertz ]=-

     
    Ono\Sendai

    November 17, 2001, 02:12 AM

    Hi all,
    Thanks for all the comments.
    Hopefully I didn't sound too arrogant, Sagacity is right rtrt has been done before, most notably in the demos Fresnel and Fresnel2 by Kolor which are a lot more advanced than my engine. Still, not everyone has seen these demos:).

    Ron: no there is no algorithm for dealing with small objects. it would be easy enough to code though, just project small objects onto screen and mark position on screen for enforced subdivision.

    Angelo: Yes at the moment the spheres are fully reflective. Also the specular lighting is actually wrong as it multiplies the texture instead of adding to it. The next step as u said is to do more than 1 pass over each quad for reflective textured surfaces.

    DirtySouthAfrican: hhmmn yes probably the tex size is too big (1024x1024) sorry :( If u are really desparate u can resize it.

    Louis: I don't know what u mean by 'faking' the reflections..
    I can assure u the reflections are 'real' :)

    Genu: I plan to optimise it more and more and more :)

    Coriolis: yes you are right, what I thought was approximate is actually exact :) my mistake.

    I don't have an exact definition of realtime, but as you can interact with this and get a near-instantaneous response, I'm pretty damn sure it's realtime.

    One last thing people might be interested in, I tried doing the phong lighting in hardware by setting up the lights as OpenGL lights etc.. It was faster, but visual quality was actually worse around shadow edges (no interpolation). Also I have not yet figured out how to handle hardware lighting of reflected objects.

     
    Frans Bouma

    November 17, 2001, 06:31 AM

    I wonder how many FPS you'll get with 2 dynamically generated cubemaps and 1 projected shadow texture that's used for every shadow a sphere makes. THEN you use the advantage of hardware acceleration. :) Now I really don't see the advantage of OpenGL in this. You have to upload the texture per triangle anyway, so why not use DDraw for that?

     
    davepermen

    November 17, 2001, 07:33 AM

    its simple: dont mess with rastericing.. its very simple to render this grid with opengl, so why messing around with it yourself? sure it _could_ be faster without opengl, and most of all you could do simple pixelprograms wich are hardware-dependend else, but heh, its simple and you fast get a nice visual result.. and so he used it. why not?

     
    Blaze

    November 17, 2001, 08:24 AM

    How do you measure your FPS?

    As lycium pointed out in a previous post, the FPS counter is defect. It seems as if you're using QueryPerformanceCounter but you're forgetting to divide the result by the frequency (QueryPerformanceFrequency), or you're using a magical number.

    This is just a guess, but on one of my pc's it runs really smooth and gives me a FPS around 10, which is not right. On my other pc the sphere movement is erratic (but updates frequently) and it gives me an FPS of 0.002, which is definitely not right.

    Btw, you really should have used a decent texture when you’re going to show of on flipcode.

     
    Vince

    November 17, 2001, 09:19 AM

    I got the black squares around the flares too... TNT2 M64 AGP, PIII 550 Mhz.

     
    sagacity

    November 17, 2001, 10:04 AM

    He's using OpenGL to accelerate the quadtree drawing, he's not just doing software stuff and then uploading that to a texture.

     
    L.e.Denninger

    November 17, 2001, 10:52 AM

    yadayadayadayada you shouldn't say people don't understand what's going on just because they don't start screaming "ohmygoditsthecoolestengineIeversaw!".

    It's pretty damn easy to understand what's going on, it's a very old technique, it's not special, it doesn't look as good as most other raytracers, and it's not that fast either afaict. (Still think the fake lensflares should be dropped :))

    Not to say the author didn't do a good job, but if you post an image and start shouting "it's amazing!!! using space-age-technology!!" you can expect some people to put your feet back on the ground :)

     
    Chrysomite

    November 17, 2001, 11:25 AM

    So where's your realtime raytracer?

     
    L.e.Denninger

    November 17, 2001, 11:42 AM

    Depends on which one you mean, the ones in my code-dumpbin of 5-year-old-or-older stuff or my latest one ? :)

    And even if I didn't have one (or more :)), would that mean I'm not entitled to respond to someone's IOTD ? (Thus, with terrainshots only people with a terrain-engine are allowed to reply ?)
    Never saw that in the forum-guide... Guess I should have read it better.

    Realtime raytracing has been around for a long time now, and it's amazing to see that every once in a while someone thinks he did the impossible again without realizing there have been 64Kb-rtrt-intro's on 386 / 486 pc's (and even much older computers in fact).

     
    z80

    November 17, 2001, 01:00 PM

    Good work, looks kewl :-) What kind of FPS are you getting if you run say 640x320?

    Seems like RTRT is popular right now -- I am working on my own RTRT right now as well, but I didnt get as far as you. I got my subdivision thingy to work, so I am ready to make OpenGL or DirectX rasterize my quads. I am only doing diffuse light and shadows for now though, no reflections or textures yet. Wanna test a few things before i throw that in.

    Keep up the good work :-)

     
    zed zeek

    November 17, 2001, 03:19 PM

    i use opengl in my rtrt so i can map a texture with the rtrt and then can display this image at say 1152x864 + will get a nice filtered image. this is not possible with directdraw. also if u use the stqandard technique youre not really gonna have the same image quality when the cameras right up close to one of the relected balls

     
    mikie

    November 17, 2001, 05:49 PM

    Looks pretty cool - ok so this is not new... but then if you take the example of the japanese with their cars. they 'borrowed' designs from america and europe first ones were not too great....and now look at what they make - some pretty decent cars with inovations!

    So good luck to you

     
    _Nameless

    November 18, 2001, 11:17 PM

    There is definately something wrong with the FPS counter. It tells me I'm getting 4-5 FPS when it's at least 40-50. I used to play Half-Life on a Pentium 100Mhz -- now THAT is 4-5 FPS.

    Make sure you download the program and check it out before critisizing its frame per second rating.

     
    altoids

    November 20, 2001, 05:27 PM

    No, that would be Angelo Mottola.

     
    This thread contains 51 messages.
    First Previous ( To view more messages, select a page: 0 1 ... out of 1) Next Last
     
     
    Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.