Loading

Module 1: Lighting

Study Reminders
Support
Text Version

Set your study reminders

We will email you at these times to remind you to study.
  • Monday

    -

    7am

    +

    Tuesday

    -

    7am

    +

    Wednesday

    -

    7am

    +

    Thursday

    -

    7am

    +

    Friday

    -

    7am

    +

    Saturday

    -

    7am

    +

    Sunday

    -

    7am

    +

Hello and welcome to lecture number 14 in the course Computer Graphics. As usual, we will start by recollecting the pipeline stages which we are currently discussing.
So, there are 5 stages in the 3D graphics pipeline. Now, if you may recollect, this pipeline refers to the process of rendering a 2D image on a computer screen which is generated from a 3D scene and among those 5 stages, we have seen the first stage object representation. We have also discussed modeling transformation, the second stage. Currently we are discussing lighting or the third stage after that there are two more stages; one is viewing pipeline which itself is a series of 5 short stages and then finally scan conversion or rendering which is the last stage.
As I just mentioned we are currently discussing the third stage that is lighting. So, the idea is that we want to assign colors to the points that are on the surface of the objects that are there in a scene. The assignment of colors to the surface point is the responsibility of the third stage that is called the lighting stage. If you may recollect in the previous lecture we discussed the basic concepts that are there behind this coloring of surface point.
First thing is lighting that is, the light that comes after getting reflected from the point of interest to our eye that light determines the perception of color and this process of perceiving color by receiving the reflected light from the point of interest is called lighting and we discussed that this lighting can be computed with the help of a simple lighting model. Today we are going to talk about that simple lighting model.
When we are referring a lighting model to be simple that means we are trying to simplify certain things. Now if you may recollect lighting models refers to the modeling of the process of lighting. Now that is clearly an optical process and when we are using the term simple to refer to a lighting model we are essentially referring to the fact that many optical phenomena that happens in practice will be ignored.
Instead, we will make some simplifying assumptions about those phenomena and then implement the lighting model.
So, in order to discuss the lighting model, we will start with the basic idea that is we use the lighting models to compute colors at the surface points. So, essentially the job of the lighting model is to enable us to compute colors at the points of interest.
If you may recollect, in the introductory lecture we mentioned there are broadly two components that determine the color. One is light source, other one is surface properties. Now, for simplicity, let us start by assuming that is a single light source which is monochromatic and a point light source. Monochromatic means it has only one color component and it is a point light source.
If you recollect, we discussed point light source that are dimensionless and characterized by only position as well as the intensity of the emitted light. So, when we are assuming a monochromatic single point light source then how the model will look like let us try to derive it.
In order to do so, let us revisit our idea of perceiving a color the process involved in perceiving a color. So, this is a light source in the figure. Now as you can see on the queue this is a point of interest at this point we want to compute the color. Now color perception we get after we receive the light that gets reflected from that point to our eye or the viewer eye. Now this light is a combination of two incident light.
One comes directly from the light source this is direct light one comes after getting reflected from a secondary object this is we call ambient light. So, there are these two components direct light and ambient light.
So, we can say that this reflected light intensity can be approximated as a sum of intensities of the two incident light that is ambient light and direct reflection that is the assumption simplifying assumption that we are making.
Now this reflection from a point can occur in two ways. One type of reflection is called diffused reflection and the other type is called specular reflection. So, we have two types of reflection one is diffuse reflection other one is specular reflection.
Let us try to understand these different types of reflections with respect to one illustrative example. Look at the figure here as you can see on this object different colors are there at different points. This region is having slightly dark color and this color comes from ambient reflection. Above this region we have slightly brighter color excluding the central region this whole region excluding the central region is having somewhat brighter color that is called diffuse reflection.
Now diffuse reflection is defined as given here that when incident light tends to reflect in all directions from a rough or grainy surface then we get to see diffuse reflection. Now we assume that both reflection from direct light source as well as ambient light can result in diffuse reflection. So, ambient and diffuse technically both are same diffuse reflection, but we will differentiate between the two.
By the term diffuse we mean diffuse reflection due to direct light and by the term ambient we mean diffuse reflection due to ambient light.
For a shiny or smooth surface, we see a different sort of reflection that is light gets reflected in specific direction or region and if a viewer is situated within that region then the viewer gets to see a bright spot. You can see here in this figure, this zone, the color in this zone is completely different from the surrounding surface region. This is a bright spot and this results due to another type of reflection. Now this reflection is called specular reflection.
So, we have this third type of reflection specular reflection. So, we have diffuse reflection due to ambient light which gives us this dark color somewhat dark color then diffuse reflection due to direct light source which gives us somewhat lighter color and finally specular reflection which gives us this bright spots.
So, in light of this knowledge, let us now try to derive the simple model. So, in the simple model then we have 3 components. One component is due to the diffuse reflection of ambient light, one component is due to the diffuse reflection of direct light and the third component is due to the specular reflection of direct light that is incident at that point.
So, we can actually model the light intensity that reaches to the viewer from the surface point that is of interest to us as a sum of 3 intensities.
What are these 3 intensities? Intensity due to ambient light, intensity due to diffuse light and intensity due to specular light. Now when I say intensity due to ambient light I mean to say the diffuse reflection of ambient light when I say intensity due to diffuse light I mean to say diffuse reflection of direct light and when I say specular light I mean to say specular reflection due to direct light.
So, the intensity at the point is a sum of these three intensities which we denote by these terms Iamb, Idiff and Ispec.
Now, those are the components. Now, how to get those components? So, one assumption is that reflected light intensity is a fraction of incident light intensity. How to decide on this fraction? It is determined by a surface property which is known as the reflection coefficient or reflectivity. Now recollect in our earlier lecture we discussed about two determinants for color.
One is light source, other one is surface property. Now, we are bringing in the surface property here. So, we are assuming that the reflected light is a fraction of the incident light and the fraction is determined by one surface property that is the reflectivity or the reflection coefficient.
Now, in order to control the lighting effect in our computation, we define 3 such reflection coefficients.
One is for the 3 types of lights. So, one coefficient for diffuse reflection due to direct light, one coefficient for diffuse reflection due to ambient light and one coefficient for specular reflection due to direct light. So, diffuse reflection coefficient due to ambient light is denoted by ka. Diffuse reflection coefficient due to direct light is denoted by kd and specular reflection coefficient due to direct light is denoted by ks.
So, we are defining these three coefficients and we are also specifying the values that these coefficients can take. It is defined as a range.
These coefficients can take values within the range 0.0 to 1.0. Now when we are specifying the value to be 0.0, it represents a dull surface with no reflection so everything will be absorbed. And when you are specifying the value 1.0, it represents the shiniest surface with full reflection that is whatever gets incident to that point will be fully reflected from that point. So, it reflects all the incident lights.
By varying these values, we can actually control the amount of dullness or shininess of the surface of interest.
Now, as I said, there are three components which determines the color: one is the ambient light component, one is the diffuse reflection component due to direct light and one is the specular reflection component due to direct light. So, let us try to model this individual components one by one. We will start with the ambient light component which is the simplest two model and actually we will be making a very, very simplifying assumption in this case.
So, here we will assume that every surface is fully illuminated by an ambient light with intensity Ia so that is our simplifying assumption that all points are getting illuminated by the same ambient light intensity Ia so we will not consider complex optical behavior of light after getting reflected from surrounding surfaces. We will instead make a very, very simplifying assumption that any point gets illuminated by a single intensity Ia representing the ambient light. So, essentially we are modeling ambient light as a single light source with intensity Ia.
And we have already defined the reflectivity or reflective coefficient for ambient light. Now if the light that is incident at a point is Ia, then reflected light we can compute based on the
assumption will be the incident light multiplied by the coefficient. So, that will give us the ambient light component of the color. This is our simple model for ambient light. So, with this model we can compute the intensity contribution due to ambient light in the overall intensity which gives us the color.
Then we have the second component that is diffuse reflection component due to direct light source.
Now in order to model this component we make another assumption. This is about how the surface reflects the incident light. So, we assume that all the surfaces in the scene are ideal,
diffuse relectors or more popularly these are called Lambertian reflectors. Now this follows the Lambert’s cosine law. So, all the surfaces follow this law which states that energy reflected by a small portion of a surface from a light source in a given direction is proportional to the cosine of the angle between the direction and the surface normal. This is the Lambert’s cosine law. Now as per this law what we can infer?
The law implies that amount of incident light from a light source on a Lambertian surface is proportional to the cosine of the angle between the surface normal and the direction of the incident light. Now if we assume that this is the point of interest in the right hand figure, then this law the Lambert’s cosine law indicates that the amount of incident light from a light source on a Lambertian surface is proportional to the cosine of the angle between the surface normal and the direction of the incident light. Now this angle is called angle of incidence.
Based on this, let us assume a direct light source with intensity Is and the angle of incidence at the point is denoted by θ.
Then we can say that amount of light incident at that point according to the Lambert’s law is Iscosθ, as we have just seen as per the law.
Now if that is the incident light, we also know that a fraction of this light is reflected and reaches the viewer’s eye and that fraction is determined by the diffuse reflectivity or the diffuse reflection coefficient for direct light which we are denoting by kd. So then, the amount of light that gets reflected can be modeled with this expression and this will be the contribution of the diffuse reflection due to direct light to the overall intensity.
This will be our expression to compute the diffuse reflection component to the overall intensity value.
Now we can represent the same expression in different way. Let us assume L and N denotes the unit direction vector to the light source from the point and the unit surface normal vector respectively. So, L denotes the unit direction vector to the light source from the point of interest and N denotes the surface normal vector at that point.
Then the same expression we can rewrite in this way because we know that we can represent cosθ as a vector dot product in terms of the two unit vector N.L. So, if N.L>0, then we have the diffuse reflection component denoted by this expression and if it is less than equal to 0, then it is 0. This is another way of writing the same expression and we will follow this expression of this representation.
So, we have model the two components. And the third component is the one that is remaining which is model in specular reflection component.
Now, this component, we will model with some empirical derivation which we will see later and this empirically derived model was proposed by Bui Tuong Phong way back in 1973 and we shall use that model which is also known as Phong specular reflection model so we will be using this model in our simple lighting model.
So, what this model tells us the assumption is specular reflection intensity is proportional to cosine of the angle between viewing and specular reflection vector raise to a power that is the empirically derived law so to say. So, in this Phong model empirically it has been found that we can model specular reflection intensity as proportional to the cosine of the angle between the viewing and the specular reflection vectors raised to a power.
Now, V is the viewing vector and if R is the specular reflection vector and the angle between them is φ as shown here.
Then according to this empirically derived formula, we can say specular reflection component is proportional to this expression where φ is defined within this range 0 degree and 90 degree. Now the term ns which is the power is called specular reflection exponent and by using this exponent judiciously we can generate different effects and by varying the value of course if the value is larger greater than 100, then it can generate shiny surface effect if the value is close is 1, it generates rough surface effect.
Like in case of diffuse reflection, in case of specular reflection also, we can have vector representation of the same expression. First let us see the actual expression to compute specular reflection component. Now as we have said this component is the amount of incident light kd is the specular reflectivity. So, the actual component is given by earlier we said I specular is proportional to this component and this proportionality constant is the kd.
So, the actual component is kd multiplied by the expression. Now we know cosφ can be represented by vector dot product V and R, where V and R represents the unit vector along the viewing direction and the specular reflection direction. So, by using this expression we can say or we can represent the specular component in terms of vector product in this way. Now if V.R > 0, then we have this component to compute specular component.
And if V.R ≤ 0, then we have 0. Also to make the expression more comfortable with the previous expression that we have seen we will replace R in terms of the other vectors L and N.L is the vector direction towards light source N is the surface normal. So, if we use this
expression for R then all our reflection components both diffuse reflection as well as specular reflection due to direct light can be computed only in terms of L and N.
Rather than L and N in one case and V and R in another case. So, in case of diffuse reflection due to direct light source we have L and N in case of specular reflection due to direct light source we have L and as well as V the viewing direction and we are replacing R with L and N. So, these are the 3 components that we can use to compute the overall intensity of the reflected light from the point of interest.
There is another interesting thing which is called intensity attenuation. Now, in our computations that we have discussed earlier, we assume that the light intensity does not change as it moves from the source to the surface point. So, the intensity after getting emitted at source and the intensity when it is incident at a point which is some distance away from the source we are assuming both are same.
What is the problem with that assumption if we make such assumption that will happen? Assume, there are two surface points: one is closer to the source and the other is slightly farther away. Now intensity of the light received by either of these points will be the same because we are not assuming any change in intensity in the incident light depending on the distance then the color computed using our simple lighting model will also be the same.
So, nowhere in the computation we are taking into account the distance travelled by the light explicitly then the color computed will also be the same and as a result we will not be able to identify or perceive the relative difference in distance between the two points.
So, all surfaces will be illuminated with equal intensities irrespective of their distance which will lead to indistinguishable overlapping of surfaces when projected on screen. So, we will not be able to understand the distance between them which will reduce the perception of 3D.
In order to address this issue, we incorporate something called intensity attenuation. In our model, in the form of attenuation factors. Now there are two such factors: one is radial attenuation factor and the other one is angular attenuation factor radial attenuation factor denoted by AFrad and angular factor denoted by AFang.
Now radial factor accounts for the effect of diminishing light intensity over distance and we model it using an inverse quadratic function shown here where a0, a1, a2 are coefficients that we can vary to produce better realistic effects and d is the distance between source and surface point. So, by using this inverse quadratic function we can take into account the effect of distance on the intensity.
The other attenuation factor is angular attenuation. So, in this case, we use it primarily to generate the spotlight effect. So, there are many ways to do this of course, but one commonly used function is shown here. With this function, we can actually take into account the angular attenuation. So, farther away from this axis of point is it will reduce the intensities and that reduction in intensity with respect to the axis cone axis spotlight cone axis can be computed using this expression.
It will be 0, if the surface point is outside the angular limit θ. So, if some point is here which is outside this limit then of course it is not likely to be getting influenced by the spotlight so the overall component will be 0, but if it is within this limit say somewhere here then depending on its angle and with respect to the axis we can compute using this expression where φ is the angle that this point makes with the cone axis.
Now taking into account this attenuation so our simple lighting model will change. Earlier we had the model as a sum of three components Iamb, Idiff and Ispec. Now we are taking into the account the attenuation factor and then we are modifying the form. It now takes the form of Ip= Iamb + AFrad AFang [Idiff+Ispec].
So, AFrad denotes the attenuation factor radial attenuation factor and AFang denotes the angular attenuation factor. Now if these values are set to 1, then of course as you can see we are eliminating the attenuation effect and some value other than 1 will include the effect that is all about monochromatic point light source.
Now let us assume colored source what will happen in that case? So, in case of monochromatic light which generate different shades of gray. Now if we have to generate color images then we need to consider colored light source.
Now as we have discussed earlier in the introductory lecture, when we are talking of color, we are assuming that there are three primary colors: red, green and blue. They together give us the perception of a particular color. Accordingly we can assume that the source light intensity is a three element vector. So, source intensity has three component intensity: one for red, one for green, one for blue.
Similarly, reflection coefficient also have components. Each coefficient is a vector having three coefficient - one is for each of the color. So one for red, one for green, one for blue for each of the coefficient for ka, kd and ks. So, this is the only modification we made in order to take into account colored light sources.
Then we compute each color component separately using the light model with appropriate source intensity and coefficient values. So, for computing the component for red we use the red source intensity as well as the reflective coefficients for red. Similarly, for green and blue.
That is the modification and finally let us assume that there are more than one light sources.
In that case what will happen again a simple extension so earlier we had only these component plus this component now we are introducing a summation component here. So, for each of the source we will compute these component and then we will add it up for all the n light sources. Note that ambient component will not change because it is the same for all with a single ambient light intensity.
The change is only for the components due to direct light namely diffuse component and the specular reflection component. So, this is the overall simple lighting model in general for multiple sources and if we want to have color then we will simply have IpR, IpG and IpB for red, green, blue where these coefficient for ambient light as well as diffused reflection coefficients will be chosen according to the specific color component.
So, we will have 3 separate values giving us a 3 element output. So, that is in summary our overall simple lighting model.
So, to summarize, we have discussed a simple model assuming that there is one point light source initially we assume monochromatic then we assume that there are colored light sources and initially we observe single light source then we assume that there are multiple light sources, but in all the cases we assume that it is a point light source. So, a dimensionless light source characterized by only position and intensity.
Another thing that you should note here is that the simplifying assumptions we made. So, to compute ambient light we assume that there is a single ambient light intensity which is not true in practice. To compute diffuse light component due to direct light. We assume that Lambertian surfaces are there which again need not be true in practice and to compute specular component we assume an empirically derived model the Phong’s specular model which does not reflect the actual optical behavior.
But in spite of these assumptions whatever we get gives us a working solution to our problem of computing colors which works in practice. So, although it does not reflect the actual optical behavior it gives us a working solution and due to this many simplifying assumptions we are calling it simple lighting model. In order to discuss this simple lighting model we left out many important topics which actually designed to take into the account the actual optical behavior.
Which in turns gives us even better, much, much better realistic effects which is expected, but at the cost of increased heavily increased computation. To know more about such models you may refer to the material that will be mentioned in the next slide.
So, with this, we conclude our discussion on the simple lighting model. As I said to learn about this you may refer to this book, refer to chapter 4, section 4.2 to learn in more details the topics that I have discussed today and also you may refer to the reference material mentioned in that book and in that chapter for more details on the more realistic lighting models which are much more complex than the simple model. So, with this I conclude today’s lecture. Thank you and good bye.