WebGLShaderPrecisionFormat: precision 属性

Baseline 已广泛支持

此特性已相当成熟,可在许多设备和浏览器版本上使用。自 ⁨2015 年 7 月⁩以来,各浏览器均已提供此特性。

注意:此功能在 Web Workers 中可用。

只读的 WebGLShaderPrecisionFormat.precision 属性返回可表示的精度位数。

对于整数格式,此值始终为 0。

示例

js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");

gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT).precision; // 23
gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.LOW_INT).precision; // 0

规范

规范
WebGL 规范
# DOM-WebGLShaderPrecisionFormat-precision

浏览器兼容性

另见