当纹理重叠时如何使背景透明?
我有一个具有黑色背景的纹理,我想将其设置为透明。问题是,当我使用该纹理在另一个对象前面绘制该纹理时,黑色背景仍然显示。如何使纹理透明,即使它重叠?
I have a texture that has a black background which I want to make transparent. The problem is that when I draw this texture in front of another object using the texture, the black background still shows. How do I make my texture transparent, even when it overlaps?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在这里假设 3 件事
当 OpenGL 为绘制四边形/三角形时,它也会绘制到深度缓冲区,无论该像素是否透明(或部分透明)。
我的猜测是,您首先绘制这个透明形状,然后最后绘制其后面的对象。 OpenGL 不会绘制后面的对象,深度缓冲区已经表明您已经在其前面绘制了某些内容,因此您实际上是透过第一个和第二个对象看到“天空”。
所以如果透明物体总是在前面,那么最后绘制它。否则它会变得相当复杂(谷歌“深度排序”),
当我回家时我会尝试添加更多细节。
I'm assuming 3 things here
When OpenGL is drawing your Quad/Triangle, it is also drawing to the depth buffer, regardless of whether or not that pixel is transparent (or partially transparent).
My guess is that you're drawing this transparent shape first, and then the object behind it last. OpenGL wont draw the back object where the depth buffer already says you've drawn something in front of it, so you're really seeing through the first and second object, out into the 'sky'.
so if the transparent object is always in front, draw it last. Otherwise it gets pretty complicated (Google "depth sorting")
I'll try an add more detail to this when I get home.