Using the Chapter s Code

[ LiB ]

Using the Chapter's Code

The CD materials for this chapter contain an example of the photon mapping application (in /Book Code/Chapter13/Photon Mapping) . The general design of the application is the same as the previous applications in this book. The environment of the photon mapping application is exactly the same as the previous application. This application incorporates the KD Tree algorithm. The folder that includes the required classes for this program is in /Book Code/Chapter 13/Photon Mapping/Common . The files in this folder are:

 12/21/2002  05:19p        1,381 cLight.h 12/21/2002  05:19p        5,127 cObject.cpp 12/21/2002  05:19p        4,692 cObject.h 12/21/2002  05:19p          442 Color3.cpp 12/21/2002  05:19p        4,480 Color3.h 12/21/2002  05:20p        2,248 cPhoton.cpp 12/21/2002  05:32p        1,408 cPhoton.h 12/21/2002  05:19p           23 cRay.cpp 12/21/2002  05:19p        2,043 cRay.h 12/21/2002  05:19p       34,852 cScene.cpp 12/21/2002  05:23p        3,781 cScene.h 12/19/2002  05:29p        1,991 cVector3.cpp 12/21/2002  05:19p        5,169 cVector3.h 12/21/2002  05:19p        1,060 MathTools.h 12/21/2002  05:19p        1,108 PPM.cpp 12/21/2002  05:19p          154 PPM.h 

You compile this program as described in previous chapters. You can also run the program directly by executing the /Book Code/Chapter 13/Photon Mapping/Photon Mapping.exe file. When the program asks you to "Enter Information:", you enter:

 /scenes/photon.txt 

The program will also ask for how many photons you would like to scatter per object. A good number for spheres is 1000, whereas a good number for triangles is 1000. It will also ask you what the photon contribution is. A good number is 50.

The photon-mapping algorithm will then begin scattering photons. The program starts the ray-tracing process and then again will prompt you to enter the output path for the rendered file stored on the image plane. When it asks "Please Enter output Path and Filename:", enter:

 /scenes/myoutput.ppm 

You can then browse to that path and open up the file in IrfanView. However, I've already created the exported file for you and placed it in the following folder:

 /Book Code/Chapter 13/Photon Mapping/Output 

The file in this folder is:

 10/13/2002  03:30p           3,212,934 photon.ppm 

The program time report is as follows :

 Done Tracing Scene! Render Took 0 Minute(s) and 33 Second(s)... 

The application reports the time it took to load and render the scene with photon mapping using the KD Tree algorithm. As you can see, it took 33 seconds to render Scenes/photon.txt . This is much faster compared to the old linear method covered in Chapter 12 (which took 30 minutes and 35 seconds).

[ LiB ]


Focus On Photon Mapping
Focus On Photon Mapping (Premier Press Game Development)
ISBN: 1592000088
EAN: 2147483647
Year: 2005
Pages: 128
Authors: Marlon John

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net