shading and lighting 04
play

Shading and Lighting (04) RNDr. Martin Madaras, PhD. - PowerPoint PPT Presentation

Principles of Computer Graphics and Image Processing Shading and Lighting (04) RNDr. Martin Madaras, PhD. martin.madaras@stuba.sk Overview Direct Illumination Emission at light sources Scattering at surfaces Gouraud shading


  1. Principles of Computer Graphics and Image Processing Shading and Lighting (04) RNDr. Martin Madaras, PhD. martin.madaras@stuba.sk

  2. Overview  Direct Illumination  Emission at light sources  Scattering at surfaces  Gouraud shading  Global Illumination  Shadows  Refractions  Inter-object reflections 2

  3. How the lectures should look like #1 Ask questions, please!!! - Be communicative - www.slido.com #PPGSO04 - More active you are, the better for you! - 3

  4. Overview  𝐽 𝑀 (𝑦, 𝑧, 𝑨, 𝜄, 𝜒, 𝜇)  describes intensity of energy,  leaving a light source, ...  arriving at location (x,y,z), ...  from direction ( θ,φ), ...  with wavelength λ 4

  5. Light Source types  Omnidirectional  Spotlight  Area  Directional  Object - what are the differences? 5

  6. Light Source Models  Simple mathematical models  OpenGL support  Point light  Directional light  Spot light 6

  7. Point Light Source  Models omni-directional source  intensity (𝐽 0 ),  position (𝑦, 𝑧, 𝑨),  factors (𝑙 𝑑 , 𝑙 𝑚 , 𝑙 𝑟 ) for attenuation with distance (𝑒) 7

  8. Directional Light Source  Models point light source at infinity  intensity (𝐽 0 ),  direction (𝑒𝑦, 𝑒𝑧, 𝑒𝑨),  no attenuation with distance 8

  9. Spot Light Source  Models point light source with direction  intensity (𝐽 0 ),  position (𝑦, 𝑧, 𝑨) ,  direction (𝑒) ,  attenuation 𝑙 𝑑 , 𝑙 𝑚 , 𝑙 𝑟 . 9

  10. Overview  Direct Illumination  Emission at light sources  Scattering at surfaces  Gouraud shading  Global Illumination  Shadows  Refractions  Inter-object reflections 10

  11. Elementary theory  Light-surface interaction  Reflection  Refraction  Snell’s law  Surface normal vector  Real world is a bit different 11

  12. Surface types  Reflective  Diffuse – Lambertian  Both 12

  13. Surface types Mirror Matte directional indirectional component component 13

  14. Light models  Empiric – e.g. Phong lighting model  cheap computation  physically incorrect  visually plausible  Physically-based  energy transfer, light propagation  closer to real-world physics  expensive 14

  15. Local illumination models  Fast but inaccurate  Empirical (no physical background)  Many physical effects are impossible to achieve  Computer games, real-time rendering 15

  16. Modeling Surface Reflectance  Rs( θ,φ,γ,ψ,λ) ...  describes the amount of incident energy, ...  arriving from direction ( θ , φ ), ...  leaving in direction ( γ , ψ ), ...  with wavelength λ 16

  17. OpenGL Reflectance Model  Simple empirical model:  diffuse reflection +  specular reflection +  emission +  “ambient”  Bui Tuong Phong, 1973 17

  18. OpenGL Reflectance Model  Simple empirical model:  diffuse reflection +  specular reflection +  emission +  “ambient” 18

  19. Diffuse Reflection  Assume surface reflects equally in all directions  Examples: chalk, clay 19

  20. Diffuse Reflection  How is light reflected ?  Depends on an angle of incident light 20

  21. Diffuse Reflection  How is light reflected ?  Depends on an angle of incident light 21

  22. Diffuse Reflection  Lambertian model  cosine law (dot product) 22

  23. OpenGL Reflectance Model  Simple empirical model:  diffuse reflection +  specular reflection +  emission +  “ambient” 23

  24. Specular Reflection  Reflection is strongest near mirror angle  Examples: Mirrors, Metals 24

  25. Specular Reflection  How much light is seen ?  Depends on:  angle of incident light  angle of viewer 25

  26. Specular Reflection  Phong Model  cos( α )n This is a physically motivated hack! 26

  27. OpenGL Reflectance Model  Simple empirical model:  diffuse reflection +  specular reflection +  emission +  “ambient” 27

  28. Emission  Represents light emitted directly from surface 28

  29. OpenGL Reflectance Model  Simple empirical model:  diffuse reflection +  specular reflection +  emission +  “ ambient ” 29

  30. Ambient term  Represents reflection of all indirect illumination  This is a total hack  (avoids complexity of global illumination)! 30

  31. OpenGL Reflectance Model  Simple empirical model:  diffuse reflection +  specular reflection +  emission +  “ ambient ” 31

  32. OpenGL Reflectance Model  Simple empirical model:  diffuse reflection +  specular reflection +  emission +  “ ambient ” 32

  33. OpenGL Reflectance Model  Simple empirical model:  diffuse reflection +  specular reflection +  emission +  “ ambient ” 33

  34. Diffuse light 34

  35. Ambient light 35

  36. Diffuse + Ambient light 36

  37. Specular + Diffuse + Ambient light 37

  38. Phong lighting model  Ambient + Diffuse + Specular components without ambient with ambient  Simulates global light scattered in the scene and reflected from other objects 38

  39. Other lighting models  Blinn-Phong  generalization of Phong’s model  Cook-Torrance  microfacets  Oren-Nayar  rough surfaces  Anisotropic microfacet distribution 39

  40. Direct Illumination  Single light source example 40

  41. Direct Illumination  Multiple light source example 41

  42. 3D rendering pipeline 3D polygons Modeling 1 Transformation Lighting Viewing Transformation Projection Transformation Clipping Scan Conversion Draw pixels 2D Image 42

  43. Ray Casting  Independent lighting calculation for each pixel  Computationally expensive 43

  44. Polygon Shading  • Can take advantage of spatial coherence  Illumination calculations of pixels of a triangle are related  Scanline rasterization 44

  45. Surface normal vector  Perpendicular to the surface at the point  Computation:  Usually from tangent vectors    =   Vector cross product n u v  Depends on the   object representation n  v u   Vector n = ˆ normalization  n n 45

  46. Tangent vectors  Parametric representation  X = x(u,v)  Y = y(u,v)  Z = z(u,v)  Partial derivation by u , v → vectors t u, t v  Polygonal representation  Tangent vectors are edge vectors  Mind the orientation! 46

  47. Overview  Global Illumination  Shadows  Refractions  Inter-object reflections  Shading  Flat  Gouraud  Phong 47

  48. Flat Shading  Fill triangles using single calculated color 48

  49. Flat Shading  One Illumination calculation per polygon  Assign all pixels of each polygon the same color 49

  50. Flat Shading  Objects look like they are composed of polygons  Ok for polyhedral objects  Not so good for smooth surfaces 50

  51. Gouraud Shading  One lighting calculation per vertex  Assign pixels inside polygon by interpolating colors computed at vertices 51

  52. Gouraud Shading  Bilinearly interpolate colors of triangle across scan line 52

  53. Gouraud Shading  Smooth shading over adjacent polygons  Curved surfaces  Illumination highlights  Produces smoothly shaded polygonal mesh  Fast linear approximation  Needs fine mesh to capture subtle lighting effects 53

  54. Gouraud Shading 54

  55. Phong Shading  NOT Phong lighting model  One lighting calculation per pixel  Approximate surface normals inside polygon using bilinear interpolation of normals from vertices 55

  56. Phong Shading  Bilinearly interpolate surface normals at vertices down and across scan lines 56

  57. Polygon Shading Algorithms 57

  58. Example: Wireframe scene 58

  59. Example: Ambient only 59

  60. Example: Flat shading with Diffuse 60

  61. Example: Gouraud shading with Diffuse 61

  62. Example: Gouraud shading with Specular 62

  63. Example: Phong shading with Specular 63

  64. Shading Issues  Problems with interpolated shading  Problems computing shared vertex normals  Perspective distortion  Problems at T -vertices 64

  65. Shading Benefits  Good performance and quality of output  Excellent for hardware  Works well with subdivision surfaces 65

  66. How the lectures should look like #2 Ask questions, please!!! - Be communicative - www.slido.com #PPGSO04 - More active you are, the better for you! - 66

  67. Overview  Advanced Shading and Mapping  Deferred Shading  Shadow Mapping  Normal Mapping  Displacement Mapping  Vector Displacement Mapping 67

  68. Deferred Shading  Compute Lighting in Screen-Space  Two pass approach  Decoupling of geometry and lighting  G- Buffer stores positions, normals, materials …  Lighting is a per-pixel operation  Problems with transparency and G-buffer size  O(objects+lights) 68

  69. Deferred Shading Diffuse Color Z Buffer Surface Normals Final Composition 69

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend