在OpenGL中渲染透明对象 [英] Rendering transparent objects in OpenGL

查看:69
本文介绍了在OpenGL中渲染透明对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用opengl渲染某些3d对象.要求是我需要隐藏在另一个透明对象之后的所有透明对象.所有三角形都在单个三角形缓冲区中,并且将立即绘制.请给点灯.

Iam trying to render some 3d objects using opengl. Requirement is that i need to hide all the transparent objects which are z-behind another transparent object. All the triangles are in single triangle buffer and will be drawn at once. Please throw some light.

推荐答案

尝试使用glDepthMask():

Try using glDepthMask():

    //Render all opaque objects
    glDepthMask(false); //disable z-testing
    //Render all transparent objects*
    glDepthMask(true); //enable z-testing (for the next frame)

*从技术上讲,您应该从后到前渲染透明对象,但如果不这样做,则很少引起注意.

*Technically, you should render the transparent objects from back to front, but it is rarely noticeable if you don't.

这篇关于在OpenGL中渲染透明对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