1 / 40

Shading

Shading. 고려대학교 컴퓨터 그래픽스 연구실. Contents. Definition Light sources Phong reflection model Polygonal shading Shading in OpenGL Global rendering. Shading. Determine a color for each filled pixel How to choose a color

holleb
Télécharger la présentation

Shading

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Shading 고려대학교 컴퓨터 그래픽스 연구실 cgvr.korea.ac.kr

  2. Contents • Definition • Light sources • Phong reflection model • Polygonal shading • Shading in OpenGL • Global rendering cgvr.korea.ac.kr

  3. Shading • Determine a color for each filled pixel • How to choose a color • the color of the light source and of the surfaces determines the color of one or more pixels in the frame buffer cgvr.korea.ac.kr

  4. Light and Matter • Color is determined by multiple interactions among light sources and reflective surfaces • recursive reflection of light between surfaces accounts for subtle shading Rendering Equation cgvr.korea.ac.kr

  5. Light-Material Interactions • Specular surfaces – mirror • scatter reflected light in a narrow range of angle • Diffuse surfaces – chalk, clay • scatter reflected light all directions • Translucent surfaces – glass, water • refraction specular surface diffuse surface translucent surface cgvr.korea.ac.kr

  6. Light Sources • Illumination function I (x, y, z, θ, φ, λ) • each point (x, y, z) on the surface • direction of emission (θ, φ) • wavelength λ light source cgvr.korea.ac.kr

  7. Modeling Light Sources • Simple mathematical models: • ambient light • point light • directional light • spot light cgvr.korea.ac.kr

  8. Color Sources • Three-color theory • human perceive three primary colors – red, green, and blue • three-component intensity or luminance function • independent calculations cgvr.korea.ac.kr

  9. Ambient Light • Uniform lighting • identical at every point in the scene cgvr.korea.ac.kr

  10. Point Sources (1/2) • Emit light equally in all directions • p0: point source location • proportional to the inverse square distance point source illuminating a surface cgvr.korea.ac.kr

  11. Point Sources (2/2) • Large finite size of most light sources • umbra: full shadow • penumbra: partial shadow • Attenuation shadows created by finite-size light source cgvr.korea.ac.kr

  12. Spotlights • Characterized by a narrow range of angle through which light is emitted • ps: apex of a cone • ls: direction of pointing • θ: angle to determine width • Distribution of light • concentrate in the center • light intensity drop off spotlight attenuation exponent cgvr.korea.ac.kr

  13. Distant Light Sources • far from the surface  vector does not change • location  direction parallel light source cgvr.korea.ac.kr

  14. Phong Reflection Model • Efficient and close enough approximation to physical reality to produce good renderings • Use 4 vectors • n: normal at p • v: direction from p to the viewer or COP • l: direction from light source • r: direction of reflectance • 3 types of material-light interactions • ambient, diffuse, and specular vectors used by the Phong model cgvr.korea.ac.kr

  15. Computation • Light source and reflection term • Ex. red intensity • Total Intensity cgvr.korea.ac.kr

  16. Ambient Reflection • Same at every point on the surface • Ambient reflection coefficient • amount reflected • some of light source is absorbed and some is reflected • three ambient coefficients – , , and • Ambient reflection term • can be any of the individual light sources • can be a global ambient term cgvr.korea.ac.kr

  17. Diffuse Reflection (1/2) • Characterized by rough surfaces • perfectly diffuse surface  so rough that there is no preferred angle of reflection • Lambert’s law • only the vertical component of light source rough surface at noon in the afternoon Lambert’s law cgvr.korea.ac.kr

  18. Diffuse Reflection (2/2) • Lambert’s law (cont’) • Diffuse reflection term • incorporate a distance term Lambert’s law cgvr.korea.ac.kr

  19. Specular Reflection • Specular surface is smooth • highlight in the direction of the viewer • Specular reflection term • shininess coefficient • α  infinite : mirror • 100 < α < 500 : metal • α < 100 : broad highlight specular surface specular highlights effect of shininess coefficient cgvr.korea.ac.kr

  20. Phong Model • Including the distance term cgvr.korea.ac.kr

  21. Utha Teapots with Different Material Properties cgvr.korea.ac.kr

  22. p1 p0 p2 Computation of Vectors (1/2) • Normal vectors • in OpenGL • Angle of reflection n glNormal3f(nx, ny, nz); glNormal3fv(pointer_to_normal); coplanar condition ① ② by ① and ② mirror cgvr.korea.ac.kr

  23. Computation of Vectors (2/2) • Halfway vector • half-angle: 2ψ=φ • Transmitted light • Snell’s law halfway vector perfect light transmission cgvr.korea.ac.kr

  24. Polygonal Shading • Shade a polygonal mesh • flat shading • interpolative or Gouraud shading • Phong shading polygonal mesh cgvr.korea.ac.kr

  25. Flat Shading (1/2) • Constant shading • flat polygon  n: constant • distant light source  l: constant • distant viewer  v: constant • One shading calculation for each polygon • In OpenGL distant source and viewer glShadeModel(GL_FLAT); cgvr.korea.ac.kr

  26. Flat Shading (2/2) • Always be disappointing for a smooth surface • lateral inhibition • human visual system has a remarkable sensitivity • Mach bands • perceive the increases in brightness along the edges flat shading of polygonal mesh perceived and actual intensities at an edge We need smoother shading techniques to avoid it!! cgvr.korea.ac.kr

  27. Interpolative and Gouraud Shading • In OpenGL • One lighting calculation for each vertex • bilinearly interpolate colors • Vertex normal could be defined through interpolation glShadeModel(GL_SMOOTH); normals near interior vertex cgvr.korea.ac.kr

  28. Wireframe cgvr.korea.ac.kr

  29. Flat Shading cgvr.korea.ac.kr

  30. Gouraud Shading cgvr.korea.ac.kr

  31. Phong Shading • May not prevent the appearance of Mach bands • What if polygonal mesh is too coarse to capture illumination effects in polygon interiors? • One shading calculation for each pixel off-line • Compute vertex normal at each point interpolate normals across each polygon interpolation of normals edge normals cgvr.korea.ac.kr

  32. Visible-Line Determination cgvr.korea.ac.kr

  33. Visible-Surface Determination with Ambient Illumination Only cgvr.korea.ac.kr

  34. Flat Shaded Polygons with Diffuse Reflection cgvr.korea.ac.kr

  35. Gouraud Shaded Polygons with Diffuse Reflection cgvr.korea.ac.kr

  36. Gouraud Shaded Polygons with Specular Reflection cgvr.korea.ac.kr

  37. Phong Shaded Polygons with Specular Reflection cgvr.korea.ac.kr

  38. Phong Shading of Curved Surfaces with Specular Reflection cgvr.korea.ac.kr

  39. Improved Illumination Model and Multiple Lights cgvr.korea.ac.kr

  40. Texture Mapping cgvr.korea.ac.kr

More Related