PDA

View Full Version : Difference between Gouraud and Phong Shading



explorer101
01-08-2015, 10:11 PM
Hello, I'm trying to understand Gouraud and Phong Shading. I have consulted several sources but I still couldn't understand what they are and what is the difference between them. Can you explain them to me shortly please?
Thanks.

Agent D
01-08-2015, 11:16 PM
Flat shading computes lighting values for one vertex per polygon and uses the resulting color for the entire polygon,
resulting in a single flat color for every polygon. The individual polygons can be seen.

Gouraud shading computes lighting values per vertex and interpolates them over a polygon, i.e. for each fragment on
the polygon, the color values from the vertices are interpolated.

With gouraud shading, you will get visible specular highligts on vertices, but you won't see much of the specular
highlight if it should be on the inside of a triangle. Around the specular highlight, you will see noticable poolygon
edges. Specular highlights will appear to jump from vertex to vertex when moving the model, camera or light source.
The quality of your specular highlights depends on the number of vertices in your model.
See here for an example (https://en.wikipedia.org/wiki/File:Gouraud_low_anim.gif).

Phong shading interpolates the lighting parameters across the polygon and computes the lighting per fragment, not
per vertex. You get good looking, round, smooth specular highlights that move smoothly along the surface as the camera,
model or light moves. No visible artifacts from the polygon edges.
See here for an example (https://en.wikipedia.org/wiki/File:Phong-shading-sample.jpg)

Phong shading is not to be confused with the Phong reflectance model, a mathematical model for computing illumination
at a point on a surface.

kaufenpreis
01-15-2015, 04:12 AM
Gouraud Shading is effective for shading surfaces which reflect light diffusely. Specular reflections can be modelled using Gouraud Shading, but the shape of the specluar highlight produced is dependent on the relative positions of the underlying polygons. The advantage of Gouraud shading is that it is computationally the less expensive of the two model, only requring the evaluation of the intensity equation at the polygon vertices, and then bilinear interpolation of these values for each pixels.
Phong Shading produces highlights which are much less dependent on the underlying polygons. However, more calculation are required, involving the interpolation of the surface normal and the evaluation of the intensity function for each pixel.

Carmine
01-15-2015, 09:48 AM
So my question is - Which type of shading is used in state of the art OpenGL applications such as Grand Theft Auto? Are shaders used to do Phong shading? Is something even more sophisticated or compute-intensive than Phong used? Fixed pipeline GL uses either flat or Gouraud (as far as I know).

Alfonse Reinheart
01-15-2015, 10:55 AM
At this point, the terms are effectively defunct. Goroud shading could be interpreted to mean "compute lighting per-vertex, then interpolate the result across the triangle," while Phong shading would mean "interpolate normals per-vertex, then compute lighting per-fragment".

This distinction is irrelevant, as "state of the art" applications use some form of bump-mapping, which does rather more than merely interpolating normals. And many modern engines are moving to deferred rendering, where you don't even do lighting "per-fragment"; you write the lighting components per-fragment, then do lighting on the visible pixels only.

Carmine
01-15-2015, 12:31 PM
I'm familiar with bump-mapping from rendering codes such as Lightwave. Didn't know it was being used in real-time apps like games. Thanks for explaining 'deferred rendering'. Have seen the term thrown around on the forums, but didn't really know what it meant. Bump mapping and deferred rendering are much more compute intensive than Phong shading - correct?

Alfonse Reinheart
01-15-2015, 02:20 PM
The whole point of deferred rendering is to be less "compute intensive" than other things; at it's core, it is merely an optimization. But this means of rendering makes the Goroud/Phong distinction functionally irrelevant, since it's doing lighting computations per-visible-sample. And even how much of an optimization it is depends on the GPU, as many tile-based GPUs don't get faster with deferred rendering, since they can sort tiles per-sample. Then again, others do get faster.

Stop thinking of rendering techniques as some kind of ladder, where X>Y>Z. They're rendering techniques, and each one has its own performance profile and its own visual fidelity. Some things look really good and are cheap. Some things don't change how things look at all, but are cheaper than what was there before. Some are cheap on some hardware and more expensive on others.

kaufenpreis
01-26-2015, 12:55 PM
Gouraud Shading is effective for shading surfaces which reflect light diffusely. Specular reflections can be modelled using Gouraud Shading, but the shape of the specluar highlight produced is dependent on the relative positions of the underlying polygons. The advantage of Gouraud shading is that it is computationally the less expensive of the two model, only requring the evaluation of the intensity equation at the polygon vertices, and then bilinear interpolation of these values for each pixels.
Phong Shading produces highlights which are much less dependent on the underlying polygons. However, more calculation are required, involving the interpolation of the surface normal and the evaluation of the intensity function for each pixel.

GClements
01-30-2015, 10:03 PM
Gouraud Shading is effective for shading surfaces which reflect light diffusely.
Maybe.

Even diffuse reflection will be approximated poorly by Gouraud shading when using a point light source whose distance to the surface isn't significantly larger than the size of the surface, or in areas with high curvature (i.e. where the angle between the normals at the primitive's vertices is significant).

Conversely, it can adequately approximate specular reflection if the polygons are small and curvature is low.