Jump to content
  • Advertisement
Sign in to follow this  
jeroenb

OpenGL Strange behaviour [solved]

This topic is 4617 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

I am working on a project, where I noticed some strange flipping with the default opengl backface culling. On the image you can see what I mean (it is not the clearest picture). This picture contains a lot of boxes (all generated the same way, including per vertex normals). At the center of the image suddenly the front of the box isn't visible anymore but only the backside. During rotation, this 'swap' moves with the camera (I use the fixed pipeline). I have no clue what is going on here :s I have set up opengl just as normal. [Edited by - jeroenb on November 30, 2005 7:28:27 AM]

Share this post


Link to post
Share on other sites
Advertisement
Seams to me like not all the normals are pointing the right way.
The direction (perpendicular to the face of the box) may be right, but the normals have to point to the outside of the boxes.

Share this post


Link to post
Share on other sites
I drawed a red line around the area where the strange behaviour can be seen best. The left box shows the correct faces, while the box to the right of it looks like to use an entirely different winding order. Odd thing is that all those boxes are generated the same, only thing I do is rotating them around the z-axis (the normals are calculated and averaged, thus not perpendicular to the face, after the rotations).

But I will have yet another look at the winding order/normals etc to see what is wrong.

Thanks for the replies!

ps. ignore the red dot, that has nothing to do with the problem :)

Share this post


Link to post
Share on other sites
Quote:
Original post by Kwak
Seams to me like not all the normals are pointing the right way.
The direction (perpendicular to the face of the box) may be right, but the normals have to point to the outside of the boxes.

Normals are not used for face culling, only vertex winding order is.

OP: Thats a slightly odd problem you've got there. :S Are you perhaps doing any mirroring or other fliping via the modelview matrix? Negative scales/mirrors will reverse the winding order and you'll have to change the cull face. Other than that the only thing I can suggest is to turn off face culling to check that that really is the problem.

Share this post


Link to post
Share on other sites
Quote:
Original post by OrangyTang
Normals are not used for face culling, only vertex winding order is.


Yeah - my first guess would be the vertex winding order... make sure the vertices are all orderde counter-clockwise (or clockwise) and set the openGL backface culling state approprately (unforuntately, I can't remember the call off the top of my head...)



Share this post


Link to post
Share on other sites
Certainly looks like the winding order got reversed by mirroring. Particularly those gaps between boxes since they occur right at the position that you transition from drawing correctly to drawing incorrectly. That seems to be the plane of the front face of the structure on the platform to the top right suggesting that might be a coordinate plane of the object.

Share this post


Link to post
Share on other sites
I also forgot to mention that I use a modified JOGL for rendering (I made it use an FBO instead of a PBuffer for offscreen rendering) on the java platform :s.

I quadruple checked the winding order and finally got the idea to do a translate instead of a gluLookAt and that seemed to solve the problem. I do wonder though why it goes wrong when I use gluLookAt.

When I use fill mode with T&L lighting, it still looks completely wrong. I have a point light at position <0,0,0>, thus inside the geometry tunnel. When I look normally the geometry is lit, but when I rotate the geometry 180 degrees it is not. Strange is also that the geometry on the outside is also lit :s.

Share this post


Link to post
Share on other sites
--removed original message--

After player some more with it, the same problems arise with the pbuffer. Also is does not seem to be affected with changing gluLookAt to a translate (luckily). So, I am still at the same point as before. Guess I have to display normals to see how these are.

[Edited by - jeroenb on November 30, 2005 5:45:52 AM]

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!