0
$\begingroup$

I am struggling to understand as to why fundamentally triangles shaded through Gouraud shading and ones shaded through Phong shading look different.

From my understanding, Gouraud Shading, takes the vertices of a triangle. It calculates the color at each vertex with the help of vertex normals, and interpolates that color across the triangle per-pixel. Phong Shading calculates the normal at each vertex, and interpolates the normals across the triangle per-pixel and shades the said pixels using interpolated normals

Both involve interpolation. Why is it that interpolating normals produces a more realistic results, while interpolating the colors directly does not? What is it about the interpolation of colors that makes it less accurate?

Under the hood, isn't interpolating just a color similar to interpolating the normal and finding the color at every point? If not, intuitively how are they both different then?

$\endgroup$
2
  • $\begingroup$ Hint: Consider specular highlights. $\endgroup$
    – Simon F
    Jul 21, 2021 at 10:31
  • $\begingroup$ @SimonF Yes I did see several clips where the specular highlights in Gouraud appear to be...concentrated near the vertexes for a lack of better words. I am assuming this happens because closer to the vertexes the colors would obviously be closer to that of the vertex's colors But why doesn't a similar thing happen for Phong shading? Why won't the normals be closer to the vertex normals the closer we are to the vertex? Why wont a similar effect happen in Phong shading then? $\endgroup$
    – Hash
    Jul 21, 2021 at 10:36

2 Answers 2

4
$\begingroup$

View angle changes all the time. In goraud shading the color sampling is done once per vertex.

But in phong shading the angle between view angle and normal is calculated for every pixel.

Why would that be different. Well simply because angle changes, and its cosine, is not a linearly changing quantity. (Ill draw a picture later when i get to a computer)

Imagine a large plane diffuse plane. Then the diffuse shading you see is based on the dot product of the normal and the normalized vector to light. Now imagine the light is in the middle of the plane. If you only have verices at the corners of the plane you get a uniform intensity. If you subdivide once you do not. If you subdivide by pixel you get phong shading and due to the dot prduct not being linear a different answer.

enter image description here

TL;DR

A noninear function does not approximate well with a linear function.

$\endgroup$
13
  • $\begingroup$ If the large plane is lit uniformly as you said, such that every point on the plane is hit by the same 'intensity' of light, why would there be a specular highlight on a particular point on the plane? $\endgroup$
    – Hash
    Jul 22, 2021 at 18:18
  • $\begingroup$ @Hash not uniformly, symmetrically. In real life planes dont become uniformly lit just as long as corners are lit the same way. $\endgroup$
    – joojaa
    Jul 22, 2021 at 18:30
  • $\begingroup$ What do you mean exactly by 'symmetrically' in 'symmetrically lit' here? Sorry I am a bit confused $\endgroup$
    – Hash
    Jul 22, 2021 at 19:11
  • 1
    $\begingroup$ Any light source that lights the object so that the color at corners is the same. Like say a point light smack in the middle of a square, whike your camera is pointing down smack in the middle of the square. In real life you get this nice radial falloff. As you do with phong, with goraud you get a flat color. $\endgroup$
    – joojaa
    Jul 22, 2021 at 19:22
  • $\begingroup$ Could it be that @Hash is unaware of radiometric concepts? If this is the case please read Chapter 5 of PBRT as an introduction. Otherwise, I apologize. In the rendering equation, there is a cosine in the irradiance term. Hence, even if the incoming light radiance and the brdf are constant everywhere, the reflected radiance will be non-linear, which cannot be expressed as a linear combination such as the one carried out by Gouraud shading. This is exactly what is being depicted in this answer. $\endgroup$
    – vgs
    Jul 23, 2021 at 19:28
1
$\begingroup$

RGB "Colors" contain chromaticity(color) and luminance(brightness), normal vectors contain direction and magnitude.

Gouraud shading approximates color gradients.

Phong shading approximates surface gradients.

Imagine a large triangle with a small specular highlight at the center and all 3 vertex positions have normal vectors pointing away from the highlight so are only dimly lit.

Interpolating the color will completely miss the highlight and only give values between those at the 3 vertex positions.

Interpolating the normal vectors will force a change of direction in the vector so that the highlight is visible.

Also, interpolation of normal vectors changes their length which can be recalculated in the fragment shader to help improve the approximation. But there is very little we can do to help correct interpolated colors.

Edit: Why interpolating between two vectors changes length. To interpolate vectors we use the formula $N_c = N_a\alpha+N_b(1-\alpha)$ where $N_a$ and $N_b$ are the two vectors being interpolated. This includes the sum of two vectors. Adding vectors can be thought of visually as placing them end to end, so the sum of two vectors results in a third vector with its own length resulting from the angle between the two vectors.

enter image description here

As simon f pointed out in comments my description of mach banding is poorly worded and misleading. See the comment below. Here is an image of the effect in action. enter image description here

$\endgroup$
8
  • $\begingroup$ Why would interpolation of normal vectors change their length? Aren't normal vectors by definition have a length of 1? What causes their length to change from 1 to something else when they are interpolated? $\endgroup$
    – Hash
    Jul 22, 2021 at 12:42
  • $\begingroup$ I added a brief explanation of vector sums and their length. $\endgroup$
    – pmw1234
    Jul 22, 2021 at 13:40
  • $\begingroup$ @pmw1234 re "Additionally, interpolated colors tend have a nice perfect change from one color to another across the surface of the triangle, this causes an effect called "mach banding" where it looks like there are color bands when the transition is actually smooth." The Mach bands occur at the boundaries where triangles meet because the eye picks up the discontinuity in the rates of change from triangle to triangle $\endgroup$
    – Simon F
    Jul 23, 2021 at 12:06
  • 1
    $\begingroup$ I agree, I edited the answer and linked an example. $\endgroup$
    – pmw1234
    Jul 23, 2021 at 12:24
  • $\begingroup$ @SimonF what is referred by rate of change of triangle to triangle? Is it how the lighting values calculated in gouraud shading is calculated per vertex hence moving from triangle to triangle we see "changes" and discontinuities in color? $\endgroup$
    – Hash
    Jul 23, 2021 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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