WebGL API
's
EXT_float_blend
extension allows blending and draw buffers with 32-bit floating-point components.
WebGL extensions are available using the
WebGLRenderingContext.getExtension()
method. For more information, see also
使用扩展
在
WebGL 教程
.
可用性:
This extension is available to both,
WebGL1
and
WebGL2
contexts. However, to use it, you need to enable the use of 32-bit floating-point draw buffers by enabling the extension
WEBGL_color_buffer_float
(for WebGL1) or
EXT_color_buffer_float
(for WebGL2). Doing so automatically enables
EXT_float_blend
还。
With this extension enabled, calling
drawArrays()
or
drawElements()
with blending enabled and a draw buffer with 32-bit floating-point components will no longer result in an
INVALID_OPERATION
错误。
On devices that support the
EXT_float_blend
extension, it is automatically, implicitly, enabled when any one or more of
EXT_color_buffer_float
,
OES_texture_float
,或
WEBGL_color_buffer_float
are enabled. This ensures that content written before
EXT_float_blend
was exposed by WebGL will function as expected.
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
| 规范 | 状态 |
|---|---|
| EXT_float_blend | 草案 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
EXT_float_blend
|
Chrome 75 | Edge 79 | Firefox 67 | IE No | Opera No | Safari No | WebView Android No |
Chrome Android
75
|
Firefox Android No | Opera Android No | Safari iOS No | Samsung Internet Android No |
完整支持
不支持
实验。期望将来行为有所改变。
见实现注意事项。
WebGLRenderingContext.getExtension()
EXT_color_buffer_float
WEBGL_color_buffer_float
WebGLRenderingContext.drawArrays()
WebGLRenderingContext.drawElements()
EXT_float_blend
ANGLE_instanced_arrays
EXT_blend_minmax
EXT_color_buffer_half_float
EXT_disjoint_timer_query
EXT_frag_depth
EXT_sRGB
EXT_shader_texture_lod
EXT_texture_filter_anisotropic
OES_element_index_uint
OES_standard_derivatives
OES_texture_float
OES_texture_float_linear
OES_texture_half_float
OES_texture_half_float_linear
OES_vertex_array_object
WEBGL_color_buffer_float
WEBGL_compressed_texture_atc
WEBGL_compressed_texture_etc1
WEBGL_compressed_texture_pvrtc
WEBGL_compressed_texture_s3tc
WEBGL_compressed_texture_s3tc_srgb
WEBGL_debug_renderer_info
WEBGL_debug_shaders
WEBGL_depth_texture
WEBGL_draw_buffers
WEBGL_lose_context
WebGL2RenderingContext
WebGLActiveInfo
WebGLBuffer
WebGLContextEvent
WebGLFramebuffer
WebGLObject
WebGLProgram
WebGLQuery
WebGLRenderbuffer
WebGLRenderingContext
WebGLSampler
WebGLShader
WebGLShaderPrecisionFormat
WebGLSync
WebGLTexture
WebGLTransformFeedback
WebGLUniformLocation
WebGLVertexArrayObject