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

Submitted by Bram de Greve, posted on April 16, 2001

Image Description, by Bram de Greve

It's really suprising what (amazing) things you can do with raytracing. I built the program that generated this pics completely from scratch with no more than a simple "sink" (OpenScreen(), DrawPixel(), CloseScreen()), some simple "3D-in-4D" math (planes, spheres and rays), simple lighting rules (ambient, diffuse and specular lighting), simple optica rules (reflection and refraction), simple inheritance for classes that share common functions (like the different objects, textures, lights), and some other things ... I would say, if you want to learn program in C++, you don't want to dig in weird algorythms and you don't care about bad performances, then you should built a raytracer: it gives you the most satisfaction at the lowest costs.

The Humble Features:
  • Colored lights and Ambient, Diffuse and Specular lighting
  • Texture- and Bumpmapping
  • Reflection and Transparency
  • Refraction for viewing rays, but not for shadow rays
  • You can see it drawing pixels realtime :)
  • The Humble Scene:
  • The floor has a flat texture map, primarily specular enlighted and a little reflective.
  • The ceiling is a single colored bumpmap (very hard to see, if not impossible) and diffuse enlighted.
  • The walls are bumpmapped, texturemapped and diffuse enlighted.
  • The 3 lower balls are white, primarily specular enlighted and very reflective.
  • The upper ball is blue, very specular, very transparent and a very little reflective (very hard to see). The inside of the upper ball has a refraction index like glass (about 1.4), everything else is like air (about 1).
  • 3 point lights in 3 different colors: red, green and blue.
  • The Humble Pics:
  • Upper-left: The scene without bumpmapping.
  • Upper-right: The lighting of the scene. All textures, reflection had been disabled; transparency for shadow rays are still enabled, but not for viewinig rays. Although the floor and walls have in se the same color, the floor looks much darker; this is because the floor uses primarily specular lighting and the walls use diffuse lighting.
  • Lower-left: The lighting of the scene with all reflection and transparency enabled.
  • Lower-right: The final scene with bumpmapping.
  • The Humble Figures:
  • On a 1GHz Athlon, this scene costed 20 seconds to render at 640x480 1 ray per pixel, and 16 minutes at 1280x1024 4x4 (brute-force) rays per pixel. That makes about 20000 rays per second.
  • Anyway, Greetz to you all crazy coders,
    Bram the Bramz

    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 16, 2001, 12:10 PM

    Wow, that is impressive! I remember doing my first raytracer, and I certainly agree that if you're interested in learning a bit, try optimizing a raytracer. It's tricky, but worth the time. And you even get gratification sometimes! Anyway, good work and keep it up!



    April 16, 2001, 12:32 PM

    Very nice! How much time did you spend on this project?


    April 16, 2001, 12:34 PM

    Very pretty. Raytracing is always fascinating.


    April 16, 2001, 12:40 PM

    Very nice. Where did you learn how to make a raytracer? Anyone know any good places to start? How long did that take you?

    Darshan Patil

    April 16, 2001, 12:51 PM

    >I would say, if you want to learn program in C++, you don't want to >dig in weird algorythms and you don't care about bad performances, >then you should built a raytracer: it gives you the most >satisfaction at the lowest costs.

    How Very true.......

    Amazing work dude.

    Keep it up.

    Kurt Miller

    April 16, 2001, 01:02 PM

    ">>Anyone know any good places to start?"

    I believe PolyGone has some intro ray-tracing tutorials.

    Jesse Yurkovich

    April 16, 2001, 01:02 PM

    Hey, anyone know if you can speed beasts like this up for realtime simulations/games?

    How about using some new vertex and pixel shaders in hardware to do this stuff? Is it possible?

    Honestly, for the past few years in computer graphics techniques, iv always stayed away from raytracing dissin it as only academic fun :)
    Now I _SEE_ where i went wrong. Man how i would love to see realistic glass and reflections in the next Doom.


    April 16, 2001, 01:30 PM

    Great images - raytracing certainly is one of the most satisfying "bang for buck" things you can code.. the visual feedback when you get something right, is the reason us game programmers do the jobs we do for the shitty money (compared, say, to writing databases.)
    Oh - and just to be picky - Im pretty sure you're descriptions of the two bottom pics are the wrong way around ^_^

    Jari Komppa

    April 16, 2001, 03:09 PM

    Some real-time raytracing stuff has already been done, on the demoscene.

    The basic idea is that you raytrace in as low resolution as you can get away with and interpolate the result (eg. when raytracing a sphere, you need to cast more rays on the edges than on the center).

    I don't think rtrt will be plausible for game use any time soon though, since you can get much better visual result using plain polygon graphics.

    Anyways, hit google with "real-time raytracing" for several hits..


    April 16, 2001, 03:30 PM

    I would be very interested in finding out how long it took to program and how good is your programming skills because that pic looks amazing I would sware that it was done in a commercial package and yet you say it was easy to do and not to time consuming and the results speak for them selfs. I have fairly good maths and physics as I have done these up to the highest level at school and will soon be at uni doing more maths (part of the joint homours C.S and A.I).


    April 16, 2001, 04:28 PM

    Where do you get your nice textures?



    April 16, 2001, 05:11 PM

    .. But not so humble PC

    Well, actually complex things consists of simple pieces, and if they all are working well and well composed it gives something principially new
    which appears to us complex.

    1&0 it's humble ? But result is not so humble.


    April 16, 2001, 06:24 PM

    raytracing hack idea (there was tunnel demo describing it).

    So if you have 512x512 window, you can raytrace 64x64 pixels (making screen of 8x8 sized 64x64 blocks). You can calculate U,V,COLOR,SPECULAR,,OBJNUM for each of these pixels and then draw a textured squares using this data. This will work just for objects for which 4 neighbour points are from one and same object, for overlapping objects you have to subdivide or leave something random on the scren.

    This tunnel demo was included in PTC - and i've seen that idea there. Don't know if this will work for raytracing - never done any raytracer. But it may accelerate (and makes the things ugly :)) (for the TUNNEL demo)


    April 16, 2001, 06:25 PM

    opss sorry it's not :))


    Jason Wood

    April 16, 2001, 08:54 PM

    Spheres rule. Very nice pics.


    April 16, 2001, 08:56 PM

    This makes me want to write a raytracer. How long did it take you to code the whole thing?

    - Impossible


    April 16, 2001, 11:19 PM

    Nice effects! Probably wouldn't un on anything less than what you've got, though!


    April 17, 2001, 01:23 AM

    Take a look at this, it will probably do raytracing in 800x600 or 1024x768 on your athlon 1.3ghz in realtime:


    April 17, 2001, 02:02 AM

    This makes me want to submit a pic of the ray tracer that I made a couple of months ago. How do you submit?

    Jonas Norberg

    April 17, 2001, 04:11 AM

    Great Work!

    You also have good taste in choosing lights and textures. Great pictures.

    Joachim Hofer

    April 17, 2001, 06:48 AM

    Well... might work...


    April 17, 2001, 10:24 AM

    That's a pretty fancy picture you got there! I have a book on the subject and have been meaning to get around on it...what algorithms do you use? Is there a demo we can download? And what drawing methods did you use? API such as DirectDraw, or OpenGL (or what?)?

    Great Pics though!

    henry ludemann

    April 17, 2001, 11:24 AM

    That looks really good... inspires me to go into that area just for the pretty pictures! I like the top right image, due to the fact that the bump mapping on the walls are so much more pronounced. I think the falloff on the lower left image is far too heavy (the bottom right corner is almost black!).

    Keep it up...


    April 17, 2001, 02:39 PM

    OK, this might be a little late for a reply (since the IOTD is already refreshed :), but I want to answer some of your questions:

    [-WD40-], How much time did you spend on this project?
    I dunno exactly. It took me some weeks to find to concept and bringing it to a stage without imagemaps, bumpmaps nor transparency. That was some months ago, still on my old PC. Moving on to all the current features was only a matter of days. Most time was lost in figuring out how to write pixels to the screen on the new machine and how to read in TGA files (since I've never done that before :)

    Darkreaper, Where did you learn how to make a raytracer? Anyone know any good places to start? How long did that take you?
    I've learnt it in school. It doesn't take long since raytracing is a very simple thing. Just some basic theory you need to understand and off you go. PolyGone is a good place as Kurt Miller mentioned. The book 'Real-Time Rendering' also explains it very good (that's where PolyGone's got its information :)

    D.P., I would sware that it was done in a commercial package and yet you say it was easy to doWith raytracing it's not difficult to get amazing pictures, since all the beauty is inherent to the simple rules. The only problem is doing ... fast. I don't know how fast (how slow is probably a better word) my program is. Maybe I should build the same scene in POVray and see how fast that one does it ...

    morgan, Where do you get your nice textures?
    I don't know anymore. Just type in google 'free textures' and see what you can get

    disableddan, Nice effects! Probably wouldn't un on anything less than what you've got, though!
    I wouldn't say that. As I already mentioned, I've started this project on my old machine. And that was a 486 DX2 66MHz. It was exactly the same scene but without image and bumpmapping and without transparency (although the upper sphere was reflective then, so that compensates :) On 640x480 pixels 3x3 rays per pixel, it only took ... 3 hours :) So, with texture and bumpmapping, I would say it would have taken about 4 hours, since the mapping itself isn't that much of an overhead.

    Anyway, it's was a fun thing to do,
    cheers to all you out there (especially the Flemish people (and the Dutch too :) )


    April 18, 2001, 05:13 AM

    Btw. for sime nice realtime raytracing check out 'Nature still suxx/FAN' from the MS2001 demo compo. Real nice, should have placed higher in the compo if you ask me..


    April 19, 2001, 09:45 PM

    bang !

    This thread contains 26 messages.
    Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.