Illumination and Shading Illumination Lighting n n Model

  • Slides: 40
Download presentation
Illumination and Shading

Illumination and Shading

Illumination (Lighting) n n Model the interaction of light with surface points to determine

Illumination (Lighting) n n Model the interaction of light with surface points to determine their final color and brightness Open. GL computes illumination at vertices illumination

Shading n Apply the lighting model at a set of points across the entire

Shading n Apply the lighting model at a set of points across the entire surface Shading

Illumination Model n n The governing principles for computing the illumination A illumination model

Illumination Model n n The governing principles for computing the illumination A illumination model usually considers: n n Light attributes (light intensity, color, position, direction, shape) Object surface attributes (color, reflectivity, transparency, etc) Interaction among lights and objects (object orientation) Interaction between objects and eye (viewing dir. )

Illumination Model §mathematical Quality equations that of calculate the color of graphics each pixel

Illumination Model §mathematical Quality equations that of calculate the color of graphics each pixel of an object. § Tradeoffs must be made between the speed of the rendering and the quality of the rendering. High Complex models Simple models Low Slow Fast Speed of rendering

Illumination Calculation n Local illumination: only consider the light, the observer position, and the

Illumination Calculation n Local illumination: only consider the light, the observer position, and the object material properties q n Example: Open. GL

Illumination Models n Global illumination: take into account the interaction of light from all

Illumination Models n Global illumination: take into account the interaction of light from all the surfaces in the scene object 4 object 3 object 2 object 1

Light and object interaction n When light strikes an object it is: 1) absorbed

Light and object interaction n When light strikes an object it is: 1) absorbed and converted to heat, n 2) reflected off the surface, or n 3) refracted (bent) and passed through (e. g. , water, glass, cellophane) n

Light and object interaction n For an accurate lighting model, all three interactions must

Light and object interaction n For an accurate lighting model, all three interactions must be accounted for, but we will concentrate on reflected light. Reflected light is the light that has bounced off of an object into our eye (or camera). Reflected light is the light we actually see.

Reflected Light n The model used by Open. GL – consider three types of

Reflected Light n The model used by Open. GL – consider three types of light contribution to compute the final illumination of an object n n Ambient Diffuse Specular Final illumination of a point (vertex) = ambient + diffuse + specular

Ambient lighting example

Ambient lighting example

Diffuse lighting example

Diffuse lighting example

Specular light example

Specular light example

Ambient light n n general light in a room; background light that has been

Ambient light n n general light in a room; background light that has been scattered in so many directions that it's source cannot be determined (ambient light has no direction). ambient light determines the color of the portion of an object not in direct light. This is sometimes referred to as an object's "back side“. the relative position of the object, camera, and light sources has no effect on ambient light.

Ambient lighting example

Ambient lighting example

Ambient light calculation n Each light source has an ambient light contribution (Ia) Different

Ambient light calculation n Each light source has an ambient light contribution (Ia) Different objects can reflect different amounts of ambient (different ambient reflection coefficient Ka, 0 <= Ka <= 1) So the amount of ambient light that can be seen from an object is: Ambient = Ia x Ka

Diffuse light n n light that comes from one specific direction; scatters in all

Diffuse light n n light that comes from one specific direction; scatters in all directions a surface is brighter (scatters more light) if it is perpendicular to the light direction diffuse light is what gives an object its predominate color and what makes an object look "curved" or "rounded. " the relative position of the object to the light sources determines diffuse lighting.

Diffuse light contribution n Diffuse light: The illumination that a surface receives from a

Diffuse light contribution n Diffuse light: The illumination that a surface receives from a light source and reflects equally in all direction It does not matter where the eye is

Diffuse lighting example

Diffuse lighting example

Diffuse lighting example

Diffuse lighting example

Diffuse light calculation n Need to decide how much light the object point receive

Diffuse light calculation n Need to decide how much light the object point receive from the light source – based on Lambert’s Law Receive more light Receive less light

Diffuse light calculation (2) n Lambert’s law: the radiant energy D that a small

Diffuse light calculation (2) n Lambert’s law: the radiant energy D that a small surface patch receives from a light source is: D = I x cos (q) I: light intensity q: angle between the light vector and the surface normal light vector (vector from object to light) q N : surface normal

Diffuse light calculation (3) n n Like the ambient light case, different objects can

Diffuse light calculation (3) n n Like the ambient light case, different objects can reflect different amount of diffuse light (different diffuse reflection coefficient Kd, 0 <= Kd <= 1)) So, the amount of diffuse light that can be seen is: Diffuse = Kd x I x cos (q) q N L q cos(q) = N. L

