0
\$\begingroup\$

I got a problem with my VBO. When having textures. The far blocks overlay the near ones.

I tried editing the alpha, depth buffer, the VBO byte allocation. Nothing works for me...

The FAR plane is overlapping the NEAR plane.

    //Alpha
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glEnable(GL_CULL_FACE);
glDisable(GL_MULTISAMPLE);

glDepthMask(GL_TRUE);

Problem![][1]

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

It's not clear from your image if that is a single plane and the far faces are overlaying the near ones, or if you are rendering several objects and the far ones overlay the near ones.

If it's the second case, your problem is that you need to either sort the itens back to front or disable the depth test. If you render them out of order, OpenGL will discard any fragment that is drawn behind a fragment closer to the camera. If you disable the depth test, everything will be drawn, but solid objects won't be tested either. Sorting is probably the best alternative if you plan on mixing solid/transparent itens. But you will need to keep them on different lists. Sort transparent ones back to front and solid ones front to back.

There are other issues with transparency and rendering. Some cases where transparent objects intersect may give you the wrong results. Depth Peeling is a technique that can be used to avoid that (Though I never need it myself, so I may be wrong here)

\$\endgroup\$
2
  • \$\begingroup\$ Well, the problem is that none of the shows objects are transparent. For some reason the objects behind the others are visible. They like... Go through the front ones. Eg: [Block1] [Block2] | (Camera) <- Can see both of the objects, the one behind block2 'overlays' a part of block2. I tried disabling depth test and such, but it didnt work. Edit: The far ones overlap the near ones partly. So not complete. \$\endgroup\$ Commented Aug 9, 2014 at 17:23
  • \$\begingroup\$ I fixed it. The problem was that my Camera's projection matrix and my Shader's projection matrix were not the same. \$\endgroup\$ Commented Aug 9, 2014 at 19:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .