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


Submitted by TopcaT, posted on June 22, 2001




Image Description, by TopcaT



Well, ray traced images seem to quickly becoming more popular than shots from landscape engines. In keeping with my "me too" programming philosophy, here's an image from my ray tracer which I've been working on over the last couple of weeks in my spare time. The image took nearly 20 minutes to render at 1600*1200 with 4*4 antialiasing. I rendered it for my wallpaper and I run in a pretty high screen res :)

Currently it's feature set is pretty small and nothing too special:
  • A simple scene file parser
  • Reflections
  • Texture mapping with bilinear filtering
  • Perlin noise blending multiple submaterials [in the image, red, yellow and black]
  • Bump mapping
  • Lame 'hard' shadows
  • It's nothing really special, but it's fun to write and produces some fairly nice images. If you like, you can download the source and a sample scene file from www.bsod.co.uk

    Cheers,
    TopcaT


    [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.
     
    ecko_53

    June 22, 2001, 02:28 PM

    That image looks friggin sweet! I always love a good raytracer keep up the good work

     
    ubermuffin

    June 22, 2001, 03:35 PM

    I downloaded the source. There are a few minor problems compiling under gcc, but nothing too drastic (except that I'm afraid the lack of a sqrtf function in gcc slows calculations down -- I had to change sqrtf(x) to (float)sqrt(x) in helper.h). Also, why not include a makefile or Visual Studio project file or some such in the download?

    Anyways, I just got the raytracer compiled and I'm eagerly awaiting the completion of its first render... been going a couple minutes now on my Celeron 600-some MHz.

    The image looks awesome and I've always wanted to code a raytracer, so you can bet I'm eager to look over your code.

    -ubermuffin

     
    DarkReaper

    June 22, 2001, 03:53 PM

    Cool...I still haven't gotten around to writing my own raytracer :)

    I'm probably doing something wrong because I'm trying to get it setup before I go home, but I'm getting an error.

    LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
    Debug/raytrace.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

     
    ubermuffin

    June 22, 2001, 04:02 PM

    Hee hee -- I just realized the reason the raytracer was taking a "couple minutes" (read: 20 min, 26 sec) was that it was rendering a 6400 x 4800 pixel image! Still, that's much quicker than the 90MB download it would've taken to download the image off the net on my 56k connection...

    It works real well -- when I changed the image size down to 640 x 480, I got a great rendering time, around 12 seconds. Good job!

    -ubermuffin

     
    Chris 12345

    June 22, 2001, 04:06 PM

    Hmm this is just a hunch, I havent looked at anything yet, but seeing in previous posts that it compiles in both windows and linux environment would probably rule out Win32 API (WinMain). What compiler are you using ? That error looks like Visual Studio, try setting the project to console application.

     
    TimD

    June 22, 2001, 04:32 PM

    I'm having the same problem. I tried to set things up in VC6 under a
    Win32 app.

     
    Kurt Miller

    June 22, 2001, 05:01 PM

    I haven't looked at his source, but you probably need to create a win32 console app rather than a regular win32 app. just a guess;

     
    shrike

    June 22, 2001, 05:01 PM

    That is a big image, but for such a simple scene, I would think that a ray tracer would go a bit faster. How does the time scale? Are you having memory thrashing?

    Maybe I am just being silly. If you want you can see some stuff that i did under similar lines here. Don't look too much though. I plan on posting that stuff as an iotd sometime. I have just been too lazy to figger out how.

    Actually, could somebody tell me how to submit an iotd?

     
    Kurt Miller

    June 22, 2001, 05:09 PM

    ">>Actually, could somebody tell me how to submit an iotd?"

    Sure. As quoted at the bottom of this page:

    "Care for a free plug? Have you got an image you'd like to see posted here for other visitors to check out? Snap a shot of something you're working on (anything!) and if its cool, we'll post it up here along with your name and the description for all the world to see. So, don't hesitate and don't forget the description explaining what the image is and why you sent it. Images without sufficient descriptions will not be posted. This is a developer site, so don't be afraid to include tech details. We may convert / resize your image for compatibility, and unless you specifically request otherwise, your e-mail address will be posted with your image as well. Send an image today!"

     
    johnnyblade

    June 22, 2001, 05:10 PM

    Nice iotd. I can't help but feel there's something a little off with the reflections though... it's like they should be different considering the way the floor is angled, but I don't know how. Other than that, excellent.

     
    shrike

    June 22, 2001, 05:11 PM

    I now realize that I was blind. It says really plainly how to submit. One thing that I would like to know is if the image should be sent as an attachment, or if a link to where it can be obtained should be included.

    Also, are the submissions read by an actual person before they are added to the queue, or is it automatic. Forgive me. I am an iotd neophyte (is that spelled right).

     
    Kurt Miller

    June 22, 2001, 05:18 PM

    Yes, I read the descriptions and view the images before they're added to the queue. The top reasons for images not "making it" is either that their description is not sufficient (ie, "Here is my game. That's all."), or their description doesn't actually describe what the image shows. If you have any other questions, please e-mail me so we don't clutter up this gentleman's iotd thread :) Thanks...

     
    lycium

    June 22, 2001, 07:20 PM

    nice rt shot :)

    i might post an iotd at some point of my ray tracer, as soon as i get some key features in there (texturing, soft reflections, refractions, global illumination using path tracing, caustics, etc). which should be in about 2-3 weeks, if i pull my arse cheeks together real hard and code like carmack in heat.

    forgive me, it's 1:17 am :) everyone: submit more ray tracing ITODs!

    oh, and i'd love to know how you're doing your bumpmapping (ie. how you generate your U and V directions orthogonal to the normal) and texturing.

     
    lycium

    June 22, 2001, 07:28 PM

    it suddenly occured to me that you have the source online :)

    is it just me, or don't you calculate the U and V direction vectors on spheres? it's pretty easy to get them on planes, as one might imagine :)

     
    red-eye

    June 22, 2001, 07:46 PM

    I had a hard time figuring out how to calculate the orthogonal vectors. What I ended up doing in my ray tracer is instead of finding the vectors orthogonal to the normal, I calculate a transformation to align the normal with the positive Z axis. Then I use positive X and positive Y as the orthogonal vectors. The perturbation is performed about the origin. After that I transform the perturbed normal by the inverse of the previous transformation.

    This is probably not the most efficient technique, but it should work for any surface.

     
    Catfish

    June 22, 2001, 07:55 PM

    Why's it always spheres & planes with raytracers? It is simply the difficulty of generating the coords needed for a torus (say)? Or is the actual raytracing procedure on a sphere much easier than on a torus?

    Quite pretty IOTD, btw.

     
    Lucid

    June 22, 2001, 08:57 PM

    Heh, that was discussed last time a ray-tracer image was posted...
    http://www.flipcode.com/cgi-bin/msg.cgi?showThread=05-30-2001&forum=iotd&id=-1

     
    z66831

    June 22, 2001, 11:34 PM

    Just for kicks I grabbed the source and added a loop (and removed the logging and profiling) to do a fly-by of the scene in realtime. At 160x100 the tracer gets anywhere from ~2 to 10 frames per second on his default scene.

    Right now it just dumps the whole animation into a stream of targa files on disk... I'm adding a win32 wrapper so it can render to a dib in a window, and some sine wave stuff to make the animation a little more interesting than a lame fly-by. :)

    I'll let you guys know what happens. Hey Kurt, can we have an AOTD (Animation Of The Day) section? :)

    -z

     
    a_j_harvey

    June 23, 2001, 12:12 AM

    What about BOTW - book of the week?

     
    Prunesquallor

    June 23, 2001, 02:03 AM

    The reflectance of the sphere seems a bit unrealistic. Are you using Fresnel's law? In real materials, as the angle between the camera ray and the normal of the object increases, so does reflectivity. Seems here you're using a Phong model. Too bad Phong has become so popular, when it is not at all physically based; it doesn't even meet basic constraints like conservation of energy. There are many other BRDFs that produce far more correct images, and they are not necessarily much more complicated than Phong.
    Replying to the person asking why we all start with spheres and planes in our ray tracers, they simply provide the most trivial intersection tests. Additionally, the most common triangle intersection algorithms usually find the intersection with the triangle plane first, and then check if the point lies within the triangle itself (BTW I've tested several triangle-intersection algorithms, and the best one is a barycentric coordinates test, where the geometry is projected on a 2D plane parallel to one of the axes).

     
    Kurt Miller

    June 23, 2001, 02:18 AM

    That's a great idea... thanks! It should keep the book section from rotting away like it seems to have done.

     
    Chad Austin

    June 23, 2001, 06:04 AM

    If gcc 3.0 is as C++-compliant as everyone says it is, there should be at least three versions of sqrt. One for float, one for double, and one for long double.

     
    lycium

    June 23, 2001, 06:24 AM

    which BRDFs would those be? :)

     
    tcs

    June 23, 2001, 09:01 AM

    Really cool. The source is under 60K, so with some clever coding and a good exe compresor like UTX you should be able to make a cool 64K realtime-raytracing into...

     
    CGI Joe

    June 23, 2001, 03:02 PM

    Yeah, do it in text-mode. Hehe, that would be fun.

     
    Prunesquallor

    June 23, 2001, 09:47 PM

    There are more BRDFs than you can shake a stick at. A good place to start is the NEC ResearchIndex at http://citeseer.nj.nec.com/ , just search for BRDF. A good model is provided by Christophe Schlick in the paper titled "An Inexpensive BRDF Model for Physically-based Rendering", and another I recommend is presented in Peter Shirley's ray tracing book. If you want to get fancy, there are a number of databases where BRDFs were actually measured for actual materials.
    Note also that BRDFs are only half the story--they completely ignore subsurface scattering, which is especially important in rendering realistic skin, and other inhomogeneous translucent materials like marble, etc. Check out Henrik Jensen's page for some interesting images here http://graphics.stanford.edu/~henrik/images/subsurf.html
    Jensen also invented photon maps, which is the best global illumination technique, and beats radiosity in speed, generality in terms of scene geometry and materials, and it automatically handles caustics; some photon map example renderings Jensen made http://graphics.stanford.edu/~henrik/images/global.html

     
    DirtyPunk

    June 24, 2001, 03:22 AM

    Actually, the best triangle intersection method is the plücker space method :) You get an early out test with every edge (each edge test is extremely quick) and after that you can find the intersection barycentrics quickly. :)

    Not only that various schemes can re-use the Plücker dotproduct calculations in adjacent triangles as well as allowing you to more quickly traverse to the correct triangle to intersect :)

     
    lycium

    June 24, 2001, 11:49 AM

    i wouldn't go so far as to say that photon maps are the best global illum method... i personally think that metropolis light transport is the best global illum technique you'll find right now. if the problems present in the paper (by Vaugh and wassisname... La Fortune) are ever solved, you'll have what's likely to be THE method for rendering. then all you need is hardware accel... :)

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