Specular light n n light that comes from one specific direction and bounces off

Specular light n n light that comes from one specific direction and bounces off in one specific direction. the amount of specular light is determined by the smoothness of an object specular light causes a "hot spot" on shiny objects. The "hot spot" moves as the observer moves. the relative position of the object, camera, and light sources determine the amount of specular lighting.

Specular light contribution n n The bright spot on the object The result of

Specular light contribution n n The bright spot on the object The result of total reflection of the incident light in a concentrate region See nothing!

Specular light example

Specular light example

Specular light calculation n How much reflection you can see depends on where you

Specular light calculation n How much reflection you can see depends on where you are The only position the eye can see specular from P if the object has an ideal reflection surface q ? p f But for a non-perfect surface you will still see specular highlight when you move a little bit away from the idea reflection direction When f is small, you see more specular highlight

Specular light calculation (2) n Phong lighting model n specular = Ks x I

Specular light calculation (2) n Phong lighting model n specular = Ks x I x cos(f) Ks: specular reflection coefficient N: surface normal at P I: light intensity f: angle between V and R n cos(f): the larger is n, the smaller is the cos value cos(q) = R. V L N q R q p f V

Specular light calculation (3) n The effect of ‘n’ in the phong model

Specular light calculation (3) n The effect of ‘n’ in the phong model

Specular light calculation (4) n The effect of ‘n’ in the phong model n

Specular light calculation (4) n The effect of ‘n’ in the phong model n = 10 n = 90 n = 30 n = 270

Specular light

Specular light

Put it all together n Illumination from a light: Illum = ambient + diffuse

Put it all together n Illumination from a light: Illum = ambient + diffuse + specular n = Ka x I + Kd x I x (N. L) + Ks x I x (R. V) n If there are N lights Total illumination for a point P = S (Illum)

Summary of reflected light Camera (eye) Light Source Object Position n Ambient Light Diffuse

Summary of reflected light Camera (eye) Light Source Object Position n Ambient Light Diffuse Light Specular Light

Equations Light m P s v Camera Object A. Notation: Let P be the

Equations Light m P s v Camera Object A. Notation: Let P be the point on the object being rendered. m be the surface normal vector of the object at P. v be the vector from P to the eye (or camera). s be the vector from P to the light source.

Equations B. Calculating diffuse light Lambert's law: the amount of light reflected by a

Equations B. Calculating diffuse light Lambert's law: the amount of light reflected by a surface is proportional to the cos of the angle between the surface orientation (surface normal) and the location of the light source. 0 - 100% Reflection 45 - 70. 7% Reflection 80 - 17% Reflection cos curve from -90 to 90 - 0% Reflection

Equations The percentage of diffuse light can be calculated by taking the dot product

Equations The percentage of diffuse light can be calculated by taking the dot product of s and m (and dividing by their lengths if they are not unit vectors. ) Diffuse light percentage = s*m / |s||m| The cos curve goes negative if the angle between the two vectors is not in the range -90 to +90. Outside this range, the light does not strike the front surface of the object. Therefore we must make sure that if the angle is outside this range the calculation generates a zero percent reflection. Diffuse light percentage = max{ s*m / |s||m|, 0}

Equations C. Calculating specular light Specular light is reflected off of an object directly

Equations C. Calculating specular light Specular light is reflected off of an object directly into the camera. (It is typically white because the light is white. If the light was pure blue, the specular highlights would be pure blue. The specular highlights are the color of the light source and not the color of the object. ) Specular light is some percentage of the light source's light based on the light reflection off of the object into the camera.

Equations Light s Camera v m P Object r Reflection of light ray this

Equations Light s Camera v m P Object r Reflection of light ray this angle determines the percentage of specular light The amount of the reflected light that reaches the camera is proportional to the cos of the angle between the light reflection vector (r) and the vector from P to the camera (v).

Equations 0 - 100% Reflection 45 - 70. 7% Reflection 80 - 17% Reflection

Equations 0 - 100% Reflection 45 - 70. 7% Reflection 80 - 17% Reflection cos curve from -90 to 90 - 0% Reflection The percentage of specular light can be calculated by taking the dot product of r and v (and dividing by their lengths if they are not unit vectors. ) specular light percentage = r*v / |r||v|

Equations The cos curve goes negative if the angle between the two vectors is

Equations The cos curve goes negative if the angle between the two vectors is not in the range -90 to +90. Therefore we must make sure that if the angle is outside this range the calculation generates a zero percent specular reflection. Specular light percentage = max{ r*v / |r||v|, 0}