To Do Outline Phong Illumination Model Idea of Phong Illumination Phong Formula

To Do Outline Phong Illumination Model Idea of Phong Illumination Phong Formula

To Do Foundations of Computer Graphics (Spring 2010) . Work on HW4 milestone CS 184, Lecture 18: Shading & Texture Mapping . Prepare for final push on HW 4, HW 5 http://inst.eecs.berkeley.edu/~cs184 Many slides from Greg Humphreys, UVA and Rosalee Wolfe, DePaul tutorial teaching texture mapping visually Chapter 11 in text book covers some portions Outline Phong Illumination Model . Brief discussion on Phong illumination model . Specular or glossy materials: highlights and Gouraud, Phong shading . Polished floors, glossy paint, whiteboards . For plastics highlight is color of light source (not object) . Texture Mapping (bulk of lecture) . For metals, highlight depends on surface color . Really, (blurred) reflections of light source These are key components of shading Roughness Idea of Phong Illumination Phong Formula . Find a simple way to create highlights that are view- I ()RE p dependent and happen at about the right place R . Not physically based -L . Use dot product (cosine) of eye and reflection of E light direction about surface normal . Alternatively, dot product of half angle and normal . Raise cosine lobe to some power to control sharpness or roughness R ? R LLNN 2( ) 1 Alternative: Half-Angle (Blinn-Phong) Flat vs. Gouraud Shading I ()NH p N H glShadeModel(GL_FLAT) glShadeModel(GL_SMOOTH) Flat - Determine that each face has a single normal, and color the entire face a single value, based on that normal. In practice, both diffuse and specular Gouraud – Determine the color at each vertex, using the normal at components for most materials that vertex, and interpolate linearly for pixels between vertex locations. Gouraud Shading – Details Gouraud and Errors I1221()()yys Iyy s Ia yy12 . I1 = 0 because (N dot E) is negative. I ()()yy Iyy 1331s s . I = 0 because (N dot L) is negative. Ib 2 I1 yy13 y1 Iab()()xx p Ixx b p a . Any interpolation of I1 and I2 will be 0. I p xxba Ia I p Ib Scan line ys y2 I2 y3 I3 I1 = 0 I2 = 0 area of Actual implementation efficient: difference desired equations while scan converting highlight 2 Phongs make a Highlight Problems with Interpolated Shading . Besides the Phong Reflectance model (cosn), there is a . Silhouettes are still polygonal Phong Shading model. Interpolation in screen, not object space: perspective distortion . Phong Shading: Instead of interpolating the intensities . Not rotation or orientation-independent between vertices, interpolate the normals. How to compute vertex normals for sharply curving surfaces? . The entire lighting calculation is performed for each pixel, based on the interpolated normal. (OpenGL doesn’t do this, but you can with current programmable shaders) . But at end of day, polygons is mostly preferred to explicitly representing curved objects like spline patches for rendering I1 = 0 I2 = 0 2 Outline Texture Mapping . Brief discussion on Phong illumination model . Important topic: nearly all objects textured and Gouraud, Phong shading . Wood grain, faces, bricks and so on . Adds visual detail to scenes . Texture Mapping (bulk of lecture) . Meant as a fun and practically useful lecture These are key components of shading Polygonal model With surface texture Adding Visual Detail Parameterization . Basic idea: use images instead of more polygons to represent fine scale color variation ++ = geometry image texture map • Q: How do we decide where on the geometry each color from the image should go? Option: Varieties of projections Option: unfold the surface [Piponi2000] [Paul Bourke] 3 Option: make an atlas Option: it’s the artist’s problem charts atlas surface [Sander2001] Outline How to map object to texture? . Types of projections . To each vertex (x,y,z in object coordinates), must associate 2D texture coordinates (s,t) . Interpolating texture coordinates . So texture fits “nicely” over object . Broader use of textures Idea: Use Map Shape Planar mapping . Map shapes correspond to various projections . Like projections, drop z coord (s,t) = (x,y) . Planar, Cylindrical, Spherical . Problems: what happens near z = 0? . First, map (square) texture to basic map shape . Then, map basic map shape to object . Or vice versa: Object to map shape, map shape to square . Usually, this is straightforward . Maps from square to cylinder, plane, sphere well defined . Maps from object to these are simply spherical, cylindrical, cartesian coordinate systems 4 Cylindrical Mapping Spherical Mapping . Cylinder: r, θ, z with (s,t) = (θ/(2π),z) . Convert to spherical coordinates: use latitude/long. Note seams when wrapping around (θ = 0 or 2π) . Singularities at north and south poles Cube Mapping Cube Mapping Outline 1st idea: Gouraud interp. of texcoords I1221()()yys Iyy s Ia . Types of projections yy12 I ()()yy Iyy . Interpolating texture coordinates 1331s s Ia I1 yy13 y1 . Broader use of textures Iab()()xx p Ixx b p a Ia xxba Ia I p Ib Scan line ys y2 I2 y3 I3 Actual implementation efficient: difference equations while scan converting 5 Artifacts Interpolating Parameters . McMillan’s demo of this is at . The problem turns out to be fundamental to http://graphics.lcs.mit.edu/classes/6.837/F98/Lecture21/Slide05.html interpolating parameters in screen-space . Another example . Uniform steps in screen space uniform steps in world space http://graphics.lcs.mit.edu/classes/6.837/F98/Lecture21/Slide06.html . What artifacts do you see? . Why? . Why not in standard Gouraud shading? . Hint: problem is in interpolating parameters Texture Mapping Interpolating Parameters . Perspective foreshortening is not getting applied to our interpolated parameters . Parameters should be compressed with distance . Linearly interpolating them in screen-space doesn’t do this Linear interpolation Correct interpolation of texture coordinates with perspective divide Hill Figure 8.42 Perspective-Correct Interpolation Texture Map Filtering . Skipping a bit of math to make a long story short… . Naive texture mapping aliases badly . Rather than interpolating u and v directly, interpolate u/z and v/z . Look familiar? int uval = (int) (u * denom + 0.5f); . These do interpolate correctly in screen space int vval = (int) (v * denom + 0.5f); . Also need to interpolate z and multiply per-pixel int pix = texture.getPixel(uval, vval); . Problem: we don’t know z anymore . Actually, each pixel maps to a region in texture . Solution: we do know w 1/z . |PIX| < |TEX| . So…interpolate uw and vw and w, and compute . Easy: interpolate (bilinear) between texel values u = uw/w and v = vw/w for each pixel . |PIX| > |TEX| . This unfortunately involves a divide per pixel . Hard: average the contribution from multiple texels . http://graphics.lcs.mit.edu/classes/6.837/F98/Lecture21/Slide14.html . |PIX| ~ |TEX| . Still need interpolation! 6 Mip Maps MIP-map Example . Keep textures prefiltered at multiple resolutions . For each pixel, linearly interpolate between two closest levels (e.g., trilinear filtering) . No filtering: . Fast, easy for hardware AAAAAAAGH MY EYES ARE BURNING . MIP-map texturing: . Why “Mip” maps? Where are my glasses? Outline Texture Mapping Applications . Types of projections . Modulation, light maps . Interpolating texture coordinates . Bump mapping . Broader use of textures . Displacement mapping . Illumination or Environment Mapping . Procedural texturing . And many more Modulation textures Bump Mapping Map texture values to scale factor . Texture = change in surface normal! Wood texture Texture value Sphere w/ diffuse texture Sphere w/ diffuse texture Swirly bump map and swirly bump map I T(s,t)(I K I (K (N L) K (V R)n )S I K I K I ) E A A L D S L L T T S S 7 Displacement Mapping Illumination Maps . Quake introduced illumination maps or light maps to capture lighting effects in video games Texture map: Light map Texture map + light map: Environment Maps Solid textures Texture values indexed by 3D location (x,y,z) • Expensive storage, or • Compute on the fly, e.g. Perlin noise Images from Illumination and Reflection Maps: Simulated Objects in Simulated and Real Environments Gene Miller and C. Robert Hoffman SIGGRAPH 1984 “Advanced Computer Graphics Animation” Course Notes Procedural Texture Gallery 8 9.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    9 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us