illumination and shading
play

Illumination and Shading Sung-Eui Yoon ( ) ( ) C Course URL: - PowerPoint PPT Presentation

Introduction to Computer Graphics and OpenGL Introduction to Computer Graphics and OpenGL Illumination and Shading Sung-Eui Yoon ( ) ( ) C Course URL: URL http://sglab.kaist.ac.kr/~sungeui/ETRI_CG/ Course Objectives


  1. Introduction to Computer Graphics and OpenGL Introduction to Computer Graphics and OpenGL Illumination and Shading Sung-Eui Yoon ( 윤성의 ) ( 윤성의 ) C Course URL: URL http://sglab.kaist.ac.kr/~sungeui/ETRI_CG/

  2. Course Objectives Course Objectives ● Know how to consider lights Know how to consider lights during rendering models ● Light sources Li ht ● I llumination models ● Shading ● Shading ● Local vs. global illumination 2

  3. Question: How Can We See ● Emission and reflection ! Emission and reflection ! Objects? Objects? 3

  4. Question: How Can We See Objects? Objects? Light (sub-class of electromagnetic waves) Prism Sun light g From Newton magazine eMag Solutions 4

  5. Question: How Can We See Objects? Objects? Human Sensitivity Light (sub-class of electromagnetic waves) Birds Rod and cone Rod and cone E Eye From Newton magazine 5

  6. Question: How Can We See Objects? Objects? ● Emission and reflection ! Emission and reflection ! Light (sub-class of White light electromagnetic waves) Reflect green li ht light Absorb lights other than green light g g E Eye From Newton magazine 6 ● How about mirrors and white papers?

  7. Illumination Models Illumination Models ● Illumination ● Illumination ● Light energy transport from light sources between g surfaces via direct and indirect paths ● Shading ● Process of assigning colors to pixels colors to pixels 7

  8. Illumination Models Illumination Models ● Physically-based ● Physically-based ● Models based on the actual physics of light's interactions with matter te act o s t atte ● Empirical ● Simple formulations that approximate Simple formulations that approximate observed phenomenon 8

  9. Two Components of Illumination Two Components of Illumination ● Light sources: ● Light sources: ● Emittance spectrum (color) ● Geometry (position and direction) ● Geometry (position and direction) ● Directional attenuation ● Surface properties: p p ● Reflectance spectrum (color) ● Geometry (position, orientation, and micro- structure) ● Absorption 9

  10. Bi-Directional Reflectance Distribution Function (BRDF) Distribution Function (BRDF) ● Describes the transport of irradiance to Describes the transport of irradiance to radiance 10

  11. Measuring BRDFs Measuring BRDFs ● Goniophotometer ● One 4D measurement at a time (slow) 11

  12. How to use BRDF Data? How to use BRDF Data? One can make direct use of acquired BRDFs in a renderer 12

  13. Two Components of Illumination Two Components of Illumination ● Simplifications used by most computer ● Simplifications used by most computer graphics systems: ● Compute only direct illumination from the Compute only direct illumination from the emitters to the reflectors of the scene ● I gnore the geometry of light emitters, and consider only the geometry of reflectors id l h f fl 13

  14. Ambient Light Source Ambient Light Source ● A simple hack for indirect illumination A simple hack for indirect illumination ● I ncoming ambient illumination (I i,a ) is constant for all surfaces in the scene for all surfaces in the scene ● Reflected ambient illumination (I r,a ) depends only on the surface’s ambient reflection y coefficient (k a ) and not its position or  orientation I k I r ,a a i,a ● These quantities typically specified as (R, G, B) triples triples 14

  15. Point Light Sources Point Light Sources ● Point light sources emit rays from a single Point light sources emit rays from a single point ● Simple approximation to a local light source such as a ● Simple approximation to a local light source such as a light bulb  p l    p p  ˆ l L p l    p p p ˆ L  p ● The direction to the light changes across the surface the surface 15

  16. Directional Light Sources Directional Light Sources ● Light rays are parallel and have no origin Light rays are parallel and have no origin ● Can be considered as a point light at infinity ● A good approximation for sunlight ● A good approximation for sunlight ˆ L ● The direction to the light source is constant over the surface th f ● How can we specify point and directional lights? lights? 16

  17. Other Light Sources Other Light Sources ● Spotlights ● Spotlights ● Point source whose intensity falls off away te s ty a s o a ay from a given direction ● Area light sources g ● Occupies a 2D area (e.g. a polygon or a disk) ● Generates soft shadows 17

  18. Ideal Diffuse Reflection Ideal Diffuse Reflection ● I deal diffuse reflectors (e.g., chalk) I deal diffuse reflectors (e g chalk) ● Reflect uniformly over the hemisphere ● Reflection is view independent ● Reflection is view-independent ● Very rough at the microscopic level ● Follow Lambert’s cosine law ● Follow Lambert s cosine law 18

  19. Lambert’s Cosine Law Lambert s Cosine Law ● The reflected energy from a small surface area ● The reflected energy from a small surface area ˆ from illumination arriving from direction is L ˆ proportional to the cosine of the angle between L and the surface normal ˆ N I I cosθ  ˆ  L r i ˆ  I ( ( N L ) )  ˆ i i 19

  20. Computing Diffuse Reflection Computing Diffuse Reflection ● Constant of proportionality depends on Constant of proportionality depends on surface properties ˆ  I I k k I I ( ( N N L L ) )  ˆ r,d d d d i i ● The constant k d specifies how much of the incident light I i is diffusely reflected incident light I i is diffusely reflected Diffuse reflection for varying light directions   ˆ ˆ ● When the incident light is blocked by (N L) 0 the surface itself and the diffuse reflection is 0 the surface itself and the diffuse reflection is 0 20

  21. Specular Reflection Specular Reflection ● Specular reflectors have a bright view ● Specular reflectors have a bright, view dependent highlight ● E.g., polished metal, glossy car finish, a mirror E.g., polished metal, glossy car finish, a mirror ● At the microscopic level a specular reflecting surface is very smooth ● Specular reflection obeys Snell’s law Image source: astochimp.com and wiki 21

  22. Snell’s Law Snell s Law ● The relationship between the angles of ● The relationship between the angles of the incoming and reflected rays with the normal is given by: ˆ N N ˆ ˆ L   R    n sin n sin i o i i o o ● n and n are the indices of refraction for the ● n i and n o are the indices of refraction for the incoming and outgoing ray, respectively ● Reflection is a special case where n i = n o so  o n o so  o Reflection is a special case where n i =  i ● The incoming ray, the surface normal, and the reflected ray all lie in a common plane 22

  23. Computing the Reflection Vector Computing the Reflection Vector ● The vector R can be computed from the The vector R can be computed from the incoming light direction and the surface normal as shown below: normal as shown below: R (2( N L )) N L ˆ  ˆ  ˆ ˆ  ˆ ● How? ˆ ˆ ˆ N N ˆ ˆ L R ˆ  2( 2( N N L L )) )) N N ˆ ˆ  ˆ L 23

  24. Non Ideal Reflectors Non-Ideal Reflectors ● Snell’s law applies only to ideal specular Snell’s law applies only to ideal specular reflectors ● Roughness of surfaces causes highlight to ● Roughness of surfaces causes highlight to “spread out” ● Empirical models try to simulate the p y appearance of this effect, without trying to capture the physics of it ˆ N ˆ ˆ L R 24

  25. Phong Illumination Phong Illumination ● One of the most commonly used ● One of the most commonly used illumination models in computer graphics ● Empirical model and does not have no physical Empirical model and does not have no physical basis ˆ ˆ N V I I  k k I I (cos (cos ) ) n   ˆ ˆ s L R   r r s s i i n k I ( V R )  ˆ  ˆ s s i ● ˆ is the direction to the viewer (V) ˆ  ● ( V R ) ˆ ˆ ˆ is clamped to [0,1] i l d [0 ] ● The specular exponent n s controls how quickly the highlight falls off the highlight falls off 25

  26. Effect of Specular Exponent Effect of Specular Exponent ● How the shape of the highlight changes with varying n s 26

  27. Examples of Phong Examples of Phong varying light direction varying specular exponent 27

  28. Blinn & Torrance Variation Blinn & Torrance Variation ● Jim Blinn introduced another approach for Jim Blinn introduced another approach for computing Phong-like illumination based on the work of Ken Torrance: on the work of Ken Torrance: ˆ ˆ  L V ˆ ˆ  H N ˆ H ˆ ˆ L  L V V ˆ L ˆ V   ˆ ˆ n n I I k I(N H) k I(N H) s s r ,s s i ● ˆ is the half-way vector that bisects the i h h lf h bi h H light and viewer directions 28

  29. Putting it All Together Putting it All Together numLights Li ht  I (k j I j k j I j max(( N L ),0) k j I j max(( V R ) n ,0))   ˆ  ˆ  ˆ  ˆ s r a a d d j s s j 1  29

Recommend


More recommend