📄 http:^^www.cs.utexas.edu^users^fussell^354assignment3.html
字号:
MIME-Version: 1.0
Server: CERN/3.0
Date: Wednesday, 08-Jan-97 16:41:59 GMT
Content-Type: text/html
Content-Length: 6025
Last-Modified: Thursday, 25-Apr-96 23:08:17 GMT
<HTML><HEAD><TITLE> Program 3 - Ray Tracing </TITLE></HEAD><BODY><CENTER><H1> Program 3 - Ray Tracing </H1></CENTER><P><CENTER><H2> Due - May 14 </H2></CENTER><P><CENTER><H2> NOTE - Assignment 3 is an OPTION to replace the second exam </H2></CENTER>You are to implement a simple ray tracer, which will allow for bothmirrorlike polygons and transparent or mirrorlike spheres. You mayassume that the only objects in your scene will be spheres orpolygons, and you may assume that you have only a very few objects inthe scene. Your objects should be specified as a center, radius,diffuse color, specular color, opacity, and material for spheres, andas a list of vertices (you may assume a maximum of 4 vertices) andthe two color parameters for polygons. You should also be able tospecify a color for the background of the scene. You should be ableto place the viewer anywhere in the scene by specifying an eye, lookatpoint, and top of head point, and you should be able to specify thewidth, height, number of pixels wide, and number of pixels high ofa window centered a distance d (specified by you) along the viewingvector.<P>Your goal will be to produce an interesting picture of at least onemirrored sphere and one clear sphere in front of a large polygonalmirror, showing interreflections and refraction effects. You canassume that all light sources are directional (points at infinity),and that you have no more than 3 light sources. You should also beable to specify the position of these. All specifications of thescene geometry should be in an ascii input file, which your programreads to produce the internal description of the situation. You thenrun the ray tracing program to produce an array of pixel colors of thesize specified for your window, which your program outputs as a <B>ppm </B> (see below) file. You can then use the filter <B> pnmtotiff</B> to create a <B> tiff </B> file which can be displayed using<B> xv </B> so that you need not write any display software.<P>You will need to write routines for creating a ray from the eyethrough the center of each pixel in the window, computing theintersection of any ray with a sphere or a polygon, computingthe normal to the sphere or the polygon at the intersection point,computing the reflected and refracted (if needed) rays from theintersection point, and computing rays from the intersection pointto each light source. You should use the Phong lighting model toevaluate the local illumination for each point, so you will also needa routine to evaluate this model. Remember that ray tracers arerecursive, you will need to make sure the recursion terminates ata reasonable point in the calculation.<P>There is no user interface requirement for this assignment. Youcan use a text editor to create the input file, and you will usexv to display your results.<P>Once you have the ray tracer working, you can expect to get somereally ugly pictures at first. Plan to spend some time tweakingthe parameters of your Phong model to make the images look morerealistic.<CENTER><H2> ppm - portable pixmap file format </H2></CENTER><P>The portable pixmap format is a lowest common denominator color imagefile format. The definition is as follows:<P><UL><LI> A "magic number" for identifying the file type. A ppm file'smagic number is the two characters "P3".<LI> Whitespace (blanks, TABs, CRs, LFs).<LI> A width, formatted as ASCII characters in decimal.<LI> Whitespace.<LI> A height, again in ASCII decimal.<LI> Whitespace.<LI> The maximum color-component value, again in ASCII decimal.<LI> Whitespace.<LI> Width * height pixels, each three ASCII decimal values between 0and the specified maximum value, starting at the top-left corner ofthe pixmap, proceeding in normal English reading order. The threevalues for each pixel represent red, green, and blue, respectively; avalue of 0 means that color is off, and the maximum value means thatcolor is maxxed out.<LI> Characters from a "#" to the next end-of-line are ignored(comments).<LI> No line should be longer than 70 characters.</UL><P> Here is an example of a small pixmap in this format:<P> P3 # feep.ppm 4 4 15 0 0 0 0 0 0 0 0 0 15 0 15 0 0 0 0 15 7 0 0 0 0 0 0 0 0 0 0 0 0 0 15 7 0 0 0 15 0 15 0 0 0 0 0 0 0 0 0<P>Programs that read this format should be as lenient as possible,accepting anything that looks remotely like a pixmap.<P>There is also a variant on the format, available by setting theRAWBITS option at compile time. This variant is different in thefollowing ways:<P><UL><LI> The "magic number" is "P6" instead of "P3".<LI> The pixel values are stored as plain bytes, instead of ASCII decimal.<LI> Whitespace is not allowed in the pixels area, and only a single characterof whitespace (typically a newline) is allowed after the maxval.<LI> The files are smaller and many times faster to read and write.</UL><P>Note that this raw format canonly be used for maxvals less thanor equal to 255. If you use the <B> ppm </B> library and try to writea file with a larger maxval, it will automatically fall back on theslower but more general plain format.<P><B> SEE ALSO </B><P>giftoppm(1), gouldtoppm(1), ilbmtoppm(1), imgtoppm(1),mtvtoppm(1), pcxtoppm(1), pgmtoppm(1), pi1toppm(1), picttoppm(1),pjtoppm(1), qrttoppm(1), rawtoppm(1), rgb3toppm(1), sldtoppm(1),spctoppm(1), sputoppm(1), tgatoppm(1), ximtoppm(1), xpmtoppm(1),yuvtoppm(1), ppmtoacad(1), ppmtogif(1), ppmtoicr(1), ppmtoilbm(1),ppmtopcx(1), ppmtopgm(1), ppmtopi1(1), ppmtopict(1), ppmtopj(1),ppmtopuzz(1), ppmtorgb3(1), ppmtosixel(1), ppmtotga(1), ppmtouil(1),ppmtoxpm(1), ppmtoyuv(1), ppmdither(1), ppmforge(1), ppmhist(1),ppmmake(1), ppmpat(1), ppmquant(1), ppmquantall(1), ppmrelief(1),pnm(5), pgm(5), pbm(5)<P>Copyright (C) 1989, 1991 by Jef Poskanzer.</BODY> </HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -