• Advertisement
Sign in to follow this  

nasty colors with GL_SMOOTH

This topic is 3630 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. I get strange pieces of nasty colors when I use GL_SMOOTH. They dissapear with GL_FLAT. Please, take a look to this image: http://www.aule3d.com/album/img.jpg Can anybody help me? Thanks a lot.

Share this post


Link to post
Share on other sites
Advertisement
It is hard to tell if the color are on the triangles or in screen space. Need more details.

Share this post


Link to post
Share on other sites
Hi, V-man

There's a hope to the world with people that gets interested in others's problems. Thank you for that.

Symptoms:

1. Nasty Triangles become smaller and in less quantity when rendering at a bigger size.
2. They are very often in terrain areas paralell to view line, for example, in the top of the mountains.
3. It doesn't depend on the presence of a texture (they appear with both glEnable(GL_TEXTURE) and glDisable(GL_TEXTURE). And in any conditions of light and color.
3. They often dissappear when hiding (not rendering) terrain beyond and near to the area where they before appeared.
4. Closer areas to the view point never have nasty triangles.

For me, it's something related to the z-buffer. This is the related code:
glFrontFace(GL_CCW);
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
glDepthFunc(GL_LESS);
glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);

And
glClearColor(backColor.R, backColor.G, backColor.B, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

And
glShadeModel(GL_SMOOTH);
glEnable(GL_POLYGON_SMOOTH);

And
gluPerspective(aperturaV, wRenderA / hRenderA, max(dMin, 10), dMax);
where dMin and dMax are the minimum and maximum distances from the observer.

A very important symptom is that more (much more) bad triangles appear when dMax is big.

You have a new image in the same link, showing triangles closer.

Thank you for your interest



Share this post


Link to post
Share on other sites
Quote:
Original post by jcurru

For me, it's something related to the z-buffer. This is the related code:
...
glDepthFunc(GL_LESS);
...
A very important symptom is that more (much more) bad triangles appear when dMax is big.


You might try glDepthFunc(GL_LEQUAL); instead?

Share this post


Link to post
Share on other sites
Try to take away this line

glEnable(GL_NORMALIZE);

And see what would happen.

Share this post


Link to post
Share on other sites
I agree it sure looks like a z-buffer issue. Almost as if it isn't being cleared!
Perhaps try some manual values, like 1.0 and 10000.0 as a really close nearClip will effect the float accuracy a lot.

Share this post


Link to post
Share on other sites
Looks more like something has gotten corrupted rather than a depth precision issue. Try to find out which triangle has the problem and render only those ones.
But the first thing I would do is run the program on another system with another video card.

Share this post


Link to post
Share on other sites
Hello again, V-man and jezham.

The image becomes PERFECT (but different) disabling GL_SMOOTH. So, I think it is not related with clearing the z-buffer. And I have tested tmy program with several videro cards, and never works. So It IS a software (solvable) problem. In the other hand, those little nasty triangles do not match the shape of the triangles rendered in that areas. So it is not a geometry problem.

The float accuracy could be the problem. But it would really ashtonish me, because having the near plane at 4000 and the far plane at 8000, that wouldn't happen in OpenGL. And the problem only appears when GL_SMOOTH is on!. What is the relation between the z-buffer and smoothing?

Have you ever seen something like this?
Thanks for your support.

Share this post


Link to post
Share on other sites
Just a guess, but try disabling GL_POLYGON_SMOOTH. You will probably never need this and it will not give the desired resulst anyway. You would normally use Multisampling for AA.

Share this post


Link to post
Share on other sites
Trenki, YOU DID IT!!!!!!!!!!!!!
I CAN NOT BELIEVE IT!!!!!!!!!!!!

The nasty triangles completely dissapeared. I just removed the GL_POLYGON_SMOOTH, unhopefully whatched to the screen and... it happened!!. And render is now as fast as in GL_FLAT mode. This means hundreds of hours saved, and my deepest gratitude for you and the other guys who tried to help me. Ten years later... my program is now finished.

THANK YOU IS NOT ENOUGH.
But I don't know what else can I say.
Maybe in spanish (I live in Spain)

Gracias, tío, esto significa mucho para mi.
Si vienes por mi tierra, escríbeme y comerás en el mejor restaurante de Madrid.

Yeaaaahhhhhh!!!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement