开发者

OpenglES - Transparent texture blocking objects behind

开发者 https://www.devze.com 2023-04-02 06:36 出处:网络
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 t

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); glEn开发者_如何学Goable(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

OpenglES - Transparent texture blocking objects behind

front-to-back

OpenglES - Transparent texture blocking objects behind

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号