See what's going on with flipcode!




 


Submitted by Michael Pote, posted on 07 April 2004



Image Description, by Michael Pote


Lightmappers seem to be very scarce these days, so I'll push aside the pile of ray tracers and show you something more primitive :-).

In 2002, after writing my Foundry demo for the gamedev.net contest, I decided to write a lightmapper of my own since I used the excellent FSRad radiosity lightmapper for the demo.

So after about 6 months of work, this is an alpha version of my lightmapper which integrates all aspects of the mapping and lighting of any scene. Features (in chronological order):
  • a.. 3DS file loading with intelligent normal generation (Sharp corners stay sharp while preserving smooth curves)
  • b.. Planar Mapping
  • c.. Packing of lightmaps into a large texture using binary space partitioning (From this tutorial)
  • d.. Lambert Shading Model
  • e.. Shadow Casting with ray-plane intersections.
  • f.. Lightmap Filtering
  • g.. Octrees (Used for drawing the scene, and originally helped with shadow casting, but later was removed)
  • And there the project stopped for a while. There were still inaccuracies around the edges of individual lightmaps and the shadow casting routine was very slow, but I was happy enough to play around with it.

    Then when I actually thought about it, I figured that my method of shadow casting needed a rewrite. It was originally simply iterating through all the triangles in the scene and tested each one against a ray cast from each light, without any optimisations. So I sat down and sketched out a design for shadow volumes. I'd never done any sort of research on shadow casting before so it was my own idea, but quite a simple one. Instead of testing each triangle, the program precomputes a truncated pyramid for each triangle in the scene, starting at the triangle and extending out away from the lightsource, then tests if the point is inside that. Needless to say, the algorithm was 12 times faster than the original!

    The lightmapper still needs some work, especially with smooth objects where seams can be seen, and I'm also looking for a fast way of computing soft raytraced shadows.

    The image shows the main interface for the program along with a few scenes rendered in real time with lightmaps, and a lightmap which has been packed using the BSP method. The lightmapper was written completely in Delphi using OpenGL for rendering.

    Questions and comments are welcome,
    Michael Pote



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