Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am learning lightning for 3D graphics. What I'm about to ask about is described on this tutorial page here.

The color of a certain pixel with lightning is given by

$$D*I*(\hat{L}\cdot \hat{N}))$$ Where $D$ is the color of the surface, $I$ is the color of the light source (also called intensity). $L$ is the vector pointing towards the light source, and $N$ is the surface normal. Note that D and I are not vectors, even though colors are actually 4D vectors in computer science. I assume this is because you're suppose to assume that you do this operation component wise for each of the components of the 4D vector (except the last component probably, which is the alpha value. If you can, let me know if my assumption on this is correct).

For directional lightning (the direction to the light never changes, like the sun), a technique used is called gouraud shading. The vertices of a face (triangle) have predefined normals and the lightning color is calculated at each of the vertices, and then interpolated along the entire face of the triangle. This means that a color of a point along the interpolation can be given as

$$(D*I*(\hat{L}\cdot \hat{N_{a}}))\alpha +(D*I*(\hat{L}\cdot \hat{N_{b}}))(1-\alpha)$$

Alpha is the interpolation value. $N_{a}$ and $N_{b}$ are two different normals at different vertices. The only reason this technique appears realistic is because the direction to the light does not change. Really, this way of calculating it is a shortcut, the proper way to do it is by just interpolating the normals instead of the color result. Like this.

$$D*I*(\hat{L}\cdot (\hat{N_{a}}\alpha+\hat{N_{b}}(1-\alpha)))$$

However, this is a more expensive interpolation. At the page I linked in the second sentence of this post, there is a proof that the above equation is equal to the below equation.

$$(D*I*(\hat{L}\cdot \hat{N_{a}}))\alpha +(D*I*(\hat{L}\cdot \hat{N_{b}}))(1-\alpha)$$

That is why goroud shading supposedly works. However, I have thought of a case where I think goroud shading does not work, meaning interpolating the resulting colors at the vertices of the face will not achieve the correct effect as interpolating the normals would.

Consider this image. Pretend it is a triangular face. face Pretend the direction to the light is given by the straight "up" vector at the center of that face as seen in the picture. Therefore, the face should be brightest at the center of the face. However, if you use goroud shading, notice it would not achieve this effect because the vertices of the face are supposed to be slightly darker than the middle. This is because the normals at the vertices are slightly pointed away from the direction towards the light. So interpolating dark to dark will obviously not achieve a brighter color in the middle.

If I am correct in this, does this mean the proof that showed the interpolation of the normals is equivalent to the interpolation of the results is wrong, or is there something else going on that I am missing?

share|cite|improve this question
up vote 4 down vote accepted

You're right that Gouraud shading (not "Goroud") falls over in the case you mentioned. The piece of the puzzle you're missing is that this equation for interpolating the normals: $$D * I * (\hat L \cdot (\hat N_a \alpha + \hat N_b (1 - \alpha)))$$ fails to renormalize the normal vector afterward. If $\hat N_a$ and $\hat N_b$ are unit vectors, then in general $\hat N_a \alpha + \hat N_b (1 - \alpha)$ will not be a unit vector. But the diffuse lighting formula $\hat N \cdot \hat L$ requires a unit normal vector to work correctly, so a "more correct" way of doing this would be to interpolate the normals, renormalize the normal at each pixel, then use it in the lighting equation. This approach is called Phong shading.

Interpolating the normals without renormalizing per pixel is indeed equivalent to Gouraud shading, by the linearity of the dot product. In your example, what would happen is that the interpolated normals near the center of the triangle would become a good deal shorter than unit length; this would darken the resultant lighting and you would not observe the expected bright spot in the middle of the triangle.

share|cite|improve this answer
Perfect answer! Thank you. – Dan Webster Mar 22 '13 at 3:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.