Lattice-Boltzmann Lighting Models 

Source Code 
Robert Geist

The components included here are:

1. The OpenCL lighting code.
2. A sample cloud density file.
3. C code to convert density plus lighting 
   into a voxel file.
4. A C code voxel file viewer.

Details:

   The OpenCL lighting code comprises 3 files, ocllight10.cpp,
   ocllight10.cl, and ocllight10.h.  Compiling depends upon
   where OpenCL lives on your system.  On my Linux (CentOS 5.5)
   system, the compile line looks like this:

mydir=/usr/local/NVIDIA_GPU_Computing_SDK/
/usr/bin/g++44 -O2  -DUNIX                              \
-L $mydir/OpenCL/common/lib/Linux64                     \
-L $mydir/OpenCL/common/lib                             \
-L $mydir/shared/lib                                    \
-L $mydir/shared/lib/linux                              \
-L /usr/lib64                                           \
-I $mydir/OpenCL/common/inc                             \
-I $mydir/shared/inc                                    \
ocllight10.cpp                                          \
-lX11 -lGL -lGLU -lglut -lGLEW_x86_64 -lm -lXmu         \
-lOpenCL -loclUtil_x86_64 -lshrutil_x86_64 -o ocllight10

   To execute on the supplied cloud density file, ii9.density:

ocllight10 ii9.density > ii9.lit

   Execution time depends on your platform.  On a GTX480,
   it's 6 seconds.

   To visualize the results, you'll need to convert to a voxel
   file with the supplied converter, litkarl_to_vox, and then use 
   the supplied voxel viewer, vview.  Both the converter and the viewer 
   are ordinary C code.  Compilation is system-dependent; on my system it is:

gcc -L/usr/lib64 -O2 filename.c -lX11 -lGL -lGLU -lm -lXmu -o filename

    To convert:
   
litkarl_to_vox ii9.density ii9.lit > ii9.vox

    To view:

vview ii9.vox

    Danger Will Robinson!  The viewer is an interactive, "fly around" viewer.  
    The basic operation is: point the cursor where you want to go and hit
    the left mouse button.  But, the cursor position controls both direction
    and dynamic rotation.  So, until you're an experienced pilot, keep it
    close to the center of the image to avoid tailspins.

    Controls are:
    left button = zoom in
    right button = zoom out
    middle button = toggle cursor active/not
    
    Keys:
    q = quit
    x = reset system coordinates to the current eyespace; this only
        works once per flight
    r = barrel roll (can be used in combination with other movement)

    Speed:
    The viewer will NOT automatically detect or adjust to the speed of
    your graphics card.  Speed is controlled by 4 #defines at the top:

#define ZOOM_INC 0.01
#define AZ_SCALE 0.01
#define EL_SCALE 0.01
#define RO_SCALE 0.01

    Make these larger to go faster, smaller to go slower.  Default
    values work well for a Quadro FX 5600 - season to taste.

Finally, all of this is supplied (free) as part of the GPUGEMS IV chapter,
Lattice-Boltzmann Lighting Models.  I believe all the code to be fault-free,
but there are no guarantees or warranties of any kind, expressed or implied.
Use at your own risk.

-RG

