# Interpolation of surface normals on the face of a triangle and Goroud shading

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. 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?

-

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.