introduction to computer graphics
play

Introduction to Computer Graphics Toshiya Hachisuka Last Time - PowerPoint PPT Presentation

Introduction to Computer Graphics Toshiya Hachisuka Last Time Introduction to ray tracing Intersection algorithms with a ray Sphere Implicit surface Triangle GLSL Sandbox Last Time for all pixels { ray =


  1. 
 Introduction to Computer Graphics Toshiya Hachisuka

  2. Last Time • Introduction to ray tracing • Intersection algorithms with a ray • Sphere • Implicit surface • Triangle • GLSL Sandbox

  3. 
 Last Time for all pixels { ray = generate_camera_ray( pixel ) for all objects { hit = intersect( ray, object ) if “hit” is closer than “first_hit” {first_hit = hit} } pixel = shade( first_hit ) }

  4. 
 Today for all pixels { ray = generate_camera_ray( pixel ) for all objects { hit = intersect( ray, object ) if “hit” is closer than “first_hit” {first_hit = hit} } pixel = shade( first_hit ) }

  5. Today • Shading models • BRDF • Lambertian • Specular • Simple lighting calculation • Tone mapping

  6. Basic Shading Light Source Normal How much light illuminate this point?

  7. Basic Shading Light Source ~ r n ~ l ⇣ ⌘ n · ~ ~ l Φ Irradiance E = 4 ⇡ r 2

  8. Basic Shading ⇣ ⌘ n · ~ ~ l Φ Irradiance E = 4 ⇡ r 2

  9. Surface Appearance • How is light reflected by • Mirror • Paper • Rough metallic surface

  10. Types of Reflections • Diffuse: matte paint, paper • Glossy: plastic, rough metallic surface • Specular: mirror • Retro-reflective: the moon

  11. BRDF • B idirectional R eflectance D istribution F unction • How light is reflected off a surface • Capture appearance of surface

  12. BRDF • B idirectional R eflectance D istribution F unction • How light is reflected off a surface • Capture appearance of surface

  13. BRDF ~ n ~ ! o ~ ! i θ

  14. BRDF ! i ) = dL ( x, ~ ! o ) f ( x, ~ ! o , ~ dE ( x, ~ ! i ) dE ( x, ~ ! i ) = L ( x, ~ ! i ) cos ✓ d ! i ~ n ! o ~ ! i ~ θ

  15. Reflected Radiance • Sum of contributions from all directions Z L o ( x, ~ ! o ) = dL o ( x, ~ ! o ) Ω Z = f ( x, ~ ! i ) dE i ( x, ~ ! i ) ! o , ~ Ω Z = f ( x, ~ ! i ) L i ( x, ~ ! i ) cos ✓ d ! i ! o , ~ Ω

  16. BSDF • Bidirectional Scattering Distribution Function • Generalization of BRDF to transparency • Defined over all the directions

  17. Defining BRDF • Two approaches • Measurement • Analytical models � • We learn simple analytical models

  18. Lambertian • Uniformly reflects light over all directions • “Matte” surfaces ! i ) = K d f ( ~ ! o , ~ ⇡

  19. Lambertian • Irradiance times BRDF = Lambertain shading Z L o ( x, ~ ! o ) = dL o ( x, ~ ! o ) Ω Z = f ( x, ~ ! i ) dE i ( x, ~ ! i ) ! o , ~ Ω = K d Z ! i ) = K d dE i ( x, ~ ⇡ E i ⇡ Ω color shade (hit) { return (Kd / PI) * get_irradiance(hit) }

  20. Lambertian - Example

  21. Specular Reflection • Mirror reflection ! i ) = K s � ( ~ ! r ) ! o , ~ f ( ~ ! o , ~ cos ✓ ~ n θ θ

  22. Specular Reflection • Recursive tracing toward the reflected dir. ! r = − 2( ~ n ) ~ n + ~ ~ ! i · ~ ! i color shade (hit) { case hit.material diffuse: return (Kd / PI) * get_irradiance(hit) mirror: return Ks * shade(trace(reflected_ray)) }

  23. Specular Reflection - Example

  24. Specular Refraction ! i ) = K t � ( ~ ! t ) ! o , ~ • Glass etc. f ( ~ ! o , ~ cos ✓ i ~ n θ i η i θ o η o

  25. Specular Refraction • Same as reflection: recursive tracing color shade (hit) { case hit.material diffuse: return (Kd / PI) * get_irradiance(hit) mirror: return Ks * shade(trace(reflected_ray)) glass: return Kt * shade(trace(refracted_ray)) }

  26. Snell’s Law η i sin θ i = η o sin θ o ~ n θ i η i θ o η o

  27. Index of Refraction • Some values of η Vacuum 1.0 Air 1.00029 Ice 1.31 Water 1.33 Crown glass 1.52 - 1.65 Diamond 2.417

  28. Refracted Direction ~ n ! ~ η 1 ~ ! t η 2 ⇤ ⌅ ⌥ ⇥ 2 � � 1 ⇥ t = − � 1 n ) 2 ) ( ⇧ ⇥ − ( ⇧ n ) ⇧ n ) − 1 − (1 − ( ⇧ ⇧ ⇥ · ⇧ ⇥ · ⇧ ⌃ ⇧ n ⇧ � 2 � 2

  29. Refracted Direction Be aware of what object ray is entering and existing! Stack-based solution http://graphics.cs.ucdavis.edu/~bcbudge/deep/research/nested_dielectrics.pdf

  30. Fresnel Reflection • Both reflection and refraction occur at interface

  31. Fresnel Reflection • Based on Fresnel equations ρ s = η 1 cos θ i − η 2 cos θ o η 1 cos θ i + η 2 cos θ o ρ t = η 1 cos θ o − η 2 cos θ i η 1 cos θ o + η 2 cos θ i F ( θ o , θ i ) = 1 ρ 2 s + ρ 2 � � t 2

  32. Fresnel Reflection • Recursive call with branch glass: R = Fresnel(hit, ray); return R * shade(trace(reflected_ray)) 
 + (1 - R) * shade(trace(refracted_ray));

  33. Total Internal Reflection ~ n ! ~ η 1 ~ ! r η 2 Trace only reflected ray with K_s = 1 if ⌅ ⌥ ⇥ 2 � � 1 (inside of the sqrt) n ) 2 ) 1 − (1 − ( ⇧ ⇥ · ⇧ < 0 ⌃ � 2

  34. Complete Glass • Also known as dielectric materials • Be careful about ray and normal directions glass: if (TotalInternal) return shade(trace(reflected_ray)) R = Fresnel(hit, ray); return R * shade(trace(reflected_ray)) 
 + (1 - R) * shade(trace(refracted_ray));

  35. Other BRDFs • Mircofacets model • Lots of tiny mirrors at random orientations • Distribution of orientations of microfacets decides the sharpness of reflection • e.g., Cook-Torrance model Specular Glossy

  36. Other BRDFs [Ashikmin & Shirley]

  37. Other BRDFs • Measured BRDFs MERL BRDF Database

  38. Shadows • Return irradiance only if the light is visible Illuminated Occluded

  39. Shadows • Avoid self-intersection due to numerical error • Ignoring intersections that are too close etc. Occluded?

  40. With Shadows

  41. Without Shadows

  42. Multiple Light Sources • Simply add up all the contributions • Linearity of illumination One light source Two light source

  43. Image Based Lighting • Use of pixels in the image as light sources Input illumination Renderings

  44. Image Based Lighting • If ray hits nothing, return a value from image Image

  45. Image Based Lighting • Trace random ray above the hemisphere color get_irradiance (hit) { Ep = ... // irradiance from point light sources for (i = 1...N) { ray = gen_random_dir(hit.n) if (trace(ray) = no_hit) Ei = Ei + IBL(ray, image) } return Ep + (Ei / N) }

  46. Area Light Sources Z L o ( x, ~ ! o ) = f ( x, ~ ! i ) L i ( x, ~ ! i ) cos ✓ i d ! i ! o , ~ Ω L e

  47. Some Details • Generating random rays • http://people.cs.kuleuven.be/~philip.dutre/GI/ • See Eqn. (34) 
 • Fetching pixels by rays • Depends on parameterization • http://www.pauldebevec.com/Probes/

  48. Color in Computer Graphics • Store only three values (Red, Green, Blue) Energy Frequency B G R

  49. Why RGB? • Because we see with RGB • Rods: Intensity sensors • Cones: Color sensors (typically three types)

  50. Full Spectrum Rendering • Simulation at many wavelength ⇒ RGB

  51. Spectrum to RGB • Two steps • Compute responses to spectrum as XYZ • Convert XYZ to RGB Z 700 x = L ( λ )¯ x ( λ ) d λ 400 Similar for y & z r = c 0 x + c 1 y + c 2 z

  52. RGB to Spectrum • Ill-conditioned problem • Spectrum has much more info than RGB • “An RGB to Spectrum Conversion for Reflectances”

  53. Human Eye vs Monitor • Human eye • 2 14 :1 brightness difference • 14 bits 
 • Monitor • 255:1 brightness difference • 8 bits

  54. Tone Mapping • Convert an HDR value into 0-1 (0-255)

  55. Linear Scaling • Scale and clamp l ( x, y ) = min( cL ( x, y ) , 1 . 0)

  56. Non-linear Scaling • Use a function to “compress” HDR into 0-1 l ( x, y ) = f ( L ( x, y )) Output value Linear scaling 1.0 Non-linear scaling Input value (HDR)

  57. Film Response • Inspired by the response curve of a film • Simple and works well often l ( x, y ) = 1 . 0 − e − cL ( x,y ) http://freespace.virgin.net/hugo.elias/graphics/x_posure.htm

  58. Photographic Tone Reproduction • Inspired by photography [Reinhard] • Often works well • Desired brightness L white

  59. http://cadik.posvete.cz/tmo/ Comparisons

  60. Gamma Correction • 0.5 is not necessary displayed as “0.5” • Nonlinear mapping on a monitor • Correction to input tone-mapped value • g is typically 1.7-2.2 1 p ( x, y ) = l ( x, y ) g

  61. Gamma Correction Corrected No correction

  62. Missing Piece

  63. Missing Piece

Recommend


More recommend