# Emulating OpenGL Normals Calculation

Imagine we have a triangle ABC with normals a, b, c.
glShadeModel is set to GL_SMOOTH.

The question is:
from OpenGL point of view, what is the normal to a point p inside a triangle?

Why do I need this:
I slice a triangle in two, but I want the picture to look exactly the same way as before slicing. This extra tesselation is required for sophisticated coloring, we develop 3D graphs plotter. =)

AFAIK there is no ‘OpenGL normal’ to a point inside the triangle. OpenGL just uses vertex normals and does not interpolate the normals when rendering with GL_SMOOTH but interpolates the color values of the lighting equation.
I don’t understand why you cannot just calculate the interpolated or even the ‘correct’ normal and use that, as the result should be nearly the same as your original rendering and definitely more correct than OpenGLs color interpolation.
I also don’t get why this is an advanced question?

from OpenGL point of view, what is the normal to a point p inside a triangle?

GL typically does Goraud shading, which means that the lighting equation is evaluated only at the vertices. This, in turn, means that you can’t get perfect interpolation for tesselated vertices.

If you use a particular shader that interpolates normals and does lighting per pixel, then you can emulate the interpolation that that shader does. It’s pretty common to use the barycentric coordinates and interpolate the normals based on that.

jwatte,
Thanks a lot!