Transparent texture blocking objects behind

I have some quads that have a texture with transparency and some objects behind these quads. However, these don't seem to be shown. I know it's something about GL_BLEND but I can't manage to make the objects behind show.

I've tried with:

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

but still not working. What I basically have is:

// I paint the object
draw_ac3d_file([actualObject getCurrentObject3d]);

// I paint the quad
paintQuadWithAlphaTexture();

There are two common scenarios that create this situation, and it is difficult to tell which one your program is doing, if either at all.

Draw Order

First, make sure you are drawing your objects in the correct order. You must draw from back-to-front or else the models will not be blended properly.

http://www.opengl.org/wiki/Transparency_Sorting

note as Arne Bergene Fossaa pointed out, front-to-back is the proper way to render objects that are not transparent from a performance stand point. Because of this, most renderers first draw all the models that have no transparency front-to-back, and then they go back and render all models that have transparency back-to-front. This is covered in most 3D-graphic texts out there.

back-to-front

在这里输入图像描述

front-to-back

在这里输入图像描述

image credit to Geoff Leach at RMIT University

Lighting

The second most common issue is improper use of lighting. Normally in this case if you were using the fixed-function pipeline, people would advise you to simply call glDisable(GL_LIGHTING);

Now this should work (if it is the cause at all) but what if you want lighting? Then you would either have to employ custom shaders or set up proper material settings for the models.

A discussion of using the material properties can be found at http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=285889

链接地址: http://www.djcxy.com/p/34004.html

上一篇: 深色不工作正常

下一篇: 透明纹理阻挡对象后面