Computer Graphics Lecture 31 Mathematics of Lighting and

  • Slides: 52
Download presentation
Computer Graphics Lecture 31

Computer Graphics Lecture 31

Mathematics of Lighting and Shading - V Taqdees A. Siddiqi cs 602@vu. edu. pk

Mathematics of Lighting and Shading - V Taqdees A. Siddiqi cs 602@vu. edu. pk

Physically Based Illumination

Physically Based Illumination

In order to get a more realistic representation of lighting, we need to move

In order to get a more realistic representation of lighting, we need to move away from the simplistic models that are found hard coded in most graphics pipelines.

and move to something that is based more in a physical representation of light

and move to something that is based more in a physical representation of light as a wave with properties of its own that can interact with its environment

To do this, we'll need to understand how light passes through a medium and

To do this, we'll need to understand how light passes through a medium and how hitting the boundary layer at the intersection of two media can affect light's properties

In Figure 1, there's an incident light hitting a surface. At the boundary of

In Figure 1, there's an incident light hitting a surface. At the boundary of the two media (in this case, air and glass), there are two resulting rays of light.

The reflected ray is the one that we've already discussed to some extent, and

The reflected ray is the one that we've already discussed to some extent, and the other ray is the refracted or transmitted ray.

Figure 1: Light being reflected and refracted through a boundary.

Figure 1: Light being reflected and refracted through a boundary.

Until now, we've been treating our surfaces as perfectly smooth and uniform this prevents

Until now, we've been treating our surfaces as perfectly smooth and uniform this prevents us from getting some interesting effects

In addition to examining the interaction of light with the surface boundary, we need

In addition to examining the interaction of light with the surface boundary, we need a better description of real surface geometries

let's look at the physics of light interacting at a material boundary.

let's look at the physics of light interacting at a material boundary.

Reflection

Reflection

Reflection of a light wave is the change in direction of the light ray

Reflection of a light wave is the change in direction of the light ray when it bounces off the boundary between two media

light wave reflecting off a perfectly smooth surface

light wave reflecting off a perfectly smooth surface

Using a lighting model based upon the Blinn— Phong model means that we'll always

Using a lighting model based upon the Blinn— Phong model means that we'll always get a uniform specular highlight based upon the color of the reflecting light and material

In order to get a more interesting and realistic lighting model, we need to

In order to get a more interesting and realistic lighting model, we need to add in some nonlinear elements to our calculations

Refraction

Refraction

Refraction happens when a light wave goes from one medium into another.

Refraction happens when a light wave goes from one medium into another.

Because of the difference in the speed of light of the media, light bends

Because of the difference in the speed of light of the media, light bends when it crosses the boundary. Snell's law gives the change in angles.

where the n's are the material's index of refraction

where the n's are the material's index of refraction

Snell's law states that when light refracts through a surface, the refracted angle is

Snell's law states that when light refracts through a surface, the refracted angle is shifted by a function of the ratio of the two material's indices of refraction

The index of refraction of vacuum is 1, and all other material's indices of

The index of refraction of vacuum is 1, and all other material's indices of refraction are greater than 1

Figure 2: The refracted ray's angle is less than the incoming ray's.

Figure 2: The refracted ray's angle is less than the incoming ray's.

The angle of incidence is the angle between the incoming vector and the surface.

The angle of incidence is the angle between the incoming vector and the surface. Rearranging Snell's law, we can solve for the refracted angle.

Inserting the values give us

Inserting the values give us

If we use Snell's law for light going from water to air, and plug

If we use Snell's law for light going from water to air, and plug in 90° for the refracted angle, we get 41. 8° for the incident angle. This is called the critical angle at which we observe the phenomenon of total internal reflection

At any angle greater than this, light will not pass though a boundary but

At any angle greater than this, light will not pass though a boundary but will be reflected internally

One place that we get interesting visual properties is in the diamond—air interface.

One place that we get interesting visual properties is in the diamond—air interface.

The refractive index of a diamond is fairly high, 2. 24, which means that

The refractive index of a diamond is fairly high, 2. 24, which means that it's got a very low critical angle, just 24. 4°.

This means that a good portion of the light entering a diamond will bounce

This means that a good portion of the light entering a diamond will bounce around the inside of the diamond hitting a number of air— diamond boundaries, and as long as the angle is 24. 4° or greater, it will keep reflecting internally

This is why diamonds are cut to be relatively flatish on the top but

This is why diamonds are cut to be relatively flatish on the top but with many faceted sides, so that light entering in one spot will bounce around and exit at another, giving rise to the sparkle normally associated with diamonds.

Another place where a small change in the indices of refraction occurs is on

Another place where a small change in the indices of refraction occurs is on a road heated by the sun when viewed from far away

The hot air at the road's surface has a slightly smaller index of refraction

The hot air at the road's surface has a slightly smaller index of refraction than the denser, cooler air above it.

This is why we get the effect of a road looking as though it

This is why we get the effect of a road looking as though it were covered with water and reflecting the image above it—the light waves are actually reflected off the warm air— cold air interface.

Figure 3: The critical angle.

Figure 3: The critical angle.

What makes this really challenging to model is that the index of refraction for

What makes this really challenging to model is that the index of refraction for most materials is a function of the wavelength of the light

This means that not only is there a shift in the angle of refraction,

This means that not only is there a shift in the angle of refraction, but that the shift is different for differing wavelengths of light

Figure 4 and 5 show the index of refraction for fused quartz and sapphire

Figure 4 and 5 show the index of refraction for fused quartz and sapphire plotted against the wavelength.

We can see the general trend that shorter wavelength light (bluish) tends to bend

We can see the general trend that shorter wavelength light (bluish) tends to bend more than the longer (reddish) wavelengths.

Figure 4: Index of refraction as a function of wavelength for quartz.

Figure 4: Index of refraction as a function of wavelength for quartz.

Figure 5: Index of refraction as a function of wavelength for sapphire.

Figure 5: Index of refraction as a function of wavelength for sapphire.

This is the phenomenon that's responsible for the spectrum that can be seen white

This is the phenomenon that's responsible for the spectrum that can be seen white light is passed through a prism (Figure 6)

Figure 6: The wavelength dependence of the index of refraction in action.

Figure 6: The wavelength dependence of the index of refraction in action.

It's refraction that will break apart a light source into its component colors, not

It's refraction that will break apart a light source into its component colors, not reflection.

This is one area where our simplistic model of light breaks down since we're

This is one area where our simplistic model of light breaks down since we're not computing an entire spectrum of light waves, but we're limited to three primary colors.

For reference, the rgb values can be assigned to a range of wavelengths as

For reference, the rgb values can be assigned to a range of wavelengths as follows:

While the spectrum spreading effect of refraction is interesting in itself, the rgb nature

While the spectrum spreading effect of refraction is interesting in itself, the rgb nature of computer color representation precludes performing this spreading directly—we can't break up a color value into multiple color values.

However, with some work, we can compute the shade of the color for a

However, with some work, we can compute the shade of the color for a particular angle of refraction and then use that as the material color to influence the refracted color.

Computer Graphics Lecture 31

Computer Graphics Lecture 31