Lighting Dr Scott Schaefer 1 LightingIllumination n Color

  • Slides: 49
Download presentation
Lighting Dr. Scott Schaefer 1

Lighting Dr. Scott Schaefer 1

Lighting/Illumination n Color is a function of how light reflects from surfaces to the

Lighting/Illumination n Color is a function of how light reflects from surfaces to the eye Global illumination accounts for light from all sources as it is transmitted throughout the environment n Local illumination only accounts for light that directly hits a surface and is transmitted to the eye n 2/49

Global Illumination Image taken from http: //graphics. ucsd. edu/~henrik/images/cbox. html 3/49

Global Illumination Image taken from http: //graphics. ucsd. edu/~henrik/images/cbox. html 3/49

Reflection Models n Definition: Reflection is the process by which light incident on a

Reflection Models n Definition: Reflection is the process by which light incident on a surface interacts with the surface such that it leaves on the incident side without change in frequency. 4/49

Types of Reflection Functions n Ideal Specular u Reflection Law u Mirror n Ideal

Types of Reflection Functions n Ideal Specular u Reflection Law u Mirror n Ideal Diffuse u Lambert’s Law u Matte n Specular u Glossy u Directional diffuse 5/49

Illumination Model Ambient Light u Uniform light caused by secondary reflections n Diffuse Light

Illumination Model Ambient Light u Uniform light caused by secondary reflections n Diffuse Light u Light scattered equally in all directions n Specular Light u Highlights on shiny surfaces n 6/49

Ambient Light A =intensity of ambient light n ka=ambient reflection coefficient n Really 3

Ambient Light A =intensity of ambient light n ka=ambient reflection coefficient n Really 3 equations! (Red, Green, Blue) n Accounts for indirect illumination n Determines color of shadows n 7/49

Total Illumination 8/49

Total Illumination 8/49

Diffuse Light Assumes that light is reflected equally in all directions n Handles both

Diffuse Light Assumes that light is reflected equally in all directions n Handles both local and infinite light sources u Infinite distance: L doesn’t change u Finite distance: must calculate L for each point on surface n Surface 9/49

Diffuse Light n n n C = intensity of point light source kd =

Diffuse Light n n n C = intensity of point light source kd = diffuse reflection coefficient = angle between normal and direction to light Surface 10/49

Lambert’s Law Beam of Light Surface 11/49

Lambert’s Law Beam of Light Surface 11/49

Lambert’s Law Beam of Light Surface 12/49

Lambert’s Law Beam of Light Surface 12/49

Lambert’s Law Beam of Light Surface 13/49

Lambert’s Law Beam of Light Surface 13/49

Total Illumination 14/49

Total Illumination 14/49

Total Illumination 15/49

Total Illumination 15/49

Specular Light Perfect, mirror-like reflection of light from surface n Forms highlights on shiny

Specular Light Perfect, mirror-like reflection of light from surface n Forms highlights on shiny objects (metal, plastic) n Surface 16/49

Specular Light n n C = intensity of point light source ks =specular reflection

Specular Light n n C = intensity of point light source ks =specular reflection coefficient =angle between reflected vector (R) and eye (E) n =specular exponent Surface 17/49

Finding the Reflected Vector Surface 18/49

Finding the Reflected Vector Surface 18/49

Finding the Reflected Vector Surface 19/49

Finding the Reflected Vector Surface 19/49

Finding the Reflected Vector Surface 20/49

Finding the Reflected Vector Surface 20/49

Finding the Reflected Vector Surface 21/49

Finding the Reflected Vector Surface 21/49

Finding the Reflected Vector Surface 22/49

Finding the Reflected Vector Surface 22/49

Total Illumination 23/49

Total Illumination 23/49

Total Illumination 24/49

Total Illumination 24/49

Total Illumination 25/49

Total Illumination 25/49

Total Illumination 26/49

Total Illumination 26/49

Multiple Light Sources Only one ambient term no matter how many lights n Light

Multiple Light Sources Only one ambient term no matter how many lights n Light is additive; add contribution of multiple lights (diffuse/specular components) n 27/49

Total Illumination 28/49

Total Illumination 28/49

Total Illumination 29/49

