【问题标题】:Android Emulator Color Banding with Hardware Acceleration OpenGL ES 3.0具有硬件加速 OpenGL ES 3.0 的 Android 模拟器颜色条带
【发布时间】:2018-04-11 13:39:31
【问题描述】:

只有在我的 Android 模拟器上使用硬件加速渲染时,我似乎在色谱的低端失去了相当大的精度。

使用硬件加速(ANGLE D3D11 或桌面原生 OpenGL):

没有硬件加速(SwiftShader):

条带显然是非线性的,并且在尝试渲染平滑光照时变得非常突兀。

我已设置 getWindow().setFormat(PixelFormat.RGBA_8888); 并在我的片段着色器中使用 precision highp float;。

我们使用的是 Android Studio 3.1.1、Windows 10、OpenGL ES 3.0。

*编辑:这是一个并排增加亮度和对比度

【问题讨论】:

  • 更新:这花了我很长时间才发现,但这个问题只在使用外接显示器(标准 hdmi)时出现。简单地使用笔记本电脑的屏幕时,没有色带。最奇怪的是上面的图片是截图,没有任何显示器。出于某种原因,简单地将外部 hdmi 显示器作为主显示器会与模拟器混淆。

标签: android opengl-es android-emulator hardware-acceleration opengl-es-3.0


【解决方案1】:

这看起来像是 sRGB 颜色在某个时候以线性 8 位格式存储,然后被转换回 sRGB。这将导致您正在观察的那种低亮度不精确性。

调用eglCreateWindowSurface时,尝试在attrib_list参数中传递{EGL_COLORSPACE_KHR, EGL_COLORSPACE_SRGB_KHR, EGL_NONE}。如果您使用GLSurfaceView,这将需要实现EGLWindowSurfaceFactory 并调用setEGLWindowSurfaceFactory。这需要存在 EGL_KHR_gl_colorspace 扩展。

public class EGLFactory implements GLSurfaceView.EGLWindowSurfaceFactory {
  private static final int EGL_GL_COLORSPACE_KHR = 0x309D;
  private static final int EGL_GL_COLORSPACE_SRGB_KHR = 0x3089;
  public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display,
                                        EGLConfig config, Object nativeWindow) {
    final int[] attribList = {
      EGL_GL_COLORSPACE_KHR,
      EGL_GL_COLORSPACE_SRGB_KHR,
      EGL10.EGL_NONE
    };
    return egl.eglCreateWindowSurface(display, config, nativeWindow, attribList);
  }
  public void destroySurface(EGL10 egl, EGLDisplay display, EGLSurface surface) {
    egl.eglDestroySurface(display, surface);
  }
}

如果您想了解更多关于 sRGB 的信息,这里有一篇好文章:http://blog.johnnovak.net/2016/09/21/what-every-coder-should-know-about-gamma/

【讨论】:

    猜你喜欢
    • 2014-09-12
    • 1970-01-01
    • 2012-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-15
    • 2014-07-27
    • 1970-01-01
    相关资源
    最近更新 更多