D3DSHADE_GOURAUD & D3DSHADE_PHONG

Started by
4 comments, last by SoaringTortoise 21 years, 1 month ago
What''s the difference between these, and why isn''t Phong supported yet (if even only in software)? Learning to fly is easy, but as a tortoise, the landings are really rough.
Always prey on the weak, the timid and the stupid. Otherwise you'll just get your butt kicked
For a tortoise, this is extremely hard to do, but when you get it right... the expression on their faces ...
Advertisement
1-In GOURAUD shading you perform a dot product operation between (the normal on each vertex and the vector between the vertex and the light source) to get the color of the vertex.then interpolation is done on the whole face to find the color of each pixel.
2-In phong shading,at each pixel interpolation for the normals is done to find the normal at each pixel,then dot product between (the normal and the vector between the pixel and the light source) is done to find the color at each pixel.

as you see,phong shading is more realistic and more accurate ,but is very slow as the dot produt operation is done once for each pixel,while GOURAUD shading is done once for each vertex.for this reason phong shading is not supported in the fixed functin pipeline.
3-there are two ways to perform phong shading though it is not supported

a)Increasing the number of vertices very much of the model you are rendering.
b)using the vertex and pixel shaders ,you can enter the normals as texture coordinates as interpolation is always done for texture coordinates,and then calculate the color for each pixel using the dot product operation.there is a source code by wolfGang on his site of shaderx.com using this technique.
1-In GOURAUD shading you perform a dot product operation between (the normal on each vertex and the vector between the vertex and the light source) to get the color of the vertex.then interpolation is done on the whole face to find the color of each pixel.
2-In phong shading,at each pixel interpolation for the normals is done to find the normal at each pixel,then dot product between (the normal and the vector between the pixel and the light source) is done to find the color at each pixel.

as you see,phong shading is more realistic and more accurate ,but is very slow as the dot produt operation is done once for each pixel,while GOURAUD shading is done once for each vertex.for this reason phong shading is not supported in the fixed functin pipeline.
3-there are two ways to perform phong shading though it is not supported

a)Increasing the number of vertices very much of the model you are rendering.
b)using the vertex and pixel shaders ,you can enter the normals as texture coordinates as interpolation is always done for texture coordinates,and then calculate the color for each pixel using the dot product operation.there is a source code by wolfGang on his site of shaderx.com using this technique.
1-In GOURAUD shading you perform a dot product operation between (the normal on each vertex and the vector between the vertex and the light source) to get the color of the vertex.then interpolation is done on the whole face to find the color of each pixel.
2-In phong shading,at each pixel interpolation for the normals is done to find the normal at each pixel,then dot product between (the normal and the vector between the pixel and the light source) is done to find the color at each pixel.

as you see,phong shading is more realistic and more accurate ,but is very slow as the dot produt operation is done once for each pixel,while GOURAUD shading is done once for each vertex.for this reason phong shading is not supported in the fixed functin pipeline.
3-there are two ways to perform phong shading though it is not supported

a)Increasing the number of vertices very much of the model you are rendering.
b)using the vertex and pixel shaders ,you can enter the normals as texture coordinates as interpolation is always done for texture coordinates,and then calculate the color for each pixel using the dot product operation.there is a source code by wolfGang on his site of shaderx.com using this technique.
Just a little note: The act of "Gouraud" shading means interpolating between vertex colors as you''re rasterizing the triangle. i.e. It works even when lighting''s disabled.

Cheers,
Muhammad Haggag

Ok. Thanks folks.

Learning to fly is easy, but as a tortoise, the landings are really rough.
Always prey on the weak, the timid and the stupid. Otherwise you'll just get your butt kicked
For a tortoise, this is extremely hard to do, but when you get it right... the expression on their faces ...

This topic is closed to new replies.

Advertisement