##
This **preview** shows page *1-2-3-4-5*
out of 16 **pages**.

*View Full Document*

End of preview. Want to read all 16 pages?

Upload your study docs or become a GradeBuddy member to access this document.

View Full Document**Unformatted text preview:**

1Angel: Interactive Computer Graphics 4E © Addison-Wesley 2006Shading IIEd AngelProfessor of Computer Science,Electrical and ComputerEngineering, and Media ArtsUniversity of New Mexico2Angel: Interactive Computer Graphics 4E © Addison-Wesley 2006Objectives• Continue discussion of shading• Introduce modified Phong model• Consider computation of required vectors3Angel: Interactive Computer Graphics 4E © Addison-Wesley 2006Ambient Light• Ambient light is the result of multipleinteractions between (large) light sourcesand the objects in the environment• Amount and color depend on both thecolor of the light(s) and the materialproperties of the object• Add ka Ia to diffuse and specular termsreflection coefintensity of ambient light4Angel: Interactive Computer Graphics 4E © Addison-Wesley 2006Distance Terms• The light from a point source that reachesa surface is inversely proportional to thesquare of the distance between them• We can add a factor of theform 1/(ad + bd +cd2) tothe diffuse and specularterms• The constant and linear terms soften theeffect of the point source5Angel: Interactive Computer Graphics 4E © Addison-Wesley 2006Light Sources• In the Phong Model, we add the resultsfrom each light source• Each light source has separate diffuse,specular, and ambient terms to allow formaximum flexibility even though this formdoes not have a physical justification• Separate red, green and blue components• Hence, 9 coefficients for each point source- Idr, Idg, Idb, Isr, Isg, Isb, Iar, Iag, Iab6Angel: Interactive Computer Graphics 4E © Addison-Wesley 2006Material Properties• Material properties match light sourceproperties- Nine absorbtion coefficients• kdr, kdg, kdb, ksr, ksg, ksb, kar, kag, kab- Shininess coefficient α7Angel: Interactive Computer Graphics 4E © Addison-Wesley 2006Adding up the ComponentsFor each light source and each colorcomponent, the Phong model can bewritten (without the distance terms) asI =kd Id l · n + ks Is (v · r )α + ka IaFor each color componentwe add contributions fromall sources8Angel: Interactive Computer Graphics 4E © Addison-Wesley 2006Modified Phong Model• The specular term in the Phong model isproblematic because it requires thecalculation of a new reflection vector andview vector for each vertex• Blinn suggested an approximation usingthe halfway vector that is more efficient9Angel: Interactive Computer Graphics 4E © Addison-Wesley 2006The Halfway Vector• h is normalized vector halfway between land vh = ( l + v )/ | l + v |10Angel: Interactive Computer Graphics 4E © Addison-Wesley 2006Using the halfway angle• Replace (v · r )α by (n · h )β• β is chosen to match shineness• Note that halway angle is half of anglebetween r and v if vectors are coplanar• Resulting model is known as the modifiedPhong or Blinn lighting model- Specified in OpenGL standard11Angel: Interactive Computer Graphics 4E © Addison-Wesley 2006ExampleOnly differences in these teapots are the parametersin the modifiedPhong model12Angel: Interactive Computer Graphics 4E © Addison-Wesley 2006Computation of Vectors• l and v are specified by the application• Can computer r from l and n• Problem is determining n• For simple surfaces is can be determined buthow we determine n differs depending onunderlying representation of surface• OpenGL leaves determination of normal toapplication- Exception for GLU quadrics and Bezier surfaces(Chapter 11)13Angel: Interactive Computer Graphics 4E © Addison-Wesley 2006Plane Normals• Equation of plane: ax+by+cz+d = 0• From Chapter 4 we know that plane isdetermined by three points p0, p2, p3 ornormal n and p0• Normal can be obtained byn = (p2-p0) × (p1-p0)14Angel: Interactive Computer Graphics 4E © Addison-Wesley 2006Normal to Sphere• Implicit function f(x,y.z)=0• Normal given by gradient• Sphere f(p)=p·p-1• n = [∂f/∂x, ∂f/∂y, ∂f/∂z]T=p15Angel: Interactive Computer Graphics 4E © Addison-Wesley 2006Parametric Form• For sphere• Tangent plane determined by vectors• Normal given by cross productx=x(u,v)=cos u sin vy=y(u,v)=cos u cos vz= z(u,v)=sin u∂ p/∂ u = [∂ x/∂ u, ∂ y/∂ u, ∂ z/∂ u]T∂ p/∂ v = [∂ x/∂ v, ∂ y/∂ v, ∂ z/∂ v]Tn = ∂ p/∂ u × ∂ p/∂ v16Angel: Interactive Computer Graphics 4E © Addison-Wesley 2006General Case• We can compute parametric normals forother simple cases- Quadrics- Parameteric polynomial surfaces• Bezier surface patches (Chapter

View Full Document