📄 http:^^www.tc.cornell.edu^visualization^education^cs418^lab6.html
字号:
Date: Mon, 16 Dec 1996 22:10:44 GMTServer: NCSA/1.5Content-type: text/htmlLast-modified: Fri, 09 Feb 1996 12:53:53 GMTContent-length: 6491<html><head><title>CS418 Lab 6</title></head><body><h2> <!WA0><!WA0><!WA0><!WA0><!WA0><!WA0><!WA0><!WA0><img src="http://www.tc.cornell.edu/Visualization/Education/cs418/gifs/teapot.thumb.gif">CS 418: Laboratory 6</h2> <h2> Phong Lighting</h2><b> Introduction. </b><p>In this exercise you will code the lighting equation as aseries of compute statements.You will bypass the default illumination model which is built intothe Image module. By doing this, you will be able to control lightingeffects directly. For example, you will be able to define a spotlightor make the intensity of an object drop off with distance.<b><hr>Procedure:</b><p>First you need to download several example files. To do this, click on each of the filenames shownbelow. When the text window opens, use the "save as" option to put the file in your own directory. Nameeach file with the same name as shown below. <ul><li> <!WA1><!WA1><!WA1><!WA1><!WA1><!WA1><!WA1><!WA1><a href="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/Phong1995RV.net"> LightTemplate.net </a><li> <!WA2><!WA2><!WA2><!WA2><!WA2><!WA2><!WA2><!WA2><a href="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/Phong1995RV.cfg"> LightTemplate.cfg </a></ul><p>The program LightTemplate.net implements a spotlight entirely withinDX using compute modules. Ambient, diffuse and specular terms areeach computed and added together to obtain the intensity of each point. Follow the flow of the program to see how the intensities are computed.For the initial program it is assumed that the light is at a finitedistance from the objects, but the viewer is very far away in a direction<b>V.</b><p>Some examples of the program's output are shown below. The first showsa spotlight oriented along the y-axis with a "width" of 3.0. (A width of 3.0 means (<b>D dot L</b>)^3.0.)Thesmall white dot is an icon showing where the light is. The arrow isan icon showing the direction of the spotlight.<p><!WA3><!WA3><!WA3><!WA3><!WA3><!WA3><!WA3><!WA3><img src="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/labgifs/lab6.image1.gif"><p>The next image is the same light position, but with the spotlightwidth=0.0 so that the light is omnidirectional.The bright spots on the surfaces near the light are due to a large<b>(L dot N) </b> in the diffuse term. Notice that the diffuse reflection has the color of the surface,while the specular reflection has the color of the light (white).<p><!WA4><!WA4><!WA4><!WA4><!WA4><!WA4><!WA4><!WA4><img src="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/labgifs/lab6.image2.gif"><p>You can turn off the default shading in DX by collecting a singleAmbientLight with the object you are rendering. An AmbientLight ingoresnormal information. All you see is the color defined for the object as ifit were lighted from all directions uniformly. The example program constructs a surface, calculates the surface normals,then throws away the lighting information to produce an unshaded surface(because there is an AmbientLight module). The colors you calculate become the color of the objects in the image module.Note that you must use the Camera/Display module to show the image becausethe view-vector, V, must be available to the program. Do not use an Imagemodule.Throughout this exercise, leave the viewing distance at infinity,that is, leave the Camera module perspective flag at 0.<p><ul><li>Modify the program to use the <b>(N dot H)</b> formulation of specular lightingrather than <b>(R dot V).</b> Make an interactor to choose which model youare using.<p><li> All surfaces get more shiny at high angle of incidence.Modify the specular term to simulate this effect.Below is an example of what the modified program might generate.The specular reflection on the vertical plane is releatively diffusebecause the angle of incidence is near zero.The specular reflection from the horizontal plane is narrow becausethe angle of incidence is high (the light is grazing the surface).<p><b>Clarification:</b>You need to make some part of the specular term dependent on the angle of incidence, arccos(<b>L dot N</b>). The light shown is aomnidirectional light.The definition of the reflection vector,<b> R</b>, is given on page 19of Watt.<p><!WA5><!WA5><!WA5><!WA5><!WA5><!WA5><!WA5><!WA5><img src="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/labgifs/lab6.image3.gif"><p><li>The spotlight as given to you has a "soft" cutoff with angle. Modifythe program so that instead of dropping off as a power of a cosine, theintensity is uniform for angles less than a certain value and zero forangles more than that value. (Angle is measured here from the D vector.)Include an interactor to choose between the cutoff methods.The two images below show a "soft" cutoff spotlight and a "hard" cutoffspotlight. Note the jagginess at the edge of the hard cutoff lightwhich results from a very abrupt cutoff function.Try to minimize the jagginess in your program.<p><!WA6><!WA6><!WA6><!WA6><!WA6><!WA6><!WA6><!WA6><img src="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/labgifs/lab6.image4.soft.gif"><!WA7><!WA7><!WA7><!WA7><!WA7><!WA7><!WA7><!WA7><img src="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/labgifs/lab6.image4.hard.gif"><p><li> Modify the program to fly the light through a scene consisting ofa few objects.The light should be a spotlight which flys a curved path, with thedirection of the spotlight tangent to the path for about half theflight, then the spotlight should suddenly lock onto one objectand remain locked for the second half of the flight.One frame of a possible animation is shown below.<p><!WA8><!WA8><!WA8><!WA8><!WA8><!WA8><!WA8><!WA8><img src="http://www.tc.cornell.edu/Visualization/Education/cs418/labs/labgifs/lab6.image5.gif"></ul><p><b> Bugs as of 4/11/95</b><ul><li>The term "Ip" in the calculation of the specular term should be moved tothe final calculation so that Ks*Ip*(R dot V)^n is calculated.<li> The Compute module does not understand transform objects, so don't useRotate, Scale, Translate, or Transform modules when you are buildingyour scene.</ul><b> <hr> Questions/Writeup:</b><p>Be prepared to demo all of the functions specified in the first three bullets above:ambient lighting, diffuselighting, light position, light directionality, and specular reflections oftwo kinds in one program. All interactors shouldbe labeled, have appropriate ranges and step sizes and be in no more thantwo control panels. The code should be well documented and organized.<p>Be prepared to demo the flying light in a separate program.<p><ol><li> What seem to be the differences between the (R dot V) and (N dot H)specular lighting models in terms of the appearance of objects.<p><li> Write the formula you used to make a surface more shiny at high angles.<p><li> Write the formula you used to impelment a sharp cutoff spotlight.</ol><p><!WA9><!WA9><!WA9><!WA9><!WA9><!WA9><!WA9><!WA9><img src="http://www.tc.cornell.edu/Visualization/Education/cs418/gifs/leftarrow.icon.gif">Back to <!WA10><!WA10><!WA10><!WA10><!WA10><!WA10><!WA10><!WA10><a href="http://www.tc.cornell.edu/Visualization/Education/cs418/index.html">Main Page</a><br><!WA11><!WA11><!WA11><!WA11><!WA11><!WA11><!WA11><!WA11><img src="http://www.tc.cornell.edu/Visualization/Education/cs418/gifs/rightarrow.icon.gif">Go to <!WA12><!WA12><!WA12><!WA12><!WA12><!WA12><!WA12><!WA12><a href="http://www.tc.cornell.edu/Visualization/Education/cs418/lab7.html">Lab 7</a> <P><hr>Last modified, 1/25/95, B.Land.<! Revision history: Original document: P.Maxfield, 10/94><br><!WA13><!WA13><!WA13><!WA13><!WA13><!WA13><!WA13><!WA13><IMG SRC="http://www.tc.cornell.edu/copyright.xbm"><!WA14><!WA14><!WA14><!WA14><!WA14><!WA14><!WA14><!WA14><A HREF="http://www.tc.cornell.edu/ctcCopyright.html"> <i>Copyright Statement </I></A></body> </html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -