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

Submitted by Nils Desle, posted on April 04, 2002

Image Description, by Nils Desle

I'm working on a realtime raytracer in my spare time and have decided to release a demo (WIN32 platform) and some images of what I'm doing.

The raytracer gets its main speed increase from adaptive subsampling, i.e. I start by tracing the four corners of a N*N rectangle and compare color values. If the difference is too big, I subdivide the N*N into four N/2*N/2 rectangles and process those recursively and so on until I have reached pixel accuracy or the color differences have become too small to matter, in which case I let OpenGL draw the rectangle using interpolation. Texturemapping is done by the raytacer, not OpenGL.

The demo uses an initial rectangle size of 4*4 for the tracing since I want to show thin cylinders (casting thin shadows too) that sometimes will take up less than 4 pixels wide and risk flickering if I take a larger initial blockwidth. The demo runs fine in 320x240 on my PIII 900.

The top four images are stills from scenes in the demo, the bottom left is another scene and the bottom right is the same as the bottom left but showing only those pixels that are actually traced (shown as full white pixels here). All the black in that picture is where interpolated pixels go in the real picture.

You can find more pictures, a download and a full explanation of the engine at:

Nils Desle

Image of the Day Gallery


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.

April 04, 2002, 11:38 PM

there are a number of problems with using hardware accelerated (or indeed even software rendered) first hit testing:

1.) with hardware acceleration it's not nice having to check if each pixel has been drawn (agp read).

2.) you can't perfectly represent spheres with polygons.

3.) what about more complex surfaces, like an implicit heart (which btw i stole from your old signature and rendered direclty with my realtime ray tracer, :)?


April 04, 2002, 11:44 PM

"We're getting close to having this technology in games because PC's are now getting just about powerful enough to do this in real-time at an acceptable frame rate."

we're actually getting increasingly far away from having this in realtime because nvidia can't realise that ray tracing is algorithmically better than scanline rendering (in terms of efficiency as well, rtrt beats geforces at 100m+ triangle scenes) and is constantly pumping more power into scanline rendering. people start expecting this kind of detail, which can't be achieved with ray tracing unless we have hardware acceleration too. THEN the future will be here.

zed zeek

April 05, 2002, 12:53 AM

runs good ( a few parts of the shadows were missed in the balance demo but thats to be expected with the method u use )

Tim Baker

April 05, 2002, 02:19 AM

amen to that!

cyber lord

April 05, 2002, 02:28 AM

Ray tracing rocks!
When can we see real time interference patterns?


April 05, 2002, 02:29 AM

Do people use the word 'engine' just to confuse me or has someone defined where that words should be used now? Is this an application, engine, visualization, simulation, library, tool, game, ????


April 05, 2002, 03:12 AM

i just said for the triangles:) i know we can't draw perfect spheres with triangles;)

you've stolen MY HEART!?!! WITHOUT ASKING?!!? ok


April 05, 2002, 03:14 AM

even in the highresmode, he uses gl to draw the quads. he simply there subdivides till the pixel-accuracy..

and rtrt does work quite well for me, means i can get up to 10 - 15 fps, wich is enough to run some funny things:) and i don't subdivide but simply trace all rays! and TRIANGLES! ;) (without any hardware involved..)
can^t wait for a faster pc;) (and its even plain c++ code till now;))


April 05, 2002, 03:36 AM

First of all, thanks for all the positive reactions. It's nice to hear people like what you're doing...

Here are some replies to things mentioned in the posts above:
- Lens flares: yeah, you are all correct, they are not very good. I need to spend some more time with them to make them less obvious. I've been playing around with Serious Sam and that engine has very nice lens flares. I'll try doing something like that in the future

- fps varies on my PC. It all depends very much on the scene. The sheepworld runs at a nice 30-40fps (320x240, 1x1 pixel accuracy, 4x4 intial blocksize for subsampling), the lollypop scene, if zoomed right up to the ball of the lollypop goes down to 2 fps worst case. In most scenes, it's not the object count that decreases the fps. Texture detail and number of lights and size of reflective objects on the screen have a much larger impact.

- Antialiasing: I dunno, the engine is slow enough as it is without bothering with any of that just yet.

- Sir Llamalot: I have interactivity in my engine, it's just not activated in the demo. Maybe I'll release an interactive version that has the same timing but no camera paths and it lets you fly around yourself. Mail me if you are interested in this and I'll see what I can do. Oh, there are actually two levels of reflection at the moment. It's a #define. Ideally, I'd like to make it dynamic based on the detail the reflections are showing. You also asked about what primitives I can use, they are: Spheres, Planes, capped cylinders and triangles.

- Davepermen: I decided against using OpenGL for primary ray intersections because profiling showed me most of my time is spent in the lighting/shadow/reflection code anyway and I didn't want to base my code on OpenGL too much. Right now it's still quite possible to write a custom software renderer for my engine (first versions of the engine were based on tinyPTC) since it basically needs to be able to draw an RGB 32bpp interpolated square. Lensflares and fading out are fluff anyway.

Cheers and see you later!


April 05, 2002, 03:44 AM

Adaptive sampling is nice speed-up method though incorporates a big problem: how to determine 'problematic' region for sub-sampling? color testing is definitely not enough when considering the overall accuracy. it can be seen, for example, on sheep's eyes disappearing in the first scene. shred, uncomplete shadows casted in the last scene are just another example.

anyway very nice contribution! i like it!


April 05, 2002, 07:25 AM

actually, the heart object is referred to as the "mathematician's heart". it's not really yours :)

incidentally, do you have any more nice equations? :)


April 05, 2002, 10:17 AM

You guys are sad. I just happen to open the site when a new IOTD comes up, and make a comment, saying "FIRST" just for the hell of it. There's really nothing wrong with it, but you crackheads who get all worked up over it are the ones with the true problems.


April 05, 2002, 10:29 AM

i can't get wine to run at all, maybe its my odd setup

Neil Edelman

April 05, 2002, 10:29 AM

Very impressive speed running on this machine. Did some weird crash-like thing when running windowed and the window is closed. RTRT is beautiful. Would like to have an option to change the tolerance for the subsampling and to go into the mode in the bottom-right picture to see how different scenes work out.


April 05, 2002, 10:38 AM

...True... ...True...


April 05, 2002, 11:20 AM

> i know we can't draw perfect spheres with triangles;)

Perfect sphere projected on perfect plane becomes a perfect ellipse, right?
And we can draw perfect ellipses with perfect Bresenham method, right?


April 05, 2002, 11:40 AM

> - Antialiasing: I dunno, the engine is slow enough as it is without bothering with any of that just yet.

Some time ago everybody knew that RTRT is impossible.
So nobody "bothered" to try. Think about it.

Besides, 'sheepworld' is pretty fast.

Now you forced me to dream about writing my own RTRT. :) With AA, of course.



April 05, 2002, 12:41 PM

ok. another way of phrasation (i retry it with other words;))

i know i can't represent a perfect sphere with triangles in space.

that i can rasterice a sphere is not the question. but with rastericing only worldspace-triangles i can't get a perfect sphere.


April 05, 2002, 02:58 PM

If the goal is first hit testing, then why represent sphere with triangles in a first place?


April 05, 2002, 05:02 PM

> i can get up to 10 - 15 fps, and i don't subdivide but simply trace all rays!

in high-res mode?
that's sure sounds good. :) maybe even too good :):)

This thread contains 50 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.