• FEATURED

View more

View more

View more

Image of the Day Submit

IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Backface culling works totally wrong

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

5 replies to this topic

#1xantier  Members

Posted 21 October 2013 - 01:16 AM

glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);

I have been trying to implement deferred rendering for 2 weeks. But all of the meshes in my test program are culled reversely. The code above should be the correct way to render a model. Every example i looked at draws the objects like that. But here is the result when i use GL_BACK as cull face:

And this is the GL_FRONT:

GL_FRONT should have been the result i expected from GL_BACK. Strange thing is when I set glFrontFace to GL_CW, everything disappears. So this problem is not about winding. I spent all my day on searching information about this. Only thing i found is something about depth buffers. But I can't see any problems in creation. Just because of this problem, I can't correctly do stencil pass for spot light rendering. I enable GL_DEPTH_TEST in geometry pass. This is what i attach to my fbo as depth buffer

glGenRenderbuffers(1, &depthTexture);
glBindRenderbuffer(GL_RENDERBUFFER, depthTexture);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthTexture);


The main question is, what are the possibilities that would cause a reversed backface culling ?

#2C0lumbo  Members

Posted 21 October 2013 - 11:00 AM

Top of the suspect list should be your world/view/projection matrices. It's very easy to mess them up and accidentally make the world go inside out.

#3xantier  Members

Posted 21 October 2013 - 11:40 AM

Top of the suspect list should be your world/view/projection matrices. It's very easy to mess them up and accidentally make the world go inside out.

All of them are glm:: matrices like glm::perspective etc. view matrix is built by glm::quats but i use fixed functionality for model matrix like glTranslate scale etc. and use gl_modelviewmatrix in glsl. if it is really about that, i can change things. but if not, i will have to stop developing my engine because this problem blocks me to advance further.

#4xantier  Members

Posted 21 October 2013 - 05:03 PM

please someone help me. i am totally desperate right now. my faces are inversed and i have tried almost every possible combinations of perspective. just a hint, please.

#5N.I.B.  Members

Posted 21 October 2013 - 11:53 PM

#6xantier  Members

Posted 22 October 2013 - 01:30 AM

i think i am about to solve this. as i posted setting front face to GL_CW was causing everything to disappear. this was because i applied the same rule in drawing full screen quad. so i have solved this part by disabling culling in the last part. so far so good, but the thing is why every mesh i load has clockwise vertex order ? actually this is not a problem since i totally solved the problem.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.