Total Illumination 29/49

Attenuation n Decrease intensity with distance from light d = distance to light n

Attenuation n Decrease intensity with distance from light d = distance to light n r = radius of attenuation for light n 30/49

Attenuation 31/49

Attenuation 31/49

Attenuation 32/49

Attenuation 32/49

Spot Lights n Eliminate light contribution outside of a cone Surface 33/49

Spot Lights n Eliminate light contribution outside of a cone Surface 33/49

Spot Lights n Eliminate light contribution outside of a cone Surface 34/49

Spot Lights n Eliminate light contribution outside of a cone Surface 34/49

Spot Lights 35/49

Spot Lights 35/49

Spot Lights 36/49

Spot Lights 36/49

Spot Lights 37/49

Spot Lights 37/49

Implementation Considerations Surface 38/49

Implementation Considerations Surface 38/49

Implementation Considerations n Two options: u 2 -sided: negate u 1 -sided: if else

Implementation Considerations n Two options: u 2 -sided: negate u 1 -sided: if else for back-facing polygons , // light on back of surface Surface 39/49

Implementation Considerations Typically choose n Clamp each color component to [0, 1] n 40/49

Implementation Considerations Typically choose n Clamp each color component to [0, 1] n 40/49

Open. GL and Lighting Specify normals for geometry n Create/position lights n Specify material

Open. GL and Lighting Specify normals for geometry n Create/position lights n Specify material properties n Select lighting model n 41/49

Open. GL and Lighting Specify normals for geometry n Create/position lights n Specify material

Open. GL and Lighting Specify normals for geometry n Create/position lights n Specify material properties n Select lighting model n 42/49

Open. GL and Lighting gl. Begin(GL_TRIANGLES); … gl. Normal 3 f(nx, ny, nz); gl.

Open. GL and Lighting gl. Begin(GL_TRIANGLES); … gl. Normal 3 f(nx, ny, nz); gl. Vertex 3 f(x, y, z); … gl. End(); 43/49

Open. GL and Lighting Specify normals for geometry n Create/position lights n Specify material

Open. GL and Lighting Specify normals for geometry n Create/position lights n Specify material properties n Select lighting model n 44/49

Open. GL and Lighting float light_position[] = {0, -10, 0, 1}; float light_ambient[] =

Open. GL and Lighting float light_position[] = {0, -10, 0, 1}; float light_ambient[] = {. 1, 1}; float light_diffuse[] = {. 9, 1}; float light_specular[] = {1, 1, 1, 1}; gl. Lightfv(GL_LIGHT 0, GL_POSITION, light_position); gl. Lightfv(GL_LIGHT 0, GL_AMBIENT, light_ambient); gl. Lightfv(GL_LIGHT 0, GL_DIFFUSE, light_diffuse); gl. Lightfv(GL_LIGHT 0, GL_SPECULAR, light_specular); gl. Enable(GL_LIGHT 0); gl. Enable(GL_LIGHTING); 45/49

Open. GL and Lighting Specify normals for geometry n Create/position lights n Specify material

Open. GL and Lighting Specify normals for geometry n Create/position lights n Specify material properties n Select lighting model n 46/49

Open. GL and Lighting float mat_ambient[] = {1, 0, 0, 1}; float mat_diffuse[] =

Open. GL and Lighting float mat_ambient[] = {1, 0, 0, 1}; float mat_diffuse[] = {1, 0, 0, 1}; float mat_specular[] = {1, 1, 1, 1}; float mat_shiny[] = {50}; gl. Materialfv(GL_FRONT, GL_AMBIENT, mat_ambient); gl. Materialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); gl. Materialfv(GL_FRONT, GL_SPECULAR, mat_specular); gl. Materialfv(GL_FRONT, GL_SHININESS, mat_shiny); 47/49

Open. GL and Lighting Specify normals for geometry n Create/position lights n Specify material

Open. GL and Lighting Specify normals for geometry n Create/position lights n Specify material properties n Select lighting model n 48/49

Open. GL and Lighting gl. Light. Modelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); gl. Light. Modelfv(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); 49/49

Open. GL and Lighting gl. Light. Modelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); gl. Light. Modelfv(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); 49/49