Page 1 of 1

Color flickering on meshes when in OPENGL

Posted: Sun Jan 20, 2008 6:00 pm
by GrigoriosSokratis
Hi, I have this 3ds mesh as the terrain of my project (I did it so because the results are much better performance wise as well as in quality).

Now, my problem is that when rendering it under OpenGL it has this annoying color flickering when moving the camera direction, while when rendered under Direct3D it works, quite fine with no flickers at all.

I've attached two screenshots showing how it looks when moving the camera just a little bit to the right. You'll see that the whole mesh darkens significantly.

Image

Image

It also seems that the

nody->setMaterialFlag(video::EMF_LIGHTING, true);

flag doesn't make any difference, since even when there's no light at all the mesh remains completely iluminated as if it was receiving light from an omnidirectional like source.

Any help appreciated,
Thanks.

Posted: Sun Jan 20, 2008 11:38 pm
by twilight17
(this is a guess) but does it matter if you have a light in the 3ds scene? and if so, did you?

Posted: Mon Jan 21, 2008 12:16 am
by hybrid
Do you scale the mesh after loading? Could be a problem with normals (at least for the lit version).

Posted: Mon Jan 21, 2008 1:35 am
by GrigoriosSokratis
No, there aren't any original lights imported along with the 3ds object.

As for being scaled, as a matter of fact, yes I've scaled it (but this is how it must be done as we are talking about a rendered area of about 40 sq kms).

Posted: Mon Jan 21, 2008 7:07 am
by hybrid
You have to renormalize normals after scaling, otherwise lighting will fail. Also, when scaling too large you will notice that the faces will become pretty huge. Due to the per-face shading you can spot pretty bad color changes and seams. You can increase the triangle count in order to overcome this problem (the terrain scene node uses dynamic LOD for this reason, otherwise you will get too many faces in the very far background). Or you use per-pixel shading with phong shaders or similar techniques.