I am developing a visualization tool in OpenGL to visualize the output of a 3d finite element modeling application. The application uses a tetrahedral mesh (but I am only viewing the exterior facets, which are triangles). The output is a scalar variable, which I want to map to a color map (I already know how to do that). The tricky part is that the value of the variable in each cell is given by a polynomial function (I think it's of degree 3, but that hasn't been finalized yet) of the coordinates in that cell.
In OpenGL, if I use the "smooth" shading model, then if I create a polygon and give each vertex a different value, then it will automatically interpolate (linearly) between the values at the vertices in order to get the color values at the points in the interior. But that just gives a linear function in each cell, and I want it to be a nonlinear function that I specify. Is there a way to do this?
(Of course, one solution would be to interpolate "manually" by drawing each cell as a composite of much smaller OpenGL polygons that are small enough that the color doesn't change much in each of them. But I want to know if OpenGL itself has a solution.)