EXT_float_blend

WebGL API的 EXT_float_blend 扩展允许使用32位浮点数组件来混合和绘制缓冲区。

查询扩展是否存在,采用方法:WebGLRenderingContext.getExtension()。更多信息, 参考WebGL tutorial中的Using Extensions

可用性:  该扩展在 WebGL1WebGL2 上下文中均存在。但是,要使用它,你需要启用对32位浮点绘制缓冲区的使用WEBGL_color_buffer_float (for WebGL1) 或 EXT_color_buffer_float (for WebGL2)。通过启用32位浮点缓冲区扩展,将自动启用EXT_float_blend。

该组件启用后, 使用32位浮点数混合方式绘制,调用 drawArrays()drawElements()时,将不再产生INVALID_OPERATION 异常。

使用说明

在支持EXT_float_blend扩展的设备上, 当以下几种有一种或几种扩展启用时EXT_color_buffer_float, OES_texture_float, 或 WEBGL_color_buffer_float,该扩展将会自动、隐式的启用。 这确保了在该扩展定义之前的内容也都能够按照预期正确执行。

例子

const gl = canvas.getContext('webgl2');

// enable necessary extensions
gl.getExtension('EXT_color_buffer_float');
gl.getExtension('EXT_float_blend');

const tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);

// use floating point format
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, 1, 1, 0, gl.RGBA, gl.FLOAT, null);

const fb = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0);

// enable blending
gl.enable(gl.BLEND);

gl.drawArrays(gl.POINTS, 0, 1);
// won't throw gl.INVALID_OPERATION with the extension enabled

说明书

Specification Status
EXT_float_blend Draft

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
EXT_float_blend
Experimental
Chrome Full support 75Edge No support NoFirefox Full support 67IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android Full support 75
Notes
Full support 75
Notes
Notes Until Chrome 77, this extension was unavailable on several Android devices powered by GLES 3.2. See bug 964208.
Firefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android No support No

Legend

Full support  
Full support
No support  
No support
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
See implementation notes.
See implementation notes.

其它参考