LUMINANCE give me black screen/texture

I'm trying to render a video from a bayer buffer.

So I create a texture using GL_LUMINANCE/GL_UNSIGNED_BYTE. I apply some shaders onto this texture to generate a RGBA output.

The following call works fine on my PC and does NOT on the target board (iMX6/GLES2) :

glTexImage2D(GL_TEXTURE_2D, 0, textureFormat, m_texture_size.width(), m_texture_size.height(), 0, bufferFormat, GL_UNSIGNED_BYTE, imageData);

On the target board, I have a black texture.

bufferFormat is GL_LUMINANCE. textureFormat is GL_LUMINANCE.

GLES2 implements a smaller subset of OpenGL API : https://www.khronos.org/opengles/sdk/docs/man/xhtml/glTexImage2D.xml

bufferFormat should be equal to the textureFormat. If I try another formats, it works on the PC. On the target board, I get a black screen and some errors reported by glGetError().

Failing other tests

If I try GL_ALPHA, it seems the texture is filled by (0,0,0,1).

If I try GL_RGBA/GL_RGBA (this makes no sense for the application but it checks the HW/API capabilities), I get a non-black texture on the board. Obviously, the image is not what I should expect.

Why does GL_LUMINANCE give me black texture ? How to make this works ?


Guesses:

  • the texture is not a power of two in dimensions and you have not set a compatible wrapping mode;
  • you have not set an appropriate mip mapping mode and the shader is therefore sampling a level other than the one you uploaded.
  • Does setting GL_CLAMP_TO_EDGE * and GL_LINEAR or GL_NEAREST rather than GL_LINEAR_MIPMAP_... resolve the problem?

    Per section 3.8.2 of the ES 2 spec (warning: PDF):

    Calling a sampler from a fragment shader will return (R, G, B, A) = (0,0,0,1) if any of the following conditions are true:

    • A two-dimensional sampler is called, the minification filter is one that requires a mipmap (neither NEAREST nor LINEAR), and the sampler's associated texture object is not complete, as defined in sections 3.7.1 and 3.7.10,

    • A two-dimensional sampler is called, the minification filter is not one that requires a mipmap (either NEAREST nor LINEAR), and either dimension of the level zero array of the associated texture object is not positive.

    • A two-dimensional sampler is called, the corresponding texture image is a non-power-of-two image (as described in the Mipmapping discussion of section 3.7.7), and either the texture wrap mode is not CLAMP_TO_EDGE, or the minification filter is neither NEAREST nor LINEAR.

    • A cube map sampler is called, any of the corresponding texture images are non-power-of-two images, and either the texture wrap mode is not CLAMP_- TO_EDGE, or the minification filter is neither NEAREST nor LINEAR.

    • A cube map sampler is called, and either the corresponding cube map texture image is not cube complete, or TEXTURE_MIN_FILTER is one that requires a mipmap and the texture is not mipmap cube complete.

    ... so my guesses are to check the first and third bullet points.

    链接地址: http://www.djcxy.com/p/33992.html

    上一篇: 使用着色器渲染时,OpenGL纹理全部为黑色

    下一篇: LUMINANCE给我黑屏/纹理