PDA

View Full Version : How to draw a surface with color SMOOTH?



helenw
12-08-2005, 05:05 AM
Hi, teachers,

I want to draw a surface comprising triangular faces. Each point forming the triangular faces has different colors arranged. The codes are as follows.
However, it looks that the surface displayed is not SMOOTH with many sawtooths (color sawtooths).

How can I do?

Thanks.

glEnable(GL_POLYGON_SMOOTH);
for(j=0;j<NumberOfTriangle; j++)
{
glBegin{GL_POLYGON};
for{i=0;i<3;i++}
{
glColor3fv{Color[j][i]};
glNormal3fv{VerNorm[j][i]};
Vertex3f{x[j][i],y[j][i],z[j][i]}
}
glEnd{};
}

Jackis
12-08-2005, 05:45 AM
The decision for your problem is

glShadeModel(GL_SMOOTH);That thing you've done actually does polygon edge smoothing, it doesn't affect color interpolations.

helenw
12-08-2005, 01:55 PM
Originally posted by Jackis:
The decision for your problem is

glShadeModel(GL_SMOOTH);That thing you've done actually does polygon edge smoothing, it doesn't affect color interpolations.Thank you first.

But I have used glShadeModel(GL_SMOOTH). The colors, especially at the edges of different colors, are still not SMOOTH. There are many color sawtooths.

Thank you again.

Jackis
12-08-2005, 11:07 PM
Could you post a screenshot, please??
It will be much clearer for me, what's the problem exactly.

helenw
12-10-2005, 05:48 AM
Originally posted by Jackis:
Could you post a screenshot, please??
It will be much clearer for me, what's the problem exactly.Here it is!
http://www.imagestation.com/album/?id=2116362006

Thanks.

helenw
12-10-2005, 05:58 AM
Originally posted by Jackis:
Could you post a screenshot, please??
It will be much clearer for me, what's the problem exactly.Here it is:
http://www.imagestation.com/album/?id=2116362006

Thanks

Vexator
12-10-2005, 08:07 AM
Oo
whats your graphics card?

ZbuffeR
12-10-2005, 10:15 AM
ok from the image it looks like you have a problem when defining color for each vertex.

I would try to check how is the color array filled vs. how is it read.

helenw
12-10-2005, 04:03 PM
IBM Intel(R) Pentium(R) with Intel(R) 82858/82855 GM/GME Graphics Controller.

The color of each vertex filled mainly depends on the z-value of the vertex. The different z-value will be assigned a different color.

ZbuffeR
12-11-2005, 02:51 AM
It is very unlikely that this is caused by a driver/implementation bug.

When I asked "how" I meant "in which order".
To debug this you may set all vertices colors the same, then a keypress change color on a element in
Color[i][j] array. Then have others key to change i,j, and see how the color changes.

And try displaying in wireframe, to better spot how the triangles are drawn.

Some inspirations on heigthfields :
http://home.planet.nl/~monstrous/terrain.html
And try triangle or quad strips, better performance :
http://jdobry.webpark.cz/opengl/opengl_maximum_performance.html##strips

Interpol8
12-17-2005, 11:34 PM
You have a problem displaying a smooth color gradient - your graphics setting is probably for 256 or 65535 colors, which can cause such effects. Try changing to 24- or 32-bit depth.