Download
pg geldenhuys n.
Skip this Video
Loading SlideShow in 5 Seconds..
PG Geldenhuys PowerPoint Presentation
Download Presentation
PG Geldenhuys

PG Geldenhuys

2 Vues Download Presentation
Télécharger la présentation

PG Geldenhuys

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Illumination Models PG Geldenhuys

  2. Real World Lighting Physical objects tend to interact with light in three ways: • Absorption (black body) • Reflection (mirror) • Transmission (glass)

  3. 1. Incoming light 3. Reflected light 2. Surface colour Components of Colour All colours in the spectrum can be represented through the combination of intensities of 3 distinct colours,namely:red, green, blue • In coming light carries information about the intensity of each of its 3 components. • The reflected intensity of each component is calculated individually. • The resulting colour of the reflected light is then the combination of the 3 reflected components.

  4. Lighting in OpenGL The Phong Illumination model empirically divides reflection into 3 components: • Diffuse (Lambertian) • Specular • Ambient Lambertian Explained – Diffuse reflection arises from the assumption that light from any direction is reflected uniformly in all direction. Such a reflector is called a pure Lambertian reflector. Most objects are not perfect Lambertian reflectors. One of the most common deviations is for smooth metallic or highly polished objects. They tend to have specular highlights (or “shiny spots”).

  5. Diffuse Light • Does not originate from the source!! • It is a component of the reflection due to even scattering of light by uniform, rough surfaces. • Depends on the direction of the light and the surface normal. • Therefore Light emitted in all directions (moving the camera relative to the surface and light source will not change how much the face is lit)

  6. The amount of diffuse light emitted, does depend on the orientation of surface to the light source. A surface  to light source emits the most light A surface at some arbitrary angle to the source emits light whose intensity is dependent on the angle A surface // to light source emits no light Id – Intensity of emitted light Is – Intensity of light source d – diffuse reflection coefficient (for material) Or…

  7. Note: Its not possible to have a negative intensity!! When  > 90 or  < -90  Id = 0 We could then rewrite the formula above as follows : Note: • This is not a physically accurate model: • True light is not composed of three components, but an entire spectrum of frequencies. • In reality, Light intensity is inversely proportional to the distance from the source squared.

  8. Why does OpenGL not stick to a physically accurate lighting model? Realistically, objects emit diffuse light from all points on their surface, which once again should fall incident on every other object in the room. Practically, OpenGL allows only eight light sources to be used.

  9. Specular Light • Originates from the source, not the material!! • Material colour should not influence it • Causes highlights to appear on shiny surfaces in a mirror-like way. • Light is emitted in specific directions (moving the camera relative to the surface and light source is expected to change which portions of the face are lit)

  10. i r i r Phong Model • Method used by OpenGL to simulate specular lighting • Best for modeling plastic or glassy materials, not very good for metals Perfect Mirror Phong Model For one particular angle of incidence, light is reflected in a number of directions, but is most intense in the direction where i = r. On either side of this angle, the intensity drops off to 0. Light is only reflected in the direction where i = r

  11. i r Phong Model The intensity varies as some complicated function of , but in the Phong Model, it is made to vary according to the following function: cosf(), where f should range somewhere in the region between 0 and 200. r v Isp – Intensity of reflected light Is – Intensity of specular light source s – specular reflection coefficient (for material)  - angle between viewing vector and maximum reflection vector Or…

  12. i Note: Its not possible to have a negative intensity!! When  > 90 or  < -90  Isp = 0 We could then rewrite the formula above as follows : Note: This diagram is a polar plot, so the length of the arrows on the right hand side, represent the reflected intensity for different camera angles relative to the normal.

  13. f The graph above, shows how the function: cosf() varies with different values of f. When f = 1, the shininess of the material is low, and the specular highlight will be large. When f = 256, the shininess of the material is high (the material is almost mirror like), and the specular highlight will be small.

  14. Reasons for Ambient Light • In the real world, light reflecting off walls and other objects accounts for a lot of the light in a room. • Physically, if an object were placed in a lit room, even the faces not directed towards the light would be visible. • If only diffuse and specular light were applied to a scene, large areas of it would be left in darkness. (Areas where the angles between the normal to a face and the light vector were greater than 90, or less than 0 degrees) (Shadows would appear unrealistically dark)

  15. Ambient Light Ambient light has a uniform intensity in all directions, and serves to increase the overall brightness of the environment. Ia – Intensity of ambient light Pa – Ambient coefficient of surface. • Too little – Shadows too harsh • Too much – picture appears bland

  16. The Overall Picture The overall light intensity used to shade each face of an object, is now simply the sum of the three different light intensities incident on that face i.e. Intensity = + + This calculation must then be performed for each of the threelight components (R,G, B) to calculate the overall colour ofthat face.

  17. Intensity = + + Application of the Model This is the very formula used by OpenGL, and its parameters are set as follows: Ambient Specular Diffuse • Is : Use glLight, set • GL_SPECULAR to the • desired RGB value • s : Use glMaterial, set GL_SPECULAR to the desired RGB value. • f : Use glMaterial, set GL_SHININESS to the desired floating point value. • Ia : Use glLight, set • GL_AMBIENT to the • desired RGB value • a : Use glMaterial, set • GL_AMBIENT to the • desired RGB value. • Id : Use glLight, set • GL_DIFFUSE to the • desired RGB value • d : Use glMaterial, set • GL_DIFFUSE to the • desired RGB value.

  18. Wow . . . For multiple light sources, we add up the ambient, diffuse, and specular components for each light source to produce the final product . . .

  19. References • Lecture notes on illumination by Steve Sterley. • Illumination models by Prof Jonathan Cohen from the Johns Hopkins Department Of Computer Science. • Graphics: Illumination, The University Of Texas Austin. • Illumination models and Shading, Foley & Van Dam.