简体   繁体   中英

OpenGL 3.3: How implement uncompressing texture data before passing to vertex and fragment shader

I am pulling 12 bit data from a camera which is packed, so that 3 bytes define 2 consecutive pixels.

Is there a way to decompress these into two 16 bit values before passing the data to the vertex shader for further processing?

This is the idea:

  1. Copy texture to PBO (Pixel Buffer Object):

  2. Now this PBO can be used by compute shader, where decompression can be performed.

  3. The result PBO can be copied back to texture.

To make this on gpu you need direct access to buffers elements, which opengl 3.3 doesn't have. So you can do that only with 310es, 430 versions or vulkan.

Also it is possible to decompress image with cuda or OpenCL. In this case step 2 should be replaced by cuda or OpenCL routine.

The other idea:

You can load texture as one component texture, and in fragment shader use texelFetch. In this case you will get the direct access to bytes of texture buffer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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