Alpha与多种纹理融合,留下彩色边框 [英] Alpha blending with multiple textures leaves colored border

查看:105
本文介绍了Alpha与多种纹理融合,留下彩色边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下问题:我有两个纹理,我想将这两个纹理合并为一个新纹理.因此,一种纹理用作背景,另一种将被覆盖.使用glClearColor(1.0,1.0,1.0,0.0)初始化叠加纹理.将对象绘制到纹理上,这些对象确实具有alpha值.

Following problem: I have two textures and I want to combine these two into a new texture. Thus, one texture is used as background, the other will be overlaid. The overlay texture is getting initialized with glClearColor(1.0, 1.0, 1.0, 0.0). Objects are draw onto the texture, these objects do have alpha values.

现在,两个纹理之间的混合会在对象周围留下白色边框.边框来自第二个纹理中的背景颜色是白色的事实,对吗?

Now blending between the two textures leaves a white border around the objects. The border comes from the fact that the background color in the second texture is white, isn't it?

在不必考虑叠加纹理的背景色的情况下如何使用alpha混合?

How can I use alpha blending where I do not have to think about the background color of the overlaying texture?

推荐答案

我自己解决了这个问题,但是非常感谢你们!

I solved the problem myself, but thanks a lot to all of you guys!

问题出在下面:我将glblend(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)组合在一起,由于OpenGL使用了预乘的alpha值,因此无法正常工作.与glblend(GL_ONE,GL_ONE_MINUS_SRC_ALPHA)混合,因为源术语现在将是: 1 * src_alpha * src_color!

The problem was following: to combine both textures I used glblend(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) which does not work due to the fact that OpenGL uses pre-multiplied alpha values. Blending with glblend(GL_ONE, GL_ONE_MINUS_SRC_ALPHA), works as the source term now will be: 1*src_alpha*src_color!

这篇关于Alpha与多种纹理融合,留下彩色边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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