Contour Shading

Is there a way of specifying the colour transition from one vertex of a quad to the other. Say with the following code

GL_BEGIN GL_QUADS
GLCOLOR3F 0,0,1
GLVERTEX 0,0,0
GLCOLOR3F 1,0,0
GLVERTEX 10,0,0
etc
GL_END

The default colour transition will be blue to red in a default number of colour bands. I want to be able to specify firstly the number of colour bands and also the colour of the intermediate ones.

Many thanks

you can:

  • try indexed mode.
  • use a texture which represent the color transition.
  • add vertice to you quad with the corresponding color.

How do you apply 1D Texture to a QUAD which is a 2D entity

if you want the color transition only on the quad’s edge, you’ll have to use a 2D texture.

Each of the vertices might have different colours assigned to it so a 2D texture image will not be suitable.

I don’t see what do you mean. a little image should help.

Put the bands in a 1D texture. Then use glTexCoord1f instead of glColour to specify the “band index” 0.0 for one end of the bands and 1.0 for the other. This should work. Try it before you say it won’t work on a quad since it’s 2d at least. Then again, you might want something else than what I think you want. If so, you need to explain more.

Say the quad is as follows

4***************1

  •           *
    
  •           *
    
  •           *
    
  •           *
    
  •           *
    
  •           *
    

1***************2

Where the corner points have different colour code to be assigned. In the above diagram, the contour lines would go diagonally across.