Yevhen
Yevhen

Reputation: 1965

Rendering transparent 3d shape(quad) with equal z-order

I render two quads with OpenGL with equal z. When I have DEPTH enabled I get following image, but when it is off I get what I need one fruit over another. Is it possible to draw quads with equal z, as I want? My OGL settings:

glEnable(GL_BLEND); glEnable(GL_ALPHA_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

my trouble

EDIT sorry I forgot to mention that left topmost quad I call to render first, and I use orthographic

EDIT +1 when I render quads with different Z I get the same image, how to fix it?

Upvotes: 0

Views: 187

Answers (2)

Yevhen
Yevhen

Reputation: 1965

I experimented and saw that I have same problem when I render cube, so the problem was because of vertices ordering, and possibly backface culling parameters.

Upvotes: 0

Pubby
Pubby

Reputation: 53047

The z-buffer doesn't care about transparency and so you have to sort the drawing order of your quads by their approximate depth.

I would change their depth to be different (you can use an orthographic projection to have them appear the same size) and then draw the further quad first.

Also, it is never a good idea to draw two polygons at the same depth even without transparency because of z-fighting.

Upvotes: 4

Related Questions