phong shading

I just have a simple question. We implement Phong shading using shader. Can Phong shading be implemented without shader?

Basic Phong shading can be implemented with with multitexturing, but it’s a lot of effort, not particularly accurate, and applying a specular exponent is awkward to say the least.

Thanks a lot for the reply. I need some explanation. You mentioned about multitexturing. But what about when no texture is applied. Is per pixel normal calculated in the application and then color intensity applied. It’s definitely a lots of effort.
I also have some confusion about flat shading. One normal is calculated per triangle. Now if the vertices are assigned different color, in that case, per primitive color may be different, i.e. all pixels inside a triangle may not be assigned the same color. Isn’t it? These are very basic questions, but I’m still a bit confused.

Multi-texturing (glTexEnv() with a mode of GL_COMBINE) isn’t necessarily limited to textures. But in the case of using it for Phong shading, you need to use a cube map texture to normalise the interpolated normal (which is actually stored as texture coordinates).

[QUOTE=Lee_Jennifer_82;1280649]Is per pixel normal calculated in the application and then color intensity applied.
[/QUOTE]
No. Store the normals as 3-component texture coordinates. The interpolated texture coordinates (i.e. normals) are used to perform a lookup into a cube map which re-normalises the value (and converts it from -1…1 to 0…1). This is then combined with the light direction (a constant colour) using GL_DOT3_RGB.

It depends upon what you mean by “flat shading”.

With the fixed-function pipeline, If you use glShadeModel(GL_FLAT) then the colour of a single vertex is used for the entire primitive; no interpolation is performed. If you use glShadeModel(GL_SMOOTH) (the initial value) but specify the same normal for all vertices of a primitive, the computed colours at the vertices may still differ due to differences in the relative light position (for positional light sources) or differences in material colours (if GL_COLOR_MATERIAL is enabled). Even if the colour isn’t constant across the primitive, specifying normals per-primitive rather than per-vertex will result in discontinuities in colour across edges, causing the surface to appear to be made from many flat faces rather than being a smooth surface.

With shaders, individual variables (vertex shader outputs and fragment shader inputs) can be qualified as “flat”, meaning that the value of that variable for one vertex will be used for all fragments in the primitive, rather than interpolating the values for the different vertices across the primitive.

Thanks again for the clarification. I think Phong shading (without shader) can be performed using ray tracing. Isn’t it?

If you’re writing a software renderer, you can use whatever lighting models you want. But at that point, it no longer has anything to do with OpenGL.