PDA

View Full Version : How does OpenGl implement specular highlighting?



rantrod
03-08-2001, 01:01 PM
When OpenGl works with triangle-based graphics cards (that's pretty much all of them), how does it implement specular highlighting? I couln't find it in the documentation.
My guess is that it maps a texture that looks like the highlight, around the drawn objects so that the highlight ends up facing the dir of the light.
Anyone know for sure?
Anyone know the algorithm?

cass
03-08-2001, 01:26 PM
OpenGL's built-in lighting is evaluated at the object vertices and interpolated over the primitive. You can find pretty much all the information you need in the spec. There's a link to it somewhere on this website. http://www.opengl.org/discussion_boards/ubb/smile.gif

Thanks-
Cass

rantrod
03-08-2001, 01:50 PM
interpolated over the objects primitve?
If the harware can only draw triangles (no scan-line algorithms), how can this be done? It would be impossible to get a triangle that had dark vertices and a highlight in the middle.
I looked in the spec, but couldn't find it. There was some code to find specular color, but that's it.

mmeyer
03-08-2001, 02:01 PM
First of all, what do you mean by "the hardware can only draw triangles (no scan-line algorithms)"?? Drawing the triangles is (usually) a scan-line based rasterization.

Second, yes it is impossible (using only basic openGL lighting - no special texturing tricks) to get a triangle with 3 dark vertices and a highlight in the middle. This is one of the fundamental limitations of Goraud interpolation (interpolating colors calculated at the vertices) and also one reason to possibly use phong interpolation (interpolate the normals and calculate the lighting at each pixel) or another interpolation or texturing technique (specular (highlight) mapping).

rantrod
03-08-2001, 02:39 PM
I mean with the graphics card you have no control over the rasterization process. The card expects to receive triangle data. The cards handle the rasterization internally in hardware. If we want a triangle with dark edges and a highlight in the middle, we must find a way to do it that doesn't involve the rasterization process (via texturing or shading).

I didn't know that openGL's specular highlighting only involved shading the vertices. I guess if you have a lot of triangles, it would look ok.

Alain
03-08-2001, 11:58 PM
You got to the point: if you want to get satisfactory specular lighting, you need to subdivise your surfaces into many small triangles.
This applies at least to standard OpenGL.
However, with Nvidia's extensions for the GeForce3, you could do what you want. But it requires a LOT of work (and a GeForce3 too...).

Won
03-09-2001, 02:26 AM
OpenGL does per-vertex lighting, but there are plenty of extensions that let you perform per-pixel lighting (e.g. register combiners). There are tons of demos.

-Won