简体   繁体   English

在某些Android设备上具有OpenGL ES 2.0的添加混合伪像

[英]Additive blending artefacts with OpenGL ES 2.0 on some Android devices

I am developing a cross-platform game for Android and iOS. 我正在为Android和iOS开发跨平台游戏。 For a couple of billboard-like objects I am using additive blending( glBlend(GL_ONE, GL_ONE) ) with black background textures. 对于几个类似广告牌的对象,我正在使用具有黑色背景纹理的加法混合( glBlend(GL_ONE, GL_ONE) )。 The rendered objects look fine(ie the black pixels from the texture look totally transparent) almost everywhere. 几乎在任何地方,渲染的对象看起来都很好(即,纹理中的黑色像素看起来完全透明)。 However on two different Android devices with Adreno GPU's(one Nexus 4 and the other one Sony Xperia Go) I have artefacts like this: 但是,在带有Adreno GPU的两个不同的Android设备(一个Nexus 4和另一个Sony Xperia Go)上,我有这样的伪像: 在此处输入图片说明

As it is visible with the hamburger icon, the background color bleeds into the rendered quad. 如通过汉堡包图标可见,背景色渗入渲染的四边形。 I am assuming it is the background color bleeding because the effect is not visible when the billboard quads are directly in front of the background. 我假设这是背景色渗色,因为当广告牌四边形位于背景正前方时,效果不明显。 To make things weirder, the effect is not visible when I take a screenshot from the device, so I have to take a picture of the screen with another camera. 为了使事情变得更怪异,当我从设备上截取屏幕截图时,效果是不可见的,因此我必须使用另一台摄像机拍摄屏幕图像。 I also noticed that the artefacts disappear when I enable Disable HW Overlays from the Android developer settings. 我还注意到,当我从Android开发人员设置中启用“ Disable HW Overlays时,伪像消失了。 Artefacts disappear also when I have another transparent window on the screen, such as the volume slider when I press the volume buttons. 当我在屏幕上还有另一个透明窗口时,例如按音量按钮时的音量滑块,伪影也会消失。

When I am rendering my scene, I first render opaque objects in the first pass and then in the second pass I render my transparent billboards with glBlend(GL_ONE, GL_ONE) and with disabling depth-write. 渲染场景时,首先在第一遍渲染不透明的对象,然后在第二遍渲染,使用glBlend(GL_ONE, GL_ONE)并禁用深度写入来渲染我的透明广告牌。

Just for the record, it took me a long while to find the culprit but finally I found out the reason. 仅作记录,我花了很长时间才找到罪魁祸首,但最终我找到了原因。 It turns out that not all my "supposedly" opaque objects were really opaque(ie they had alpha value < 1.0). 事实证明,并非我所有“应该”的不透明对象都是真正不透明的(即它们的alpha值<1.0)。

Because of this, on the devices that use hardware overlays the artefacts become visible while on devices with single hardware overlay it looks fine. 因此,在使用硬件覆盖的设备上,伪像变得可见,而在具有单个硬件覆盖的设备上,则看起来不错。 I'm not 100% sure but the effect that when I have an overlay window such as the system volume bar on top of my application window approves this has something to do with overlays. 我不是100%确信,但是当我在应用程序窗口顶部有一个叠加窗口(例如系统音量栏)批准时,其效果与叠加有关。

After I made sure all my opaque objects are really opaque issues disappeared. 确定所有不透明对象确实是不透明后,问题消失了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM