Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of...
Transcript of Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of...
![Page 1: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/1.jpg)
Physical properties of light
![Page 2: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/2.jpg)
Physical properties of light
Light consists of photons — “particles” with no mass which
travel at the speed of light.
![Page 3: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/3.jpg)
Physical properties of light
Light consists of photons — “particles” with no mass which
travel at the speed of light. They have energy, and one measure
of this energy is the “wavelength” of the light.
![Page 4: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/4.jpg)
Physical properties of light
Light consists of photons — “particles” with no mass which
travel at the speed of light. They have energy, and one measure
of this energy is the “wavelength” of the light.
To a very good approximation, light travels in straight lines, and
behaves much like a particle.
![Page 5: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/5.jpg)
Physical properties of light
Light consists of photons — “particles” with no mass which
travel at the speed of light. They have energy, and one measure
of this energy is the “wavelength” of the light.
To a very good approximation, light travels in straight lines, and
behaves much like a particle. (In some circumstances, light has
wave properties — interference and diffraction effects — but
these are rarely important in computer graphics.)
![Page 6: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/6.jpg)
Physical properties of light
Light consists of photons — “particles” with no mass which
travel at the speed of light. They have energy, and one measure
of this energy is the “wavelength” of the light.
To a very good approximation, light travels in straight lines, and
behaves much like a particle. (In some circumstances, light has
wave properties — interference and diffraction effects — but
these are rarely important in computer graphics.)
Light may be “bent” or refracted in transparent substances, and
the degree of bending, or refraction, depends upon a quantity
called the refractive index.
![Page 7: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/7.jpg)
Physical properties of light
Light consists of photons — “particles” with no mass which
travel at the speed of light. They have energy, and one measure
of this energy is the “wavelength” of the light.
To a very good approximation, light travels in straight lines, and
behaves much like a particle. (In some circumstances, light has
wave properties — interference and diffraction effects — but
these are rarely important in computer graphics.)
Light may be “bent” or refracted in transparent substances, and
the degree of bending, or refraction, depends upon a quantity
called the refractive index.
When light is incident on a shiny, flat surface, it is reflected.
![Page 8: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/8.jpg)
Physical properties of light
Light consists of photons — “particles” with no mass which
travel at the speed of light. They have energy, and one measure
of this energy is the “wavelength” of the light.
To a very good approximation, light travels in straight lines, and
behaves much like a particle. (In some circumstances, light has
wave properties — interference and diffraction effects — but
these are rarely important in computer graphics.)
Light may be “bent” or refracted in transparent substances, and
the degree of bending, or refraction, depends upon a quantity
called the refractive index.
When light is incident on a shiny, flat surface, it is reflected.
The reflected light leaves the surface at an angle such that the
angle between the incident light and a normal to the surface is
equal to the same angle for the reflected light.
![Page 9: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/9.jpg)
Physical properties of light
Light consists of photons — “particles” with no mass which
travel at the speed of light. They have energy, and one measure
of this energy is the “wavelength” of the light.
To a very good approximation, light travels in straight lines, and
behaves much like a particle. (In some circumstances, light has
wave properties — interference and diffraction effects — but
these are rarely important in computer graphics.)
Light may be “bent” or refracted in transparent substances, and
the degree of bending, or refraction, depends upon a quantity
called the refractive index.
When light is incident on a shiny, flat surface, it is reflected.
The reflected light leaves the surface at an angle such that the
angle between the incident light and a normal to the surface is
equal to the same angle for the reflected light.
incident light
normal
incident light reflected light
refracted light
![Page 10: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/10.jpg)
Physical properties of light
Light consists of photons — “particles” with no mass which
travel at the speed of light. They have energy, and one measure
of this energy is the “wavelength” of the light.
To a very good approximation, light travels in straight lines, and
behaves much like a particle. (In some circumstances, light has
wave properties — interference and diffraction effects — but
these are rarely important in computer graphics.)
Light may be “bent” or refracted in transparent substances, and
the degree of bending, or refraction, depends upon a quantity
called the refractive index.
When light is incident on a shiny, flat surface, it is reflected.
The reflected light leaves the surface at an angle such that the
angle between the incident light and a normal to the surface is
equal to the same angle for the reflected light.
incident light
normal
incident light reflected light
refracted light
1
![Page 11: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/11.jpg)
Physical properties of surfaces
Surfaces have different characteristics with respect to their inter-
action with light.
![Page 12: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/12.jpg)
Physical properties of surfaces
Surfaces have different characteristics with respect to their inter-
action with light. Some surfaces are “shiny” and reflect most
of the light incident on the surface.
![Page 13: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/13.jpg)
Physical properties of surfaces
Surfaces have different characteristics with respect to their inter-
action with light. Some surfaces are “shiny” and reflect most
of the light incident on the surface. Others are dull and reflect
little light at all.
![Page 14: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/14.jpg)
Physical properties of surfaces
Surfaces have different characteristics with respect to their inter-
action with light. Some surfaces are “shiny” and reflect most
of the light incident on the surface. Others are dull and reflect
little light at all.
Surfaces have “color” — the color comes from the light incident
on the surface, which may reflect some spectral components,
and absorb others.
![Page 15: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/15.jpg)
Physical properties of surfaces
Surfaces have different characteristics with respect to their inter-
action with light. Some surfaces are “shiny” and reflect most
of the light incident on the surface. Others are dull and reflect
little light at all.
Surfaces have “color” — the color comes from the light incident
on the surface, which may reflect some spectral components,
and absorb others. A red painted cube reflects red light, but
absorbs green and blue light.
![Page 16: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/16.jpg)
Physical properties of surfaces
Surfaces have different characteristics with respect to their inter-
action with light. Some surfaces are “shiny” and reflect most
of the light incident on the surface. Others are dull and reflect
little light at all.
Surfaces have “color” — the color comes from the light incident
on the surface, which may reflect some spectral components,
and absorb others. A red painted cube reflects red light, but
absorbs green and blue light. If illuminated by pure green or
blue light, the cube would appear black.
![Page 17: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/17.jpg)
Physical properties of surfaces
Surfaces have different characteristics with respect to their inter-
action with light. Some surfaces are “shiny” and reflect most
of the light incident on the surface. Others are dull and reflect
little light at all.
Surfaces have “color” — the color comes from the light incident
on the surface, which may reflect some spectral components,
and absorb others. A red painted cube reflects red light, but
absorbs green and blue light. If illuminated by pure green or
blue light, the cube would appear black.
Some surfaces, like a CRT screen, for example, emit their own
light, in varying colors and intensities.
![Page 18: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/18.jpg)
Physical properties of surfaces
Surfaces have different characteristics with respect to their inter-
action with light. Some surfaces are “shiny” and reflect most
of the light incident on the surface. Others are dull and reflect
little light at all.
Surfaces have “color” — the color comes from the light incident
on the surface, which may reflect some spectral components,
and absorb others. A red painted cube reflects red light, but
absorbs green and blue light. If illuminated by pure green or
blue light, the cube would appear black.
Some surfaces, like a CRT screen, for example, emit their own
light, in varying colors and intensities.
Characteristics like “roughness” are also important in determin-
ing the interaction between light and a surface.
![Page 19: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/19.jpg)
Physical properties of surfaces
Surfaces have different characteristics with respect to their inter-
action with light. Some surfaces are “shiny” and reflect most
of the light incident on the surface. Others are dull and reflect
little light at all.
Surfaces have “color” — the color comes from the light incident
on the surface, which may reflect some spectral components,
and absorb others. A red painted cube reflects red light, but
absorbs green and blue light. If illuminated by pure green or
blue light, the cube would appear black.
Some surfaces, like a CRT screen, for example, emit their own
light, in varying colors and intensities.
Characteristics like “roughness” are also important in determin-
ing the interaction between light and a surface. Also, some ma-
terials can be transparent and this transparency may be wave-
length dependent (a red plastic screen transmits only red light,
it absorbs the rest).
![Page 20: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/20.jpg)
Physical properties of surfaces
Surfaces have different characteristics with respect to their inter-
action with light. Some surfaces are “shiny” and reflect most
of the light incident on the surface. Others are dull and reflect
little light at all.
Surfaces have “color” — the color comes from the light incident
on the surface, which may reflect some spectral components,
and absorb others. A red painted cube reflects red light, but
absorbs green and blue light. If illuminated by pure green or
blue light, the cube would appear black.
Some surfaces, like a CRT screen, for example, emit their own
light, in varying colors and intensities.
Characteristics like “roughness” are also important in determin-
ing the interaction between light and a surface. Also, some ma-
terials can be transparent and this transparency may be wave-
length dependent (a red plastic screen transmits only red light,
it absorbs the rest).
2
![Page 21: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/21.jpg)
Illumination
![Page 22: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/22.jpg)
Illumination
Indirect light which has been scattered by many sources is
known as ambient light.
![Page 23: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/23.jpg)
Illumination
Indirect light which has been scattered by many sources is
known as ambient light. You can think of ambient light as
background light.
![Page 24: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/24.jpg)
Illumination
Indirect light which has been scattered by many sources is
known as ambient light. You can think of ambient light as
background light. When ambient light interacts with a sur-
face, it is scattered in all directions.
![Page 25: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/25.jpg)
Illumination
Indirect light which has been scattered by many sources is
known as ambient light. You can think of ambient light as
background light. When ambient light interacts with a sur-
face, it is scattered in all directions.
Light which is strongly directional (e.g. a laser beam) is said
to be specular.
![Page 26: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/26.jpg)
Illumination
Indirect light which has been scattered by many sources is
known as ambient light. You can think of ambient light as
background light. When ambient light interacts with a sur-
face, it is scattered in all directions.
Light which is strongly directional (e.g. a laser beam) is said
to be specular. When interacting with a shiny surface, most
of this light is reflected as from a mirror.
![Page 27: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/27.jpg)
Illumination
Indirect light which has been scattered by many sources is
known as ambient light. You can think of ambient light as
background light. When ambient light interacts with a sur-
face, it is scattered in all directions.
Light which is strongly directional (e.g. a laser beam) is said
to be specular. When interacting with a shiny surface, most
of this light is reflected as from a mirror. (Specularity is really
a material property, but in graphics the term is also applied to
light sources.)
![Page 28: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/28.jpg)
Illumination
Indirect light which has been scattered by many sources is
known as ambient light. You can think of ambient light as
background light. When ambient light interacts with a sur-
face, it is scattered in all directions.
Light which is strongly directional (e.g. a laser beam) is said
to be specular. When interacting with a shiny surface, most
of this light is reflected as from a mirror. (Specularity is really
a material property, but in graphics the term is also applied to
light sources.)
The diffuse component of light comes from one direction, so
it is brighter if it shines directly on a surface than if it meets
the surface at an angle.
![Page 29: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/29.jpg)
Illumination
Indirect light which has been scattered by many sources is
known as ambient light. You can think of ambient light as
background light. When ambient light interacts with a sur-
face, it is scattered in all directions.
Light which is strongly directional (e.g. a laser beam) is said
to be specular. When interacting with a shiny surface, most
of this light is reflected as from a mirror. (Specularity is really
a material property, but in graphics the term is also applied to
light sources.)
The diffuse component of light comes from one direction, so
it is brighter if it shines directly on a surface than if it meets
the surface at an angle. Unlike specular light, diffuse light is
scattered in all directions after striking a surface.
![Page 30: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/30.jpg)
Illumination
Indirect light which has been scattered by many sources is
known as ambient light. You can think of ambient light as
background light. When ambient light interacts with a sur-
face, it is scattered in all directions.
Light which is strongly directional (e.g. a laser beam) is said
to be specular. When interacting with a shiny surface, most
of this light is reflected as from a mirror. (Specularity is really
a material property, but in graphics the term is also applied to
light sources.)
The diffuse component of light comes from one direction, so
it is brighter if it shines directly on a surface than if it meets
the surface at an angle. Unlike specular light, diffuse light is
scattered in all directions after striking a surface.
3
![Page 31: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/31.jpg)
SpecularDiffuseAmbient
![Page 32: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/32.jpg)
SpecularDiffuseAmbient
ambient — rays come from and scatter into all directions
![Page 33: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/33.jpg)
SpecularDiffuseAmbient
ambient — rays come from and scatter into all directions
diffuse — rays come from one direction, scatter into all directions
![Page 34: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/34.jpg)
SpecularDiffuseAmbient
ambient — rays come from and scatter into all directions
diffuse — rays come from one direction, scatter into all directions
specular — rays come from one direction, reflect into one direction
![Page 35: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/35.jpg)
SpecularDiffuseAmbient
ambient — rays come from and scatter into all directions
diffuse — rays come from one direction, scatter into all directions
specular — rays come from one direction, reflect into one direction
For specular light, the normal to the surface is used to calculate
the direction into which the reflected light is scattered.
![Page 36: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/36.jpg)
SpecularDiffuseAmbient
ambient — rays come from and scatter into all directions
diffuse — rays come from one direction, scatter into all directions
specular — rays come from one direction, reflect into one direction
For specular light, the normal to the surface is used to calculate
the direction into which the reflected light is scattered. The
normal is also used to determine the degree of diffuse lighting.
![Page 37: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/37.jpg)
SpecularDiffuseAmbient
ambient — rays come from and scatter into all directions
diffuse — rays come from one direction, scatter into all directions
specular — rays come from one direction, reflect into one direction
For specular light, the normal to the surface is used to calculate
the direction into which the reflected light is scattered. The
normal is also used to determine the degree of diffuse lighting.
Thus, normals must be defined in order to use lighting.
![Page 38: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/38.jpg)
SpecularDiffuseAmbient
ambient — rays come from and scatter into all directions
diffuse — rays come from one direction, scatter into all directions
specular — rays come from one direction, reflect into one direction
For specular light, the normal to the surface is used to calculate
the direction into which the reflected light is scattered. The
normal is also used to determine the degree of diffuse lighting.
Thus, normals must be defined in order to use lighting.
Light also has the property that it reduces in intensity with dis-
tance from the source.
![Page 39: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/39.jpg)
SpecularDiffuseAmbient
ambient — rays come from and scatter into all directions
diffuse — rays come from one direction, scatter into all directions
specular — rays come from one direction, reflect into one direction
For specular light, the normal to the surface is used to calculate
the direction into which the reflected light is scattered. The
normal is also used to determine the degree of diffuse lighting.
Thus, normals must be defined in order to use lighting.
Light also has the property that it reduces in intensity with dis-
tance from the source. In particular, light from a point source
decreased in intensity proportional to the square of the distance
from the source.
![Page 40: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/40.jpg)
SpecularDiffuseAmbient
ambient — rays come from and scatter into all directions
diffuse — rays come from one direction, scatter into all directions
specular — rays come from one direction, reflect into one direction
For specular light, the normal to the surface is used to calculate
the direction into which the reflected light is scattered. The
normal is also used to determine the degree of diffuse lighting.
Thus, normals must be defined in order to use lighting.
Light also has the property that it reduces in intensity with dis-
tance from the source. In particular, light from a point source
decreased in intensity proportional to the square of the distance
from the source. For a long linear light source, the intensity
decreases proportional to the distance from the source.
![Page 41: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/41.jpg)
SpecularDiffuseAmbient
ambient — rays come from and scatter into all directions
diffuse — rays come from one direction, scatter into all directions
specular — rays come from one direction, reflect into one direction
For specular light, the normal to the surface is used to calculate
the direction into which the reflected light is scattered. The
normal is also used to determine the degree of diffuse lighting.
Thus, normals must be defined in order to use lighting.
Light also has the property that it reduces in intensity with dis-
tance from the source. In particular, light from a point source
decreased in intensity proportional to the square of the distance
from the source. For a long linear light source, the intensity
decreases proportional to the distance from the source.
Other light sources (spotlights, and other lights containing re-
flecting or lens elements) may have more complex functions.
![Page 42: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/42.jpg)
SpecularDiffuseAmbient
ambient — rays come from and scatter into all directions
diffuse — rays come from one direction, scatter into all directions
specular — rays come from one direction, reflect into one direction
For specular light, the normal to the surface is used to calculate
the direction into which the reflected light is scattered. The
normal is also used to determine the degree of diffuse lighting.
Thus, normals must be defined in order to use lighting.
Light also has the property that it reduces in intensity with dis-
tance from the source. In particular, light from a point source
decreased in intensity proportional to the square of the distance
from the source. For a long linear light source, the intensity
decreases proportional to the distance from the source.
Other light sources (spotlights, and other lights containing re-
flecting or lens elements) may have more complex functions.
4
![Page 43: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/43.jpg)
Rendering lit scenes realistically
We require a simple model for lighting which allows us to model
both light sources and surface properties efficiently.
![Page 44: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/44.jpg)
Rendering lit scenes realistically
We require a simple model for lighting which allows us to model
both light sources and surface properties efficiently.
Ideally, we would assign the appropriate physical properties to
each surface and calculate the surface interactions of every visi-
ble ray of light from the viewer’s eye position back to the source.
![Page 45: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/45.jpg)
Rendering lit scenes realistically
We require a simple model for lighting which allows us to model
both light sources and surface properties efficiently.
Ideally, we would assign the appropriate physical properties to
each surface and calculate the surface interactions of every visi-
ble ray of light from the viewer’s eye position back to the source.
This would produce a very realistic image (if all properties were
well modelled), but would be very computationally expensive.
![Page 46: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/46.jpg)
Rendering lit scenes realistically
We require a simple model for lighting which allows us to model
both light sources and surface properties efficiently.
Ideally, we would assign the appropriate physical properties to
each surface and calculate the surface interactions of every visi-
ble ray of light from the viewer’s eye position back to the source.
This would produce a very realistic image (if all properties were
well modelled), but would be very computationally expensive.
This method is known as ray tracing.
![Page 47: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/47.jpg)
Rendering lit scenes realistically
We require a simple model for lighting which allows us to model
both light sources and surface properties efficiently.
Ideally, we would assign the appropriate physical properties to
each surface and calculate the surface interactions of every visi-
ble ray of light from the viewer’s eye position back to the source.
This would produce a very realistic image (if all properties were
well modelled), but would be very computationally expensive.
This method is known as ray tracing. It can produce very
realistic images, including refraction, shadows and multiple re-
flections, but at very high computational cost.
![Page 48: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/48.jpg)
Rendering lit scenes realistically
We require a simple model for lighting which allows us to model
both light sources and surface properties efficiently.
Ideally, we would assign the appropriate physical properties to
each surface and calculate the surface interactions of every visi-
ble ray of light from the viewer’s eye position back to the source.
This would produce a very realistic image (if all properties were
well modelled), but would be very computationally expensive.
This method is known as ray tracing. It can produce very
realistic images, including refraction, shadows and multiple re-
flections, but at very high computational cost.
OpenGL uses a relatively simple model for lighting.
![Page 49: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/49.jpg)
Rendering lit scenes realistically
We require a simple model for lighting which allows us to model
both light sources and surface properties efficiently.
Ideally, we would assign the appropriate physical properties to
each surface and calculate the surface interactions of every visi-
ble ray of light from the viewer’s eye position back to the source.
This would produce a very realistic image (if all properties were
well modelled), but would be very computationally expensive.
This method is known as ray tracing. It can produce very
realistic images, including refraction, shadows and multiple re-
flections, but at very high computational cost.
OpenGL uses a relatively simple model for lighting. It defines
a set of properties for materials, a set of light sources, and
a lighting model.
![Page 50: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/50.jpg)
Rendering lit scenes realistically
We require a simple model for lighting which allows us to model
both light sources and surface properties efficiently.
Ideally, we would assign the appropriate physical properties to
each surface and calculate the surface interactions of every visi-
ble ray of light from the viewer’s eye position back to the source.
This would produce a very realistic image (if all properties were
well modelled), but would be very computationally expensive.
This method is known as ray tracing. It can produce very
realistic images, including refraction, shadows and multiple re-
flections, but at very high computational cost.
OpenGL uses a relatively simple model for lighting. It defines
a set of properties for materials, a set of light sources, and
a lighting model. This model cannot account for secondary
effects like shadows or reflected illumination, but it produces
reasonable illumination effects efficiently.
![Page 51: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/51.jpg)
Rendering lit scenes realistically
We require a simple model for lighting which allows us to model
both light sources and surface properties efficiently.
Ideally, we would assign the appropriate physical properties to
each surface and calculate the surface interactions of every visi-
ble ray of light from the viewer’s eye position back to the source.
This would produce a very realistic image (if all properties were
well modelled), but would be very computationally expensive.
This method is known as ray tracing. It can produce very
realistic images, including refraction, shadows and multiple re-
flections, but at very high computational cost.
OpenGL uses a relatively simple model for lighting. It defines
a set of properties for materials, a set of light sources, and
a lighting model. This model cannot account for secondary
effects like shadows or reflected illumination, but it produces
reasonable illumination effects efficiently.
5
![Page 52: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/52.jpg)
Lighting models in OpenGL
![Page 53: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/53.jpg)
Lighting models in OpenGL
In order to add lighting to a scene, the following steps are
required:
![Page 54: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/54.jpg)
Lighting models in OpenGL
In order to add lighting to a scene, the following steps are
required:
• Define normals at each vertex for every object.
![Page 55: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/55.jpg)
Lighting models in OpenGL
In order to add lighting to a scene, the following steps are
required:
• Define normals at each vertex for every object. (More on
this soon)
![Page 56: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/56.jpg)
Lighting models in OpenGL
In order to add lighting to a scene, the following steps are
required:
• Define normals at each vertex for every object. (More on
this soon)
• Create and position one or more light sources with glLight*().
(OpenGL supports at least 8 light sources).
![Page 57: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/57.jpg)
Lighting models in OpenGL
In order to add lighting to a scene, the following steps are
required:
• Define normals at each vertex for every object. (More on
this soon)
• Create and position one or more light sources with glLight*().
(OpenGL supports at least 8 light sources).
• Select a lighting model; with glLightModel*(). This de-
fines the level of (global) ambient light, and the effective
location of the viewpoint (for the lighting calculations).
![Page 58: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/58.jpg)
Lighting models in OpenGL
In order to add lighting to a scene, the following steps are
required:
• Define normals at each vertex for every object. (More on
this soon)
• Create and position one or more light sources with glLight*().
(OpenGL supports at least 8 light sources).
• Select a lighting model; with glLightModel*(). This de-
fines the level of (global) ambient light, and the effective
location of the viewpoint (for the lighting calculations).
• Define the material properties for each object in the scene
with glMaterial*().
![Page 59: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/59.jpg)
Lighting models in OpenGL
In order to add lighting to a scene, the following steps are
required:
• Define normals at each vertex for every object. (More on
this soon)
• Create and position one or more light sources with glLight*().
(OpenGL supports at least 8 light sources).
• Select a lighting model; with glLightModel*(). This de-
fines the level of (global) ambient light, and the effective
location of the viewpoint (for the lighting calculations).
• Define the material properties for each object in the scene
with glMaterial*().
void glLight{if}(GLenum light, GLenum pname,
TYPE param);
![Page 60: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/60.jpg)
Lighting models in OpenGL
In order to add lighting to a scene, the following steps are
required:
• Define normals at each vertex for every object. (More on
this soon)
• Create and position one or more light sources with glLight*().
(OpenGL supports at least 8 light sources).
• Select a lighting model; with glLightModel*(). This de-
fines the level of (global) ambient light, and the effective
location of the viewpoint (for the lighting calculations).
• Define the material properties for each object in the scene
with glMaterial*().
void glLight{if}(GLenum light, GLenum pname,
TYPE param);
void glLight{if}v(GLenum light, GLenum pname,
TYPE *param);
![Page 61: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/61.jpg)
Lighting models in OpenGL
In order to add lighting to a scene, the following steps are
required:
• Define normals at each vertex for every object. (More on
this soon)
• Create and position one or more light sources with glLight*().
(OpenGL supports at least 8 light sources).
• Select a lighting model; with glLightModel*(). This de-
fines the level of (global) ambient light, and the effective
location of the viewpoint (for the lighting calculations).
• Define the material properties for each object in the scene
with glMaterial*().
void glLight{if}(GLenum light, GLenum pname,
TYPE param);
void glLight{if}v(GLenum light, GLenum pname,
TYPE *param);
create the light specified by GL_LIGHT0, GL_LIGHT1, . . . with
properties given by pname;
![Page 62: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/62.jpg)
Lighting models in OpenGL
In order to add lighting to a scene, the following steps are
required:
• Define normals at each vertex for every object. (More on
this soon)
• Create and position one or more light sources with glLight*().
(OpenGL supports at least 8 light sources).
• Select a lighting model; with glLightModel*(). This de-
fines the level of (global) ambient light, and the effective
location of the viewpoint (for the lighting calculations).
• Define the material properties for each object in the scene
with glMaterial*().
void glLight{if}(GLenum light, GLenum pname,
TYPE param);
void glLight{if}v(GLenum light, GLenum pname,
TYPE *param);
create the light specified by GL_LIGHT0, GL_LIGHT1, . . . with
properties given by pname; param specifies the set of param-
eters for the properties pname.
![Page 63: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/63.jpg)
Lighting models in OpenGL
In order to add lighting to a scene, the following steps are
required:
• Define normals at each vertex for every object. (More on
this soon)
• Create and position one or more light sources with glLight*().
(OpenGL supports at least 8 light sources).
• Select a lighting model; with glLightModel*(). This de-
fines the level of (global) ambient light, and the effective
location of the viewpoint (for the lighting calculations).
• Define the material properties for each object in the scene
with glMaterial*().
void glLight{if}(GLenum light, GLenum pname,
TYPE param);
void glLight{if}v(GLenum light, GLenum pname,
TYPE *param);
create the light specified by GL_LIGHT0, GL_LIGHT1, . . . with
properties given by pname; param specifies the set of param-
eters for the properties pname. The vector version (suffix ‘v’)
is used to specify an array of parameters.
![Page 64: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/64.jpg)
Lighting models in OpenGL
In order to add lighting to a scene, the following steps are
required:
• Define normals at each vertex for every object. (More on
this soon)
• Create and position one or more light sources with glLight*().
(OpenGL supports at least 8 light sources).
• Select a lighting model; with glLightModel*(). This de-
fines the level of (global) ambient light, and the effective
location of the viewpoint (for the lighting calculations).
• Define the material properties for each object in the scene
with glMaterial*().
void glLight{if}(GLenum light, GLenum pname,
TYPE param);
void glLight{if}v(GLenum light, GLenum pname,
TYPE *param);
create the light specified by GL_LIGHT0, GL_LIGHT1, . . . with
properties given by pname; param specifies the set of param-
eters for the properties pname. The vector version (suffix ‘v’)
is used to specify an array of parameters.
6
![Page 65: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/65.jpg)
Parameter name Default Value Meaning
GL_AMBIENT (0.0, 0.0, 0.0, 1.0) ambient color
GL_DIFFUSE (1.0, 1.0, 1.0, 1.0) diffuse color
GL_SPECULAR (1.0, 1.0, 1.0, 1.0) specular color
GL_POSITION (0.0, 0.0, 1.0, 0.0) (x, y, z, w): po-
sition or direc-
tion
GL_CONSTANT_ATTENUATION 1.0 see equation
following
GL_LINEAR_ATTENUATION 0.0
GL_QUADRATIC_ATTENUATION 0.0
![Page 66: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/66.jpg)
Parameter name Default Value Meaning
GL_AMBIENT (0.0, 0.0, 0.0, 1.0) ambient color
GL_DIFFUSE (1.0, 1.0, 1.0, 1.0) diffuse color
GL_SPECULAR (1.0, 1.0, 1.0, 1.0) specular color
GL_POSITION (0.0, 0.0, 1.0, 0.0) (x, y, z, w): po-
sition or direc-
tion
GL_CONSTANT_ATTENUATION 1.0 see equation
following
GL_LINEAR_ATTENUATION 0.0
GL_QUADRATIC_ATTENUATION 0.0
There are also other parameters which restrict a light to be a
spotlight.
![Page 67: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/67.jpg)
Parameter name Default Value Meaning
GL_AMBIENT (0.0, 0.0, 0.0, 1.0) ambient color
GL_DIFFUSE (1.0, 1.0, 1.0, 1.0) diffuse color
GL_SPECULAR (1.0, 1.0, 1.0, 1.0) specular color
GL_POSITION (0.0, 0.0, 1.0, 0.0) (x, y, z, w): po-
sition or direc-
tion
GL_CONSTANT_ATTENUATION 1.0 see equation
following
GL_LINEAR_ATTENUATION 0.0
GL_QUADRATIC_ATTENUATION 0.0
There are also other parameters which restrict a light to be a
spotlight.
Light color: GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR
![Page 68: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/68.jpg)
Parameter name Default Value Meaning
GL_AMBIENT (0.0, 0.0, 0.0, 1.0) ambient color
GL_DIFFUSE (1.0, 1.0, 1.0, 1.0) diffuse color
GL_SPECULAR (1.0, 1.0, 1.0, 1.0) specular color
GL_POSITION (0.0, 0.0, 1.0, 0.0) (x, y, z, w): po-
sition or direc-
tion
GL_CONSTANT_ATTENUATION 1.0 see equation
following
GL_LINEAR_ATTENUATION 0.0
GL_QUADRATIC_ATTENUATION 0.0
There are also other parameters which restrict a light to be a
spotlight.
Light color: GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR
These four-dimensional quantities specify the colors of the am-
bient, diffuse, and specular light emitted from a light source.
![Page 69: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/69.jpg)
Parameter name Default Value Meaning
GL_AMBIENT (0.0, 0.0, 0.0, 1.0) ambient color
GL_DIFFUSE (1.0, 1.0, 1.0, 1.0) diffuse color
GL_SPECULAR (1.0, 1.0, 1.0, 1.0) specular color
GL_POSITION (0.0, 0.0, 1.0, 0.0) (x, y, z, w): po-
sition or direc-
tion
GL_CONSTANT_ATTENUATION 1.0 see equation
following
GL_LINEAR_ATTENUATION 0.0
GL_QUADRATIC_ATTENUATION 0.0
There are also other parameters which restrict a light to be a
spotlight.
Light color: GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR
These four-dimensional quantities specify the colors of the am-
bient, diffuse, and specular light emitted from a light source.
The default values for GL_DIFFUSE and GL_SPECULAR are for
GL_LIGHT0 only.
![Page 70: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/70.jpg)
Parameter name Default Value Meaning
GL_AMBIENT (0.0, 0.0, 0.0, 1.0) ambient color
GL_DIFFUSE (1.0, 1.0, 1.0, 1.0) diffuse color
GL_SPECULAR (1.0, 1.0, 1.0, 1.0) specular color
GL_POSITION (0.0, 0.0, 1.0, 0.0) (x, y, z, w): po-
sition or direc-
tion
GL_CONSTANT_ATTENUATION 1.0 see equation
following
GL_LINEAR_ATTENUATION 0.0
GL_QUADRATIC_ATTENUATION 0.0
There are also other parameters which restrict a light to be a
spotlight.
Light color: GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR
These four-dimensional quantities specify the colors of the am-
bient, diffuse, and specular light emitted from a light source.
The default values for GL_DIFFUSE and GL_SPECULAR are for
GL_LIGHT0 only. Other lights default to black (0.0, 0.0, 0.0, 1.0).
![Page 71: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/71.jpg)
Parameter name Default Value Meaning
GL_AMBIENT (0.0, 0.0, 0.0, 1.0) ambient color
GL_DIFFUSE (1.0, 1.0, 1.0, 1.0) diffuse color
GL_SPECULAR (1.0, 1.0, 1.0, 1.0) specular color
GL_POSITION (0.0, 0.0, 1.0, 0.0) (x, y, z, w): po-
sition or direc-
tion
GL_CONSTANT_ATTENUATION 1.0 see equation
following
GL_LINEAR_ATTENUATION 0.0
GL_QUADRATIC_ATTENUATION 0.0
There are also other parameters which restrict a light to be a
spotlight.
Light color: GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR
These four-dimensional quantities specify the colors of the am-
bient, diffuse, and specular light emitted from a light source.
The default values for GL_DIFFUSE and GL_SPECULAR are for
GL_LIGHT0 only. Other lights default to black (0.0, 0.0, 0.0, 1.0).
Light position: GL_POSITION
![Page 72: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/72.jpg)
Parameter name Default Value Meaning
GL_AMBIENT (0.0, 0.0, 0.0, 1.0) ambient color
GL_DIFFUSE (1.0, 1.0, 1.0, 1.0) diffuse color
GL_SPECULAR (1.0, 1.0, 1.0, 1.0) specular color
GL_POSITION (0.0, 0.0, 1.0, 0.0) (x, y, z, w): po-
sition or direc-
tion
GL_CONSTANT_ATTENUATION 1.0 see equation
following
GL_LINEAR_ATTENUATION 0.0
GL_QUADRATIC_ATTENUATION 0.0
There are also other parameters which restrict a light to be a
spotlight.
Light color: GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR
These four-dimensional quantities specify the colors of the am-
bient, diffuse, and specular light emitted from a light source.
The default values for GL_DIFFUSE and GL_SPECULAR are for
GL_LIGHT0 only. Other lights default to black (0.0, 0.0, 0.0, 1.0).
Light position: GL_POSITION
The fourth value specified for GL_POSITION controls whether
the light is directional or positional.
![Page 73: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/73.jpg)
Parameter name Default Value Meaning
GL_AMBIENT (0.0, 0.0, 0.0, 1.0) ambient color
GL_DIFFUSE (1.0, 1.0, 1.0, 1.0) diffuse color
GL_SPECULAR (1.0, 1.0, 1.0, 1.0) specular color
GL_POSITION (0.0, 0.0, 1.0, 0.0) (x, y, z, w): po-
sition or direc-
tion
GL_CONSTANT_ATTENUATION 1.0 see equation
following
GL_LINEAR_ATTENUATION 0.0
GL_QUADRATIC_ATTENUATION 0.0
There are also other parameters which restrict a light to be a
spotlight.
Light color: GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR
These four-dimensional quantities specify the colors of the am-
bient, diffuse, and specular light emitted from a light source.
The default values for GL_DIFFUSE and GL_SPECULAR are for
GL_LIGHT0 only. Other lights default to black (0.0, 0.0, 0.0, 1.0).
Light position: GL_POSITION
The fourth value specified for GL_POSITION controls whether
the light is directional or positional. A directional light is in-
finitely far away, such that the rays of light it emanates are
7
![Page 74: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/74.jpg)
parallel (e.g. like the rays of light from the sun striking a small
area on Earth).
![Page 75: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/75.jpg)
parallel (e.g. like the rays of light from the sun striking a small
area on Earth). If the w value is zero, the light is considered
directional and the (x, y, z) values describe the direction of the
light.
![Page 76: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/76.jpg)
parallel (e.g. like the rays of light from the sun striking a small
area on Earth). If the w value is zero, the light is considered
directional and the (x, y, z) values describe the direction of the
light.
If the w−value is non-zero the light is positional.
![Page 77: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/77.jpg)
parallel (e.g. like the rays of light from the sun striking a small
area on Earth). If the w value is zero, the light is considered
directional and the (x, y, z) values describe the direction of the
light.
If the w−value is non-zero the light is positional. The (x, y, z)
values specify the location of the light which radiates in all
directions.
![Page 78: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/78.jpg)
parallel (e.g. like the rays of light from the sun striking a small
area on Earth). If the w value is zero, the light is considered
directional and the (x, y, z) values describe the direction of the
light.
If the w−value is non-zero the light is positional. The (x, y, z)
values specify the location of the light which radiates in all
directions.
The direction of a directional light and the position of a posi-
tional light are both transformed by the MODELVIEW matrix.
![Page 79: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/79.jpg)
parallel (e.g. like the rays of light from the sun striking a small
area on Earth). If the w value is zero, the light is considered
directional and the (x, y, z) values describe the direction of the
light.
If the w−value is non-zero the light is positional. The (x, y, z)
values specify the location of the light which radiates in all
directions.
The direction of a directional light and the position of a posi-
tional light are both transformed by the MODELVIEW matrix.
The PROJECTION matrix has no effect on a light source.
![Page 80: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/80.jpg)
parallel (e.g. like the rays of light from the sun striking a small
area on Earth). If the w value is zero, the light is considered
directional and the (x, y, z) values describe the direction of the
light.
If the w−value is non-zero the light is positional. The (x, y, z)
values specify the location of the light which radiates in all
directions.
The direction of a directional light and the position of a posi-
tional light are both transformed by the MODELVIEW matrix.
The PROJECTION matrix has no effect on a light source.
The tutorial lightposition shows a simple use of lighting and
the interaction with viewing position.
![Page 81: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/81.jpg)
parallel (e.g. like the rays of light from the sun striking a small
area on Earth). If the w value is zero, the light is considered
directional and the (x, y, z) values describe the direction of the
light.
If the w−value is non-zero the light is positional. The (x, y, z)
values specify the location of the light which radiates in all
directions.
The direction of a directional light and the position of a posi-
tional light are both transformed by the MODELVIEW matrix.
The PROJECTION matrix has no effect on a light source.
The tutorial lightposition shows a simple use of lighting and
the interaction with viewing position.
Light attenuation: GL_CONSTANT_ATTENUATION, GL_LINEAR_ATTENUATION,
GL_QUADRATIC_ATTENUATION
![Page 82: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/82.jpg)
parallel (e.g. like the rays of light from the sun striking a small
area on Earth). If the w value is zero, the light is considered
directional and the (x, y, z) values describe the direction of the
light.
If the w−value is non-zero the light is positional. The (x, y, z)
values specify the location of the light which radiates in all
directions.
The direction of a directional light and the position of a posi-
tional light are both transformed by the MODELVIEW matrix.
The PROJECTION matrix has no effect on a light source.
The tutorial lightposition shows a simple use of lighting and
the interaction with viewing position.
Light attenuation: GL_CONSTANT_ATTENUATION, GL_LINEAR_ATTENUATION,
GL_QUADRATIC_ATTENUATION
As mentioned, light has the property that it reduces in intensity
with distance.
![Page 83: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/83.jpg)
parallel (e.g. like the rays of light from the sun striking a small
area on Earth). If the w value is zero, the light is considered
directional and the (x, y, z) values describe the direction of the
light.
If the w−value is non-zero the light is positional. The (x, y, z)
values specify the location of the light which radiates in all
directions.
The direction of a directional light and the position of a posi-
tional light are both transformed by the MODELVIEW matrix.
The PROJECTION matrix has no effect on a light source.
The tutorial lightposition shows a simple use of lighting and
the interaction with viewing position.
Light attenuation: GL_CONSTANT_ATTENUATION, GL_LINEAR_ATTENUATION,
GL_QUADRATIC_ATTENUATION
As mentioned, light has the property that it reduces in intensity
with distance. That is, it attenuates.
![Page 84: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/84.jpg)
parallel (e.g. like the rays of light from the sun striking a small
area on Earth). If the w value is zero, the light is considered
directional and the (x, y, z) values describe the direction of the
light.
If the w−value is non-zero the light is positional. The (x, y, z)
values specify the location of the light which radiates in all
directions.
The direction of a directional light and the position of a posi-
tional light are both transformed by the MODELVIEW matrix.
The PROJECTION matrix has no effect on a light source.
The tutorial lightposition shows a simple use of lighting and
the interaction with viewing position.
Light attenuation: GL_CONSTANT_ATTENUATION, GL_LINEAR_ATTENUATION,
GL_QUADRATIC_ATTENUATION
As mentioned, light has the property that it reduces in intensity
with distance. That is, it attenuates.
The attenuation is calculated from the expression
![Page 85: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/85.jpg)
parallel (e.g. like the rays of light from the sun striking a small
area on Earth). If the w value is zero, the light is considered
directional and the (x, y, z) values describe the direction of the
light.
If the w−value is non-zero the light is positional. The (x, y, z)
values specify the location of the light which radiates in all
directions.
The direction of a directional light and the position of a posi-
tional light are both transformed by the MODELVIEW matrix.
The PROJECTION matrix has no effect on a light source.
The tutorial lightposition shows a simple use of lighting and
the interaction with viewing position.
Light attenuation: GL_CONSTANT_ATTENUATION, GL_LINEAR_ATTENUATION,
GL_QUADRATIC_ATTENUATION
As mentioned, light has the property that it reduces in intensity
with distance. That is, it attenuates.
The attenuation is calculated from the expression
attenuation factor =1
kc + kld + kqd2
![Page 86: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/86.jpg)
parallel (e.g. like the rays of light from the sun striking a small
area on Earth). If the w value is zero, the light is considered
directional and the (x, y, z) values describe the direction of the
light.
If the w−value is non-zero the light is positional. The (x, y, z)
values specify the location of the light which radiates in all
directions.
The direction of a directional light and the position of a posi-
tional light are both transformed by the MODELVIEW matrix.
The PROJECTION matrix has no effect on a light source.
The tutorial lightposition shows a simple use of lighting and
the interaction with viewing position.
Light attenuation: GL_CONSTANT_ATTENUATION, GL_LINEAR_ATTENUATION,
GL_QUADRATIC_ATTENUATION
As mentioned, light has the property that it reduces in intensity
with distance. That is, it attenuates.
The attenuation is calculated from the expression
attenuation factor =1
kc + kld + kqd2
where d is the distance from the light source, and kc, kl, and kq
are the constant, linear, and quadratic attenuation terms.
![Page 87: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/87.jpg)
parallel (e.g. like the rays of light from the sun striking a small
area on Earth). If the w value is zero, the light is considered
directional and the (x, y, z) values describe the direction of the
light.
If the w−value is non-zero the light is positional. The (x, y, z)
values specify the location of the light which radiates in all
directions.
The direction of a directional light and the position of a posi-
tional light are both transformed by the MODELVIEW matrix.
The PROJECTION matrix has no effect on a light source.
The tutorial lightposition shows a simple use of lighting and
the interaction with viewing position.
Light attenuation: GL_CONSTANT_ATTENUATION, GL_LINEAR_ATTENUATION,
GL_QUADRATIC_ATTENUATION
As mentioned, light has the property that it reduces in intensity
with distance. That is, it attenuates.
The attenuation is calculated from the expression
attenuation factor =1
kc + kld + kqd2
where d is the distance from the light source, and kc, kl, and kq
are the constant, linear, and quadratic attenuation terms.
8
![Page 88: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/88.jpg)
First example
![Page 89: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/89.jpg)
First example
The following simple program light.c shows a lighted sphere:
![Page 90: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/90.jpg)
First example
The following simple program light.c shows a lighted sphere:
/* Initialize material property, light source,
* lighting model, and depth buffer. */
void init(void)
{
![Page 91: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/91.jpg)
First example
The following simple program light.c shows a lighted sphere:
/* Initialize material property, light source,
* lighting model, and depth buffer. */
void init(void)
{GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat mat_shininess[] = { 50.0 };
GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 };
GLfloat white_light_[] = { 1.0, 1.0, 1.0, 0.0 };
![Page 92: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/92.jpg)
First example
The following simple program light.c shows a lighted sphere:
/* Initialize material property, light source,
* lighting model, and depth buffer. */
void init(void)
{GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat mat_shininess[] = { 50.0 };
GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 };
GLfloat white_light_[] = { 1.0, 1.0, 1.0, 0.0 };
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_SMOOTH);
![Page 93: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/93.jpg)
First example
The following simple program light.c shows a lighted sphere:
/* Initialize material property, light source,
* lighting model, and depth buffer. */
void init(void)
{GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat mat_shininess[] = { 50.0 };
GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 };
GLfloat white_light_[] = { 1.0, 1.0, 1.0, 0.0 };
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_SMOOTH);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
![Page 94: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/94.jpg)
First example
The following simple program light.c shows a lighted sphere:
/* Initialize material property, light source,
* lighting model, and depth buffer. */
void init(void)
{GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat mat_shininess[] = { 50.0 };
GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 };
GLfloat white_light_[] = { 1.0, 1.0, 1.0, 0.0 };
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_SMOOTH);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightfv(GL_LIGHT0, GL_DIFFUSE, white_light);
glLightfv(GL_LIGHT0, GL_SPECULAR, white_light);
![Page 95: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/95.jpg)
First example
The following simple program light.c shows a lighted sphere:
/* Initialize material property, light source,
* lighting model, and depth buffer. */
void init(void)
{GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat mat_shininess[] = { 50.0 };
GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 };
GLfloat white_light_[] = { 1.0, 1.0, 1.0, 0.0 };
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_SMOOTH);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightfv(GL_LIGHT0, GL_DIFFUSE, white_light);
glLightfv(GL_LIGHT0, GL_SPECULAR, white_light);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
}
9
![Page 96: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/96.jpg)
void display(void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSolidSphere (1.0, 20, 16);
glFlush ();
}
![Page 97: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/97.jpg)
void display(void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSolidSphere (1.0, 20, 16);
glFlush ();
}
Second example
![Page 98: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/98.jpg)
void display(void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSolidSphere (1.0, 20, 16);
glFlush ();
}
Second example
This example, movelight.c, illustrates how the position of a
light is transformed by the MODELVIEW matrix:
![Page 99: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/99.jpg)
void display(void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSolidSphere (1.0, 20, 16);
glFlush ();
}
Second example
This example, movelight.c, illustrates how the position of a
light is transformed by the MODELVIEW matrix:
void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_SMOOTH);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
}
![Page 100: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/100.jpg)
void display(void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSolidSphere (1.0, 20, 16);
glFlush ();
}
Second example
This example, movelight.c, illustrates how the position of a
light is transformed by the MODELVIEW matrix:
void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_SMOOTH);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
}
10
![Page 101: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/101.jpg)
void display(void)
{
GLfloat position[] = { 0.0, 0.0, 1.5, 1.0 };
![Page 102: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/102.jpg)
void display(void)
{
GLfloat position[] = { 0.0, 0.0, 1.5, 1.0 };
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix ();
![Page 103: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/103.jpg)
void display(void)
{
GLfloat position[] = { 0.0, 0.0, 1.5, 1.0 };
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix ();
glPushMatrix ();
glRotated ((GLdouble) spin, 1.0, 0.0, 0.0);
glLightfv (GL_LIGHT0, GL_POSITION, position);
glTranslated (0.0, 0.0, 1.5);
![Page 104: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/104.jpg)
void display(void)
{
GLfloat position[] = { 0.0, 0.0, 1.5, 1.0 };
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix ();
glPushMatrix ();
glRotated ((GLdouble) spin, 1.0, 0.0, 0.0);
glLightfv (GL_LIGHT0, GL_POSITION, position);
glTranslated (0.0, 0.0, 1.5);
glDisable (GL_LIGHTING); /* Draw an unlit wire cube at */
glColor3f (0.0, 1.0, 1.0); /* the position of the light. */
glutWireCube (0.1);
glEnable (GL_LIGHTING);
glPopMatrix ();
![Page 105: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/105.jpg)
void display(void)
{
GLfloat position[] = { 0.0, 0.0, 1.5, 1.0 };
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix ();
glPushMatrix ();
glRotated ((GLdouble) spin, 1.0, 0.0, 0.0);
glLightfv (GL_LIGHT0, GL_POSITION, position);
glTranslated (0.0, 0.0, 1.5);
glDisable (GL_LIGHTING); /* Draw an unlit wire cube at */
glColor3f (0.0, 1.0, 1.0); /* the position of the light. */
glutWireCube (0.1);
glEnable (GL_LIGHTING);
glPopMatrix ();
![Page 106: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/106.jpg)
void display(void)
{
GLfloat position[] = { 0.0, 0.0, 1.5, 1.0 };
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix ();
glPushMatrix ();
glRotated ((GLdouble) spin, 1.0, 0.0, 0.0);
glLightfv (GL_LIGHT0, GL_POSITION, position);
glTranslated (0.0, 0.0, 1.5);
glDisable (GL_LIGHTING); /* Draw an unlit wire cube at */
glColor3f (0.0, 1.0, 1.0); /* the position of the light. */
glutWireCube (0.1);
glEnable (GL_LIGHTING);
glPopMatrix ();
glutSolidTorus (0.275, 0.85, 8, 15);
![Page 107: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/107.jpg)
void display(void)
{
GLfloat position[] = { 0.0, 0.0, 1.5, 1.0 };
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix ();
glPushMatrix ();
glRotated ((GLdouble) spin, 1.0, 0.0, 0.0);
glLightfv (GL_LIGHT0, GL_POSITION, position);
glTranslated (0.0, 0.0, 1.5);
glDisable (GL_LIGHTING); /* Draw an unlit wire cube at */
glColor3f (0.0, 1.0, 1.0); /* the position of the light. */
glutWireCube (0.1);
glEnable (GL_LIGHTING);
glPopMatrix ();
glutSolidTorus (0.275, 0.85, 8, 15);
glPopMatrix ();
glFlush ();
}
![Page 108: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/108.jpg)
void display(void)
{
GLfloat position[] = { 0.0, 0.0, 1.5, 1.0 };
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix ();
glPushMatrix ();
glRotated ((GLdouble) spin, 1.0, 0.0, 0.0);
glLightfv (GL_LIGHT0, GL_POSITION, position);
glTranslated (0.0, 0.0, 1.5);
glDisable (GL_LIGHTING); /* Draw an unlit wire cube at */
glColor3f (0.0, 1.0, 1.0); /* the position of the light. */
glutWireCube (0.1);
glEnable (GL_LIGHTING);
glPopMatrix ();
glutSolidTorus (0.275, 0.85, 8, 15);
glPopMatrix ();
glFlush ();
}
11
![Page 109: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/109.jpg)
void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
gluPerspective(40.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
}
![Page 110: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/110.jpg)
void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
gluPerspective(40.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
}
void mouse(int button, int state, int x, int y) {
switch (button) {
case GLUT_LEFT_BUTTON:
if (state == GLUT_DOWN) {
spin = (spin + 30) % 360;
glutPostRedisplay();
}
break;
default:
break;
}
}
12
![Page 111: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/111.jpg)
void keyboard(unsigned char key, int x, int y) {
switch (key) {
case 27:
exit(0);
break;
}
}
![Page 112: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/112.jpg)
void keyboard(unsigned char key, int x, int y) {
switch (key) {
case 27:
exit(0);
break;
}
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
glutCreateWindow (argv[0]);
init ();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMouseFunc(mouse);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
}
13
![Page 113: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/113.jpg)
Material properties
![Page 114: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/114.jpg)
Material properties
The colors of light reflected by a primitive are set with the
function glMaterial*().
![Page 115: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/115.jpg)
Material properties
The colors of light reflected by a primitive are set with the
function glMaterial*(). It has the form:
![Page 116: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/116.jpg)
Material properties
The colors of light reflected by a primitive are set with the
function glMaterial*(). It has the form:
void glMaterial{if}(GLenum face, GLenum pname, TYPE
param);
![Page 117: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/117.jpg)
Material properties
The colors of light reflected by a primitive are set with the
function glMaterial*(). It has the form:
void glMaterial{if}(GLenum face, GLenum pname, TYPE
param);
void glMaterial{if}v(GLenum face, GLenum pname, TYPE
*param);
![Page 118: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/118.jpg)
Material properties
The colors of light reflected by a primitive are set with the
function glMaterial*(). It has the form:
void glMaterial{if}(GLenum face, GLenum pname, TYPE
param);
void glMaterial{if}v(GLenum face, GLenum pname, TYPE
*param);
where face can be GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK,
and pname and param are defined in the following table:
![Page 119: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/119.jpg)
Material properties
The colors of light reflected by a primitive are set with the
function glMaterial*(). It has the form:
void glMaterial{if}(GLenum face, GLenum pname, TYPE
param);
void glMaterial{if}v(GLenum face, GLenum pname, TYPE
*param);
where face can be GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK,
and pname and param are defined in the following table:
Parameter name Default Value Meaning
GL_AMBIENT (0.2, 0.2, 0.2, 1.0) ambient color of material
GL_DIFFUSE (0.8, 0.8, 0.8, 1.0) diffuse color of material
GL_SPECULAR (0.0, 0.0, 0.0, 1.0) specular color of material
GL_EMISSION (0.0, 0.0, 0.0, 1.0) emissive color of material
GL_SHININESS 0.0 specular exponent
![Page 120: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/120.jpg)
Material properties
The colors of light reflected by a primitive are set with the
function glMaterial*(). It has the form:
void glMaterial{if}(GLenum face, GLenum pname, TYPE
param);
void glMaterial{if}v(GLenum face, GLenum pname, TYPE
*param);
where face can be GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK,
and pname and param are defined in the following table:
Parameter name Default Value Meaning
GL_AMBIENT (0.2, 0.2, 0.2, 1.0) ambient color of material
GL_DIFFUSE (0.8, 0.8, 0.8, 1.0) diffuse color of material
GL_SPECULAR (0.0, 0.0, 0.0, 1.0) specular color of material
GL_EMISSION (0.0, 0.0, 0.0, 1.0) emissive color of material
GL_SHININESS 0.0 specular exponent
The parameter GL_EMISSION allows a body to emit light (for
modelling lamps, etc.).
![Page 121: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/121.jpg)
Material properties
The colors of light reflected by a primitive are set with the
function glMaterial*(). It has the form:
void glMaterial{if}(GLenum face, GLenum pname, TYPE
param);
void glMaterial{if}v(GLenum face, GLenum pname, TYPE
*param);
where face can be GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK,
and pname and param are defined in the following table:
Parameter name Default Value Meaning
GL_AMBIENT (0.2, 0.2, 0.2, 1.0) ambient color of material
GL_DIFFUSE (0.8, 0.8, 0.8, 1.0) diffuse color of material
GL_SPECULAR (0.0, 0.0, 0.0, 1.0) specular color of material
GL_EMISSION (0.0, 0.0, 0.0, 1.0) emissive color of material
GL_SHININESS 0.0 specular exponent
The parameter GL_EMISSION allows a body to emit light (for
modelling lamps, etc.). Light from this source does not illumi-
nate any other part of the scene.
![Page 122: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/122.jpg)
Material properties
The colors of light reflected by a primitive are set with the
function glMaterial*(). It has the form:
void glMaterial{if}(GLenum face, GLenum pname, TYPE
param);
void glMaterial{if}v(GLenum face, GLenum pname, TYPE
*param);
where face can be GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK,
and pname and param are defined in the following table:
Parameter name Default Value Meaning
GL_AMBIENT (0.2, 0.2, 0.2, 1.0) ambient color of material
GL_DIFFUSE (0.8, 0.8, 0.8, 1.0) diffuse color of material
GL_SPECULAR (0.0, 0.0, 0.0, 1.0) specular color of material
GL_EMISSION (0.0, 0.0, 0.0, 1.0) emissive color of material
GL_SHININESS 0.0 specular exponent
The parameter GL_EMISSION allows a body to emit light (for
modelling lamps, etc.). Light from this source does not illumi-
nate any other part of the scene.
The tutorial lightmaterial shows interaction between light
sources and material properties.
![Page 123: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/123.jpg)
Material properties
The colors of light reflected by a primitive are set with the
function glMaterial*(). It has the form:
void glMaterial{if}(GLenum face, GLenum pname, TYPE
param);
void glMaterial{if}v(GLenum face, GLenum pname, TYPE
*param);
where face can be GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK,
and pname and param are defined in the following table:
Parameter name Default Value Meaning
GL_AMBIENT (0.2, 0.2, 0.2, 1.0) ambient color of material
GL_DIFFUSE (0.8, 0.8, 0.8, 1.0) diffuse color of material
GL_SPECULAR (0.0, 0.0, 0.0, 1.0) specular color of material
GL_EMISSION (0.0, 0.0, 0.0, 1.0) emissive color of material
GL_SHININESS 0.0 specular exponent
The parameter GL_EMISSION allows a body to emit light (for
modelling lamps, etc.). Light from this source does not illumi-
nate any other part of the scene.
The tutorial lightmaterial shows interaction between light
sources and material properties.
14
![Page 124: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/124.jpg)
The lighting model
![Page 125: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/125.jpg)
The lighting model
The OpenGL lighting model has four components:
![Page 126: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/126.jpg)
The lighting model
The OpenGL lighting model has four components:
1. The global ambient light intensity
![Page 127: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/127.jpg)
The lighting model
The OpenGL lighting model has four components:
1. The global ambient light intensity
2. The viewpoint position (local or at infinity)
![Page 128: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/128.jpg)
The lighting model
The OpenGL lighting model has four components:
1. The global ambient light intensity
2. The viewpoint position (local or at infinity)
3. Whether front and back surfaces should have different light-
ing calculations
![Page 129: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/129.jpg)
The lighting model
The OpenGL lighting model has four components:
1. The global ambient light intensity
2. The viewpoint position (local or at infinity)
3. Whether front and back surfaces should have different light-
ing calculations
4. Whether or not the specular color should be separated from
ambient and diffuse colors and applied after texturing.
![Page 130: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/130.jpg)
The lighting model
The OpenGL lighting model has four components:
1. The global ambient light intensity
2. The viewpoint position (local or at infinity)
3. Whether front and back surfaces should have different light-
ing calculations
4. Whether or not the specular color should be separated from
ambient and diffuse colors and applied after texturing.
All those properties can be set individually with the function
glLightModel*().
![Page 131: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/131.jpg)
The lighting model
The OpenGL lighting model has four components:
1. The global ambient light intensity
2. The viewpoint position (local or at infinity)
3. Whether front and back surfaces should have different light-
ing calculations
4. Whether or not the specular color should be separated from
ambient and diffuse colors and applied after texturing.
All those properties can be set individually with the function
glLightModel*().
void glLightModel{if}(GLenum pname, TYPE param);
![Page 132: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/132.jpg)
The lighting model
The OpenGL lighting model has four components:
1. The global ambient light intensity
2. The viewpoint position (local or at infinity)
3. Whether front and back surfaces should have different light-
ing calculations
4. Whether or not the specular color should be separated from
ambient and diffuse colors and applied after texturing.
All those properties can be set individually with the function
glLightModel*().
void glLightModel{if}(GLenum pname, TYPE param);
void glLightModel{if}v(GLenum pname, TYPE *param);
![Page 133: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/133.jpg)
The lighting model
The OpenGL lighting model has four components:
1. The global ambient light intensity
2. The viewpoint position (local or at infinity)
3. Whether front and back surfaces should have different light-
ing calculations
4. Whether or not the specular color should be separated from
ambient and diffuse colors and applied after texturing.
All those properties can be set individually with the function
glLightModel*().
void glLightModel{if}(GLenum pname, TYPE param);
void glLightModel{if}v(GLenum pname, TYPE *param);
Again, pname specifies the property; param specifies the set of
parameters for the property pname.
![Page 134: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/134.jpg)
The lighting model
The OpenGL lighting model has four components:
1. The global ambient light intensity
2. The viewpoint position (local or at infinity)
3. Whether front and back surfaces should have different light-
ing calculations
4. Whether or not the specular color should be separated from
ambient and diffuse colors and applied after texturing.
All those properties can be set individually with the function
glLightModel*().
void glLightModel{if}(GLenum pname, TYPE param);
void glLightModel{if}v(GLenum pname, TYPE *param);
Again, pname specifies the property; param specifies the set of
parameters for the property pname.
In the following, GL_LIGHT_MODEL precedes the parameter name:
![Page 135: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/135.jpg)
The lighting model
The OpenGL lighting model has four components:
1. The global ambient light intensity
2. The viewpoint position (local or at infinity)
3. Whether front and back surfaces should have different light-
ing calculations
4. Whether or not the specular color should be separated from
ambient and diffuse colors and applied after texturing.
All those properties can be set individually with the function
glLightModel*().
void glLightModel{if}(GLenum pname, TYPE param);
void glLightModel{if}v(GLenum pname, TYPE *param);
Again, pname specifies the property; param specifies the set of
parameters for the property pname.
In the following, GL_LIGHT_MODEL precedes the parameter name:
15
![Page 136: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/136.jpg)
Parameter name Default Value Meaning
_AMBIENT (0.2, 0.2, 0.2, 1.0) ambient intensity for
scene
_LOCAL_VIEWER 0.0 how specular reflec-
tion angles are calcu-
lated
_TWO_SIDE 0.0 one sides or two sided
lighting
_COLOR_CONTROL GL_SINGLE_COLOR whether specular
color is calculated
separately
![Page 137: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/137.jpg)
Parameter name Default Value Meaning
_AMBIENT (0.2, 0.2, 0.2, 1.0) ambient intensity for
scene
_LOCAL_VIEWER 0.0 how specular reflec-
tion angles are calcu-
lated
_TWO_SIDE 0.0 one sides or two sided
lighting
_COLOR_CONTROL GL_SINGLE_COLOR whether specular
color is calculated
separately
16
![Page 138: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/138.jpg)
How a vertex’s color is calculated in OpenGL
![Page 139: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/139.jpg)
How a vertex’s color is calculated in OpenGL
The color of a vertex under lighting in OpenGL is:
![Page 140: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/140.jpg)
How a vertex’s color is calculated in OpenGL
The color of a vertex under lighting in OpenGL is:
color = emission at the vertex +
![Page 141: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/141.jpg)
How a vertex’s color is calculated in OpenGL
The color of a vertex under lighting in OpenGL is:
color = emission at the vertex +
global ambient light scaled by the ambient co-
efficient of the material +
![Page 142: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/142.jpg)
How a vertex’s color is calculated in OpenGL
The color of a vertex under lighting in OpenGL is:
color = emission at the vertex +
global ambient light scaled by the ambient co-
efficient of the material +
the ambient, diffuse, and specular components
from all light sources, properly attenuated
![Page 143: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/143.jpg)
How a vertex’s color is calculated in OpenGL
The color of a vertex under lighting in OpenGL is:
color = emission at the vertex +
global ambient light scaled by the ambient co-
efficient of the material +
the ambient, diffuse, and specular components
from all light sources, properly attenuated
The contribution from individual light sources is calculated as
follows:
![Page 144: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/144.jpg)
How a vertex’s color is calculated in OpenGL
The color of a vertex under lighting in OpenGL is:
color = emission at the vertex +
global ambient light scaled by the ambient co-
efficient of the material +
the ambient, diffuse, and specular components
from all light sources, properly attenuated
The contribution from individual light sources is calculated as
follows:
color = emissionmaterial+
![Page 145: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/145.jpg)
How a vertex’s color is calculated in OpenGL
The color of a vertex under lighting in OpenGL is:
color = emission at the vertex +
global ambient light scaled by the ambient co-
efficient of the material +
the ambient, diffuse, and specular components
from all light sources, properly attenuated
The contribution from individual light sources is calculated as
follows:
color = emissionmaterial+
ambientlight model ∗ ambientmaterial +
![Page 146: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/146.jpg)
How a vertex’s color is calculated in OpenGL
The color of a vertex under lighting in OpenGL is:
color = emission at the vertex +
global ambient light scaled by the ambient co-
efficient of the material +
the ambient, diffuse, and specular components
from all light sources, properly attenuated
The contribution from individual light sources is calculated as
follows:
color = emissionmaterial+
ambientlight model ∗ ambientmaterial +∑n−1i=0
(1
kc+kld+kqd2
)∗ (spotlight effect)i ∗
![Page 147: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/147.jpg)
How a vertex’s color is calculated in OpenGL
The color of a vertex under lighting in OpenGL is:
color = emission at the vertex +
global ambient light scaled by the ambient co-
efficient of the material +
the ambient, diffuse, and specular components
from all light sources, properly attenuated
The contribution from individual light sources is calculated as
follows:
color = emissionmaterial+
ambientlight model ∗ ambientmaterial +∑n−1i=0
(1
kc+kld+kqd2
)∗ (spotlight effect)i ∗
[ambientlight ∗ ambientmaterial +
![Page 148: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/148.jpg)
How a vertex’s color is calculated in OpenGL
The color of a vertex under lighting in OpenGL is:
color = emission at the vertex +
global ambient light scaled by the ambient co-
efficient of the material +
the ambient, diffuse, and specular components
from all light sources, properly attenuated
The contribution from individual light sources is calculated as
follows:
color = emissionmaterial+
ambientlight model ∗ ambientmaterial +∑n−1i=0
(1
kc+kld+kqd2
)∗ (spotlight effect)i ∗
[ambientlight ∗ ambientmaterial +
(max{Li · n, 0}) ∗ diffuselight ∗ diffusematerial +
![Page 149: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/149.jpg)
How a vertex’s color is calculated in OpenGL
The color of a vertex under lighting in OpenGL is:
color = emission at the vertex +
global ambient light scaled by the ambient co-
efficient of the material +
the ambient, diffuse, and specular components
from all light sources, properly attenuated
The contribution from individual light sources is calculated as
follows:
color = emissionmaterial+
ambientlight model ∗ ambientmaterial +∑n−1i=0
(1
kc+kld+kqd2
)∗ (spotlight effect)i ∗
[ambientlight ∗ ambientmaterial +
(max{Li · n, 0}) ∗ diffuselight ∗ diffusematerial +
specular effect ]i
![Page 150: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/150.jpg)
How a vertex’s color is calculated in OpenGL
The color of a vertex under lighting in OpenGL is:
color = emission at the vertex +
global ambient light scaled by the ambient co-
efficient of the material +
the ambient, diffuse, and specular components
from all light sources, properly attenuated
The contribution from individual light sources is calculated as
follows:
color = emissionmaterial+
ambientlight model ∗ ambientmaterial +∑n−1i=0
(1
kc+kld+kqd2
)∗ (spotlight effect)i ∗
[ambientlight ∗ ambientmaterial +
(max{Li · n, 0}) ∗ diffuselight ∗ diffusematerial +
specular effect ]i
where n = (nx,ny,nz) is the unit normal vector at the vertex
and L = (Lx,Ly,Lz) is the unit vector pointing from the vertex
to the light.
![Page 151: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/151.jpg)
How a vertex’s color is calculated in OpenGL
The color of a vertex under lighting in OpenGL is:
color = emission at the vertex +
global ambient light scaled by the ambient co-
efficient of the material +
the ambient, diffuse, and specular components
from all light sources, properly attenuated
The contribution from individual light sources is calculated as
follows:
color = emissionmaterial+
ambientlight model ∗ ambientmaterial +∑n−1i=0
(1
kc+kld+kqd2
)∗ (spotlight effect)i ∗
[ambientlight ∗ ambientmaterial +
(max{Li · n, 0}) ∗ diffuselight ∗ diffusematerial +
specular effect ]i
where n = (nx,ny,nz) is the unit normal vector at the vertex
and L = (Lx,Ly,Lz) is the unit vector pointing from the vertex
to the light. Thus, the diffuse component is highest when n
and L are parallel.
![Page 152: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/152.jpg)
How a vertex’s color is calculated in OpenGL
The color of a vertex under lighting in OpenGL is:
color = emission at the vertex +
global ambient light scaled by the ambient co-
efficient of the material +
the ambient, diffuse, and specular components
from all light sources, properly attenuated
The contribution from individual light sources is calculated as
follows:
color = emissionmaterial+
ambientlight model ∗ ambientmaterial +∑n−1i=0
(1
kc+kld+kqd2
)∗ (spotlight effect)i ∗
[ambientlight ∗ ambientmaterial +
(max{Li · n, 0}) ∗ diffuselight ∗ diffusematerial +
specular effect ]i
where n = (nx,ny,nz) is the unit normal vector at the vertex
and L = (Lx,Ly,Lz) is the unit vector pointing from the vertex
to the light. Thus, the diffuse component is highest when n
and L are parallel. The calculation for the specular effect is
similar but incorporates also the position of the viewpoint.
![Page 153: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/153.jpg)
How a vertex’s color is calculated in OpenGL
The color of a vertex under lighting in OpenGL is:
color = emission at the vertex +
global ambient light scaled by the ambient co-
efficient of the material +
the ambient, diffuse, and specular components
from all light sources, properly attenuated
The contribution from individual light sources is calculated as
follows:
color = emissionmaterial+
ambientlight model ∗ ambientmaterial +∑n−1i=0
(1
kc+kld+kqd2
)∗ (spotlight effect)i ∗
[ambientlight ∗ ambientmaterial +
(max{Li · n, 0}) ∗ diffuselight ∗ diffusematerial +
specular effect ]i
where n = (nx,ny,nz) is the unit normal vector at the vertex
and L = (Lx,Ly,Lz) is the unit vector pointing from the vertex
to the light. Thus, the diffuse component is highest when n
and L are parallel. The calculation for the specular effect is
similar but incorporates also the position of the viewpoint.
The result is clamped to [0, 1].
![Page 154: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/154.jpg)
How a vertex’s color is calculated in OpenGL
The color of a vertex under lighting in OpenGL is:
color = emission at the vertex +
global ambient light scaled by the ambient co-
efficient of the material +
the ambient, diffuse, and specular components
from all light sources, properly attenuated
The contribution from individual light sources is calculated as
follows:
color = emissionmaterial+
ambientlight model ∗ ambientmaterial +∑n−1i=0
(1
kc+kld+kqd2
)∗ (spotlight effect)i ∗
[ambientlight ∗ ambientmaterial +
(max{Li · n, 0}) ∗ diffuselight ∗ diffusematerial +
specular effect ]i
where n = (nx,ny,nz) is the unit normal vector at the vertex
and L = (Lx,Ly,Lz) is the unit vector pointing from the vertex
to the light. Thus, the diffuse component is highest when n
and L are parallel. The calculation for the specular effect is
similar but incorporates also the position of the viewpoint.
The result is clamped to [0, 1].
17
![Page 155: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/155.jpg)
Shading — what happens between vertices
![Page 156: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/156.jpg)
Shading — what happens between vertices
Clearly, the color and intensity of light at interior points in a
polygon could be calculated similarly.
![Page 157: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/157.jpg)
Shading — what happens between vertices
Clearly, the color and intensity of light at interior points in a
polygon could be calculated similarly. However, this would be
computationally expensive, so other methods are used.
![Page 158: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/158.jpg)
Shading — what happens between vertices
Clearly, the color and intensity of light at interior points in a
polygon could be calculated similarly. However, this would be
computationally expensive, so other methods are used.
As mentioned, OpenGL provides an interpolated shading model
known as Gouraud shading.
![Page 159: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/159.jpg)
Shading — what happens between vertices
Clearly, the color and intensity of light at interior points in a
polygon could be calculated similarly. However, this would be
computationally expensive, so other methods are used.
As mentioned, OpenGL provides an interpolated shading model
known as Gouraud shading. Gouraud shading linearly interpo-
lates the color of an interior pixel from the color at the vertices.
![Page 160: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/160.jpg)
Shading — what happens between vertices
Clearly, the color and intensity of light at interior points in a
polygon could be calculated similarly. However, this would be
computationally expensive, so other methods are used.
As mentioned, OpenGL provides an interpolated shading model
known as Gouraud shading. Gouraud shading linearly interpo-
lates the color of an interior pixel from the color at the vertices.
This interpolation is incorporated directly into the rasterization
algorithm.
![Page 161: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/161.jpg)
Shading — what happens between vertices
Clearly, the color and intensity of light at interior points in a
polygon could be calculated similarly. However, this would be
computationally expensive, so other methods are used.
As mentioned, OpenGL provides an interpolated shading model
known as Gouraud shading. Gouraud shading linearly interpo-
lates the color of an interior pixel from the color at the vertices.
This interpolation is incorporated directly into the rasterization
algorithm.
Another common shading model is Phong shading.
![Page 162: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/162.jpg)
Shading — what happens between vertices
Clearly, the color and intensity of light at interior points in a
polygon could be calculated similarly. However, this would be
computationally expensive, so other methods are used.
As mentioned, OpenGL provides an interpolated shading model
known as Gouraud shading. Gouraud shading linearly interpo-
lates the color of an interior pixel from the color at the vertices.
This interpolation is incorporated directly into the rasterization
algorithm.
Another common shading model is Phong shading. Instead
of interpolating over the intensity, Phong shading interpolates
over the normal vectors specified at the vertices.
![Page 163: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/163.jpg)
Shading — what happens between vertices
Clearly, the color and intensity of light at interior points in a
polygon could be calculated similarly. However, this would be
computationally expensive, so other methods are used.
As mentioned, OpenGL provides an interpolated shading model
known as Gouraud shading. Gouraud shading linearly interpo-
lates the color of an interior pixel from the color at the vertices.
This interpolation is incorporated directly into the rasterization
algorithm.
Another common shading model is Phong shading. Instead
of interpolating over the intensity, Phong shading interpolates
over the normal vectors specified at the vertices. This gener-
ally produces a better specular component, because a better
approximation is used to the normal at each point.
![Page 164: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/164.jpg)
Shading — what happens between vertices
Clearly, the color and intensity of light at interior points in a
polygon could be calculated similarly. However, this would be
computationally expensive, so other methods are used.
As mentioned, OpenGL provides an interpolated shading model
known as Gouraud shading. Gouraud shading linearly interpo-
lates the color of an interior pixel from the color at the vertices.
This interpolation is incorporated directly into the rasterization
algorithm.
Another common shading model is Phong shading. Instead
of interpolating over the intensity, Phong shading interpolates
over the normal vectors specified at the vertices. This gener-
ally produces a better specular component, because a better
approximation is used to the normal at each point. (Gouraud
shading tends to “average out” specular highlights.)
![Page 165: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/165.jpg)
Shading — what happens between vertices
Clearly, the color and intensity of light at interior points in a
polygon could be calculated similarly. However, this would be
computationally expensive, so other methods are used.
As mentioned, OpenGL provides an interpolated shading model
known as Gouraud shading. Gouraud shading linearly interpo-
lates the color of an interior pixel from the color at the vertices.
This interpolation is incorporated directly into the rasterization
algorithm.
Another common shading model is Phong shading. Instead
of interpolating over the intensity, Phong shading interpolates
over the normal vectors specified at the vertices. This gener-
ally produces a better specular component, because a better
approximation is used to the normal at each point. (Gouraud
shading tends to “average out” specular highlights.)
This is computationally expensive, however, because the normal
vector must be both interpolated and normalized for each pixel.
![Page 166: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/166.jpg)
Shading — what happens between vertices
Clearly, the color and intensity of light at interior points in a
polygon could be calculated similarly. However, this would be
computationally expensive, so other methods are used.
As mentioned, OpenGL provides an interpolated shading model
known as Gouraud shading. Gouraud shading linearly interpo-
lates the color of an interior pixel from the color at the vertices.
This interpolation is incorporated directly into the rasterization
algorithm.
Another common shading model is Phong shading. Instead
of interpolating over the intensity, Phong shading interpolates
over the normal vectors specified at the vertices. This gener-
ally produces a better specular component, because a better
approximation is used to the normal at each point. (Gouraud
shading tends to “average out” specular highlights.)
This is computationally expensive, however, because the normal
vector must be both interpolated and normalized for each pixel.
18
![Page 167: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/167.jpg)
Specifying normal vectors
![Page 168: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/168.jpg)
Specifying normal vectors
In the examples above the objects viewed were generated by
calls to glutSolidSphere and glutSolidTorus.
![Page 169: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/169.jpg)
Specifying normal vectors
In the examples above the objects viewed were generated by
calls to glutSolidSphere and glutSolidTorus. These func-
tions generate the appropriate surface normals for these objects.
![Page 170: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/170.jpg)
Specifying normal vectors
In the examples above the objects viewed were generated by
calls to glutSolidSphere and glutSolidTorus. These func-
tions generate the appropriate surface normals for these objects.
However, you often have to specify normal vectors yourself.
![Page 171: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/171.jpg)
Specifying normal vectors
In the examples above the objects viewed were generated by
calls to glutSolidSphere and glutSolidTorus. These func-
tions generate the appropriate surface normals for these objects.
However, you often have to specify normal vectors yourself.
For proper lighting, these normal vectors must have unit length.
![Page 172: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/172.jpg)
Specifying normal vectors
In the examples above the objects viewed were generated by
calls to glutSolidSphere and glutSolidTorus. These func-
tions generate the appropriate surface normals for these objects.
However, you often have to specify normal vectors yourself.
For proper lighting, these normal vectors must have unit length.
Even if you specify unit length normals, their lengths can be
changed by subsequent transformations (scaling and shearing).
![Page 173: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/173.jpg)
Specifying normal vectors
In the examples above the objects viewed were generated by
calls to glutSolidSphere and glutSolidTorus. These func-
tions generate the appropriate surface normals for these objects.
However, you often have to specify normal vectors yourself.
For proper lighting, these normal vectors must have unit length.
Even if you specify unit length normals, their lengths can be
changed by subsequent transformations (scaling and shearing).
Therefore you may have to renormalize them.
![Page 174: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/174.jpg)
Specifying normal vectors
In the examples above the objects viewed were generated by
calls to glutSolidSphere and glutSolidTorus. These func-
tions generate the appropriate surface normals for these objects.
However, you often have to specify normal vectors yourself.
For proper lighting, these normal vectors must have unit length.
Even if you specify unit length normals, their lengths can be
changed by subsequent transformations (scaling and shearing).
Therefore you may have to renormalize them. OpenGL can
do this for you automatically (at some computational expense).
![Page 175: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/175.jpg)
Specifying normal vectors
In the examples above the objects viewed were generated by
calls to glutSolidSphere and glutSolidTorus. These func-
tions generate the appropriate surface normals for these objects.
However, you often have to specify normal vectors yourself.
For proper lighting, these normal vectors must have unit length.
Even if you specify unit length normals, their lengths can be
changed by subsequent transformations (scaling and shearing).
Therefore you may have to renormalize them. OpenGL can
do this for you automatically (at some computational expense).
To set this up call glEnablewith GL_NORMALIZE or GL_RESCALE_NORMAL
as a parameter (see red book for details).
![Page 176: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/176.jpg)
Specifying normal vectors
In the examples above the objects viewed were generated by
calls to glutSolidSphere and glutSolidTorus. These func-
tions generate the appropriate surface normals for these objects.
However, you often have to specify normal vectors yourself.
For proper lighting, these normal vectors must have unit length.
Even if you specify unit length normals, their lengths can be
changed by subsequent transformations (scaling and shearing).
Therefore you may have to renormalize them. OpenGL can
do this for you automatically (at some computational expense).
To set this up call glEnablewith GL_NORMALIZE or GL_RESCALE_NORMAL
as a parameter (see red book for details).
The function glNormal*(x,y,z) sets the normal vector for a
vertex.
![Page 177: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/177.jpg)
Specifying normal vectors
In the examples above the objects viewed were generated by
calls to glutSolidSphere and glutSolidTorus. These func-
tions generate the appropriate surface normals for these objects.
However, you often have to specify normal vectors yourself.
For proper lighting, these normal vectors must have unit length.
Even if you specify unit length normals, their lengths can be
changed by subsequent transformations (scaling and shearing).
Therefore you may have to renormalize them. OpenGL can
do this for you automatically (at some computational expense).
To set this up call glEnablewith GL_NORMALIZE or GL_RESCALE_NORMAL
as a parameter (see red book for details).
The function glNormal*(x,y,z) sets the normal vector for a
vertex.
19
![Page 178: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/178.jpg)
Example: tent.c
![Page 179: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/179.jpg)
Example: tent.c
The program tent.c shows a ‘tent’ composed of two polygons.
![Page 180: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/180.jpg)
Example: tent.c
The program tent.c shows a ‘tent’ composed of two polygons.
Initially, the normal vectors are specified as follows:
![Page 181: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/181.jpg)
Example: tent.c
The program tent.c shows a ‘tent’ composed of two polygons.
Initially, the normal vectors are specified as follows:
Light 0
y
x
z
![Page 182: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/182.jpg)
Example: tent.c
The program tent.c shows a ‘tent’ composed of two polygons.
Initially, the normal vectors are specified as follows:
Light 0
y
x
z
The diffuse light source illuminates the right polygon much more
than the left, and the transition in illumination is abrupt.
20
![Page 183: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/183.jpg)
A more gentle transition in illumination can be enabled by spec-
ifying normal vectors as follows:
![Page 184: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/184.jpg)
A more gentle transition in illumination can be enabled by spec-
ifying normal vectors as follows:
Light 0
y
x
z
![Page 185: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/185.jpg)
A more gentle transition in illumination can be enabled by spec-
ifying normal vectors as follows:
Light 0
y
x
z
These two modes can be toggled by pressing ‘t’.
![Page 186: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/186.jpg)
A more gentle transition in illumination can be enabled by spec-
ifying normal vectors as follows:
Light 0
y
x
z
These two modes can be toggled by pressing ‘t’. Additionally,
a white specular component can be added to the light source
by pressing ‘s’.
![Page 187: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/187.jpg)
A more gentle transition in illumination can be enabled by spec-
ifying normal vectors as follows:
Light 0
y
x
z
These two modes can be toggled by pressing ‘t’. Additionally,
a white specular component can be added to the light source
by pressing ‘s’.
The following is the most relevant code from tent.c...
21
![Page 188: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/188.jpg)
void display(void) {
![Page 189: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/189.jpg)
void display(void) {
.
.
.
/* We require unit length normal vectors. For a vector with 2 non-zero
* elements of equal magnitude, the magnitude of both elements should be equal
* to 1 / sqrt(2) = 0.7071 for the vector to be of unit length. */
double l = 0.7071;
![Page 190: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/190.jpg)
void display(void) {
.
.
.
/* We require unit length normal vectors. For a vector with 2 non-zero
* elements of equal magnitude, the magnitude of both elements should be equal
* to 1 / sqrt(2) = 0.7071 for the vector to be of unit length. */
double l = 0.7071;
/* Set up the light in a position perpendicular to the right polygon. */
GLfloat light_position[] = { 3.0, 2.0, 0.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
![Page 191: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/191.jpg)
void display(void) {
.
.
.
/* We require unit length normal vectors. For a vector with 2 non-zero
* elements of equal magnitude, the magnitude of both elements should be equal
* to 1 / sqrt(2) = 0.7071 for the vector to be of unit length. */
double l = 0.7071;
/* Set up the light in a position perpendicular to the right polygon. */
GLfloat light_position[] = { 3.0, 2.0, 0.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
.
.
.
/* Draw the tent. */
glBegin(GL_QUADS);
![Page 192: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/192.jpg)
void display(void) {
.
.
.
/* We require unit length normal vectors. For a vector with 2 non-zero
* elements of equal magnitude, the magnitude of both elements should be equal
* to 1 / sqrt(2) = 0.7071 for the vector to be of unit length. */
double l = 0.7071;
/* Set up the light in a position perpendicular to the right polygon. */
GLfloat light_position[] = { 3.0, 2.0, 0.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
.
.
.
/* Draw the tent. */
glBegin(GL_QUADS);
/* Left side. */
![Page 193: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/193.jpg)
void display(void) {
.
.
.
/* We require unit length normal vectors. For a vector with 2 non-zero
* elements of equal magnitude, the magnitude of both elements should be equal
* to 1 / sqrt(2) = 0.7071 for the vector to be of unit length. */
double l = 0.7071;
/* Set up the light in a position perpendicular to the right polygon. */
GLfloat light_position[] = { 3.0, 2.0, 0.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
.
.
.
/* Draw the tent. */
glBegin(GL_QUADS);
/* Left side. */
glNormal3f(-l, l, 0);
![Page 194: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/194.jpg)
void display(void) {
.
.
.
/* We require unit length normal vectors. For a vector with 2 non-zero
* elements of equal magnitude, the magnitude of both elements should be equal
* to 1 / sqrt(2) = 0.7071 for the vector to be of unit length. */
double l = 0.7071;
/* Set up the light in a position perpendicular to the right polygon. */
GLfloat light_position[] = { 3.0, 2.0, 0.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
.
.
.
/* Draw the tent. */
glBegin(GL_QUADS);
/* Left side. */
glNormal3f(-l, l, 0);
glVertex3f(0, 0, 0);
![Page 195: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/195.jpg)
void display(void) {
.
.
.
/* We require unit length normal vectors. For a vector with 2 non-zero
* elements of equal magnitude, the magnitude of both elements should be equal
* to 1 / sqrt(2) = 0.7071 for the vector to be of unit length. */
double l = 0.7071;
/* Set up the light in a position perpendicular to the right polygon. */
GLfloat light_position[] = { 3.0, 2.0, 0.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
.
.
.
/* Draw the tent. */
glBegin(GL_QUADS);
/* Left side. */
glNormal3f(-l, l, 0);
glVertex3f(0, 0, 0);
glVertex3f(0, 0, 1);
![Page 196: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/196.jpg)
void display(void) {
.
.
.
/* We require unit length normal vectors. For a vector with 2 non-zero
* elements of equal magnitude, the magnitude of both elements should be equal
* to 1 / sqrt(2) = 0.7071 for the vector to be of unit length. */
double l = 0.7071;
/* Set up the light in a position perpendicular to the right polygon. */
GLfloat light_position[] = { 3.0, 2.0, 0.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
.
.
.
/* Draw the tent. */
glBegin(GL_QUADS);
/* Left side. */
glNormal3f(-l, l, 0);
glVertex3f(0, 0, 0);
glVertex3f(0, 0, 1);
if ( topUp ) glNormal3f(0, 1, 0);
![Page 197: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/197.jpg)
void display(void) {
.
.
.
/* We require unit length normal vectors. For a vector with 2 non-zero
* elements of equal magnitude, the magnitude of both elements should be equal
* to 1 / sqrt(2) = 0.7071 for the vector to be of unit length. */
double l = 0.7071;
/* Set up the light in a position perpendicular to the right polygon. */
GLfloat light_position[] = { 3.0, 2.0, 0.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
.
.
.
/* Draw the tent. */
glBegin(GL_QUADS);
/* Left side. */
glNormal3f(-l, l, 0);
glVertex3f(0, 0, 0);
glVertex3f(0, 0, 1);
if ( topUp ) glNormal3f(0, 1, 0);
glVertex3f(1, 1, 1);
![Page 198: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/198.jpg)
void display(void) {
.
.
.
/* We require unit length normal vectors. For a vector with 2 non-zero
* elements of equal magnitude, the magnitude of both elements should be equal
* to 1 / sqrt(2) = 0.7071 for the vector to be of unit length. */
double l = 0.7071;
/* Set up the light in a position perpendicular to the right polygon. */
GLfloat light_position[] = { 3.0, 2.0, 0.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
.
.
.
/* Draw the tent. */
glBegin(GL_QUADS);
/* Left side. */
glNormal3f(-l, l, 0);
glVertex3f(0, 0, 0);
glVertex3f(0, 0, 1);
if ( topUp ) glNormal3f(0, 1, 0);
glVertex3f(1, 1, 1);
glVertex3f(1, 1, 0);
![Page 199: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/199.jpg)
void display(void) {
.
.
.
/* We require unit length normal vectors. For a vector with 2 non-zero
* elements of equal magnitude, the magnitude of both elements should be equal
* to 1 / sqrt(2) = 0.7071 for the vector to be of unit length. */
double l = 0.7071;
/* Set up the light in a position perpendicular to the right polygon. */
GLfloat light_position[] = { 3.0, 2.0, 0.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
.
.
.
/* Draw the tent. */
glBegin(GL_QUADS);
/* Left side. */
glNormal3f(-l, l, 0);
glVertex3f(0, 0, 0);
glVertex3f(0, 0, 1);
if ( topUp ) glNormal3f(0, 1, 0);
glVertex3f(1, 1, 1);
glVertex3f(1, 1, 0);
/* Right side. */
![Page 200: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/200.jpg)
void display(void) {
.
.
.
/* We require unit length normal vectors. For a vector with 2 non-zero
* elements of equal magnitude, the magnitude of both elements should be equal
* to 1 / sqrt(2) = 0.7071 for the vector to be of unit length. */
double l = 0.7071;
/* Set up the light in a position perpendicular to the right polygon. */
GLfloat light_position[] = { 3.0, 2.0, 0.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
.
.
.
/* Draw the tent. */
glBegin(GL_QUADS);
/* Left side. */
glNormal3f(-l, l, 0);
glVertex3f(0, 0, 0);
glVertex3f(0, 0, 1);
if ( topUp ) glNormal3f(0, 1, 0);
glVertex3f(1, 1, 1);
glVertex3f(1, 1, 0);
/* Right side. */
glNormal3f(l, l, 0);
![Page 201: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/201.jpg)
void display(void) {
.
.
.
/* We require unit length normal vectors. For a vector with 2 non-zero
* elements of equal magnitude, the magnitude of both elements should be equal
* to 1 / sqrt(2) = 0.7071 for the vector to be of unit length. */
double l = 0.7071;
/* Set up the light in a position perpendicular to the right polygon. */
GLfloat light_position[] = { 3.0, 2.0, 0.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
.
.
.
/* Draw the tent. */
glBegin(GL_QUADS);
/* Left side. */
glNormal3f(-l, l, 0);
glVertex3f(0, 0, 0);
glVertex3f(0, 0, 1);
if ( topUp ) glNormal3f(0, 1, 0);
glVertex3f(1, 1, 1);
glVertex3f(1, 1, 0);
/* Right side. */
glNormal3f(l, l, 0);
glVertex3f(2, 0, 1);
![Page 202: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/202.jpg)
void display(void) {
.
.
.
/* We require unit length normal vectors. For a vector with 2 non-zero
* elements of equal magnitude, the magnitude of both elements should be equal
* to 1 / sqrt(2) = 0.7071 for the vector to be of unit length. */
double l = 0.7071;
/* Set up the light in a position perpendicular to the right polygon. */
GLfloat light_position[] = { 3.0, 2.0, 0.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
.
.
.
/* Draw the tent. */
glBegin(GL_QUADS);
/* Left side. */
glNormal3f(-l, l, 0);
glVertex3f(0, 0, 0);
glVertex3f(0, 0, 1);
if ( topUp ) glNormal3f(0, 1, 0);
glVertex3f(1, 1, 1);
glVertex3f(1, 1, 0);
/* Right side. */
glNormal3f(l, l, 0);
glVertex3f(2, 0, 1);
glVertex3f(2, 0, 0);
![Page 203: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/203.jpg)
void display(void) {
.
.
.
/* We require unit length normal vectors. For a vector with 2 non-zero
* elements of equal magnitude, the magnitude of both elements should be equal
* to 1 / sqrt(2) = 0.7071 for the vector to be of unit length. */
double l = 0.7071;
/* Set up the light in a position perpendicular to the right polygon. */
GLfloat light_position[] = { 3.0, 2.0, 0.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
.
.
.
/* Draw the tent. */
glBegin(GL_QUADS);
/* Left side. */
glNormal3f(-l, l, 0);
glVertex3f(0, 0, 0);
glVertex3f(0, 0, 1);
if ( topUp ) glNormal3f(0, 1, 0);
glVertex3f(1, 1, 1);
glVertex3f(1, 1, 0);
/* Right side. */
glNormal3f(l, l, 0);
glVertex3f(2, 0, 1);
glVertex3f(2, 0, 0);
if ( topUp ) glNormal3f(0, 1, 0);
![Page 204: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/204.jpg)
void display(void) {
.
.
.
/* We require unit length normal vectors. For a vector with 2 non-zero
* elements of equal magnitude, the magnitude of both elements should be equal
* to 1 / sqrt(2) = 0.7071 for the vector to be of unit length. */
double l = 0.7071;
/* Set up the light in a position perpendicular to the right polygon. */
GLfloat light_position[] = { 3.0, 2.0, 0.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
.
.
.
/* Draw the tent. */
glBegin(GL_QUADS);
/* Left side. */
glNormal3f(-l, l, 0);
glVertex3f(0, 0, 0);
glVertex3f(0, 0, 1);
if ( topUp ) glNormal3f(0, 1, 0);
glVertex3f(1, 1, 1);
glVertex3f(1, 1, 0);
/* Right side. */
glNormal3f(l, l, 0);
glVertex3f(2, 0, 1);
glVertex3f(2, 0, 0);
if ( topUp ) glNormal3f(0, 1, 0);
glVertex3f(1, 1, 0);
![Page 205: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/205.jpg)
void display(void) {
.
.
.
/* We require unit length normal vectors. For a vector with 2 non-zero
* elements of equal magnitude, the magnitude of both elements should be equal
* to 1 / sqrt(2) = 0.7071 for the vector to be of unit length. */
double l = 0.7071;
/* Set up the light in a position perpendicular to the right polygon. */
GLfloat light_position[] = { 3.0, 2.0, 0.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
.
.
.
/* Draw the tent. */
glBegin(GL_QUADS);
/* Left side. */
glNormal3f(-l, l, 0);
glVertex3f(0, 0, 0);
glVertex3f(0, 0, 1);
if ( topUp ) glNormal3f(0, 1, 0);
glVertex3f(1, 1, 1);
glVertex3f(1, 1, 0);
/* Right side. */
glNormal3f(l, l, 0);
glVertex3f(2, 0, 1);
glVertex3f(2, 0, 0);
if ( topUp ) glNormal3f(0, 1, 0);
glVertex3f(1, 1, 0);
glVertex3f(1, 1, 1);
![Page 206: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/206.jpg)
void display(void) {
.
.
.
/* We require unit length normal vectors. For a vector with 2 non-zero
* elements of equal magnitude, the magnitude of both elements should be equal
* to 1 / sqrt(2) = 0.7071 for the vector to be of unit length. */
double l = 0.7071;
/* Set up the light in a position perpendicular to the right polygon. */
GLfloat light_position[] = { 3.0, 2.0, 0.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
.
.
.
/* Draw the tent. */
glBegin(GL_QUADS);
/* Left side. */
glNormal3f(-l, l, 0);
glVertex3f(0, 0, 0);
glVertex3f(0, 0, 1);
if ( topUp ) glNormal3f(0, 1, 0);
glVertex3f(1, 1, 1);
glVertex3f(1, 1, 0);
/* Right side. */
glNormal3f(l, l, 0);
glVertex3f(2, 0, 1);
glVertex3f(2, 0, 0);
if ( topUp ) glNormal3f(0, 1, 0);
glVertex3f(1, 1, 0);
glVertex3f(1, 1, 1);
glEnd();
![Page 207: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/207.jpg)
void display(void) {
.
.
.
/* We require unit length normal vectors. For a vector with 2 non-zero
* elements of equal magnitude, the magnitude of both elements should be equal
* to 1 / sqrt(2) = 0.7071 for the vector to be of unit length. */
double l = 0.7071;
/* Set up the light in a position perpendicular to the right polygon. */
GLfloat light_position[] = { 3.0, 2.0, 0.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
.
.
.
/* Draw the tent. */
glBegin(GL_QUADS);
/* Left side. */
glNormal3f(-l, l, 0);
glVertex3f(0, 0, 0);
glVertex3f(0, 0, 1);
if ( topUp ) glNormal3f(0, 1, 0);
glVertex3f(1, 1, 1);
glVertex3f(1, 1, 0);
/* Right side. */
glNormal3f(l, l, 0);
glVertex3f(2, 0, 1);
glVertex3f(2, 0, 0);
if ( topUp ) glNormal3f(0, 1, 0);
glVertex3f(1, 1, 0);
glVertex3f(1, 1, 1);
glEnd();
.
.
.
}
22
![Page 208: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/208.jpg)
void init (void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_SMOOTH);
/* Set up material properties. */
GLfloat mat_ambient[] = { 1.0, 0.0, 0.0, 1.0 };
GLfloat mat_diffuse[] = { 0.0, 1.0, 0.0, 1.0 };
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
glMaterialf(GL_FRONT, GL_SHININESS, 50.0 ); /* No effect if specular == 0 */
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
}
23
![Page 209: Physical properties of light - School Learning Resources · 2019-03-07 · Physical properties of light Light consists of photons — “particles” with no mass which travelatthespeedoflight.](https://reader034.fdocuments.in/reader034/viewer/2022042116/5e9344204022305e014daed7/html5/thumbnails/209.jpg)
void key( unsigned char k, int x, int y )
{
switch (k) {
case 27: /* Escape */
exit(0);
break;
case ’s’:
specular = !specular;
if ( specular ) {
GLfloat mat_specular[] = { 0.0, 0.0, 1.0, 1.0 };
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
} else {
GLfloat mat_specular[] = { 0.0, 0.0, 0.0, 1.0 };
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
}
break;
case ’t’:
topUp = !topUp;
break;
default:
return;
}
glutPostRedisplay();
}
24