Does WebGL support color formats with more than 32bit?

我的未来我决定 提交于 2019-12-13 07:35:47

问题


I can't seem to find any texture format with more than 32 bit (GL.RGBA). Is this not supported by WebGL ?


回答1:


By 32bit you mean where each element is 32bit itself or each element is 8bits and in sum they are 32 bits (8 bits of red, 8 bits of green, 8 bits of blue, 8 bits of alpha)?

In any case there are extensions for 32bit float formats in WebGL so 32bits of red, 32bits of green, 32bits of blue, 32bits of alpha which is 128bit texture format.

Those extensions are

  • OES_texture_float. Let's you create 32bits per channel floating point textures
  • OES_texture_half_float Let's you create 16bits per channel half floating point textures
  • OES_texture_float_linear. Let's you set filtering to something other than gl.NEAREST when using a floating point texture
  • OES_texture_half_float_linear. Let's you set filtering to something other than gl.NEAREST when using a half floating point texture

To use any of these you have to enable each one as in

var ext = gl.getExtension("OES_texture_float");
if (!ext) {
   alertNoFloatSupportOrFallbackToOtherOption();
}

Pretty much all desktop GPUs support all 4. Mobile devices usually only support the half formats and sometimes don't support filtering.

Also most mobile devices do not allow rendering to float or half float textures where as desktops do. To check if they do, create a texture in the desired format, attach it to a framebuffer and the call gl.checkFramebufferStatus. If it returns gl.FRAMEBUFFER_COMPLETE then you can render to the texture. Otherwise you can only use it as a source.



来源:https://stackoverflow.com/questions/29658210/does-webgl-support-color-formats-with-more-than-32bit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!