The WebGLRenderingContext.uniform[1234][fi][v]() methods of the WebGL API specify values of uniform variables.
void gl.uniform1f(location, v0); void gl.uniform1fv(location, value); void gl.uniform1i(location, v0); void gl.uniform1iv(location, value); void gl.uniform2f(location, v0, v1); void gl.uniform2fv(location, value); void gl.uniform2i(location, v0, v1); void gl.uniform2iv(location, value); void gl.uniform3f(location, v0, v1, v2); void gl.uniform3fv(location, value); void gl.uniform3i(location, v0, v1, v2); void gl.uniform3iv(location, value); void gl.uniform4f(location, v0, v1, v2, v3); void gl.uniform4fv(location, value); void gl.uniform4i(location, v0, v1, v2, v3); void gl.uniform4iv(location, value);
WebGLUniformLocation object containing the location of the uniform attribute to modify.value, v0, v1, v2, v3Number for floating point values (methods with "f").Float32Array for floating point vector methods (methods with "fv").Number for integer values (methods with "i").int32Array for integer vector methods (methods with "iv").None.
gl.uniform1f(u_alpha, 0.8);
| Specification | Status | Comment |
|---|---|---|
| WebGL 1.0 The definition of 'uniform' in that specification. | Recommendation | Initial definition. |
| OpenGL ES 2.0 The definition of 'glUniform' in that specification. | Standard | Man page of the OpenGL API. |
| Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | Servo |
|---|---|---|---|---|---|---|---|
| WebGLRenderingContext.uniform1f | 9 | 12 | 4.0 | 11 | 12 | 5.1 | No support |
| WebGLRenderingContext.uniform1fv | 9 | 12 | 4.0 | 11 | 12 | 5.1 | No support |
| WebGLRenderingContext.uniform1i | 9 | 12 | 4.0 | 11 | 12 | 5.1 | No support |
| WebGLRenderingContext.uniform1iv | 9 | 12 | 4.0 | 11 | 12 | 5.1 | No support |
| WebGLRenderingContext.uniform2f | 9 | 12 | 4.0 | 11 | 12 | 5.1 | No support |
| WebGLRenderingContext.uniform2fv | 9 | 12 | 4.0 | 11 | 12 | 5.1 | No support |
| WebGLRenderingContext.uniform2i | 9 | 12 | 4.0 | 11 | 12 | 5.1 | No support |
| WebGLRenderingContext.uniform2iv | 9 | 12 | 4.0 | 11 | 12 | 5.1 | No support |
| WebGLRenderingContext.uniform3f | 9 | 12 | 4.0 | 11 | 12 | 5.1 | No support |
| WebGLRenderingContext.uniform3fv | 9 | 12 | 4.0 | 11 | 12 | 5.1 | No support |
| WebGLRenderingContext.uniform3i | 9 | 12 | 4.0 | 11 | 12 | 5.1 | No support |
| WebGLRenderingContext.uniform3iv | 9 | 12 | 4.0 | 11 | 12 | 5.1 | No support |
| WebGLRenderingContext.uniform4f | 9 | 12 | 4.0 | 11 | 12 | 5.1 | No support |
| WebGLRenderingContext.uniform4fv | 9 | 12 | 4.0 | 11 | 12 | 5.1 | No support |
| WebGLRenderingContext.uniform4i | 9 | 12 | 4.0 | 11 | 12 | 5.1 | No support |
| WebGLRenderingContext.uniform4iv | 9 | 12 | 4.0 | 11 | 12 | 5.1 | No support |
| Feature | Android | Chrome for Android | Edge Mobile | Firefox for Android | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|---|
| WebGLRenderingContext.uniform1f | (Yes) | 25 | (Yes) | 4.0 | 11 | 12 | 8.1 |
| WebGLRenderingContext.uniform1fv | (Yes) | 25 | (Yes) | 4.0 | 11 | 12 | 8.1 |
| WebGLRenderingContext.uniform1i | (Yes) | 25 | (Yes) | 4.0 | 11 | 12 | 8.1 |
| WebGLRenderingContext.uniform1iv | (Yes) | 25 | (Yes) | 4.0 | 11 | 12 | 8.1 |
| WebGLRenderingContext.uniform2f | (Yes) | 25 | (Yes) | 4.0 | 11 | 12 | 8.1 |
| WebGLRenderingContext.uniform2fv | (Yes) | 25 | (Yes) | 4.0 | 11 | 12 | 8.1 |
| WebGLRenderingContext.uniform2i | (Yes) | 25 | (Yes) | 4.0 | 11 | 12 | 8.1 |
| WebGLRenderingContext.uniform2iv | (Yes) | 25 | (Yes) | 4.0 | 11 | 12 | 8.1 |
| WebGLRenderingContext.uniform3f | (Yes) | 25 | (Yes) | 4.0 | 11 | 12 | 8.1 |
| WebGLRenderingContext.uniform3fv | (Yes) | 25 | (Yes) | 4.0 | 11 | 12 | 8.1 |
| WebGLRenderingContext.uniform3i | (Yes) | 25 | (Yes) | 4.0 | 11 | 12 | 8.1 |
| WebGLRenderingContext.uniform3iv | (Yes) | 25 | (Yes) | 4.0 | 11 | 12 | 8.1 |
| WebGLRenderingContext.uniform4f | (Yes) | 25 | (Yes) | 4.0 | 11 | 12 | 8.1 |
| WebGLRenderingContext.uniform4fv | (Yes) | 25 | (Yes) | 4.0 | 11 | 12 | 8.1 |
| WebGLRenderingContext.uniform4i | (Yes) | 25 | (Yes) | 4.0 | 11 | 12 | 8.1 |
| WebGLRenderingContext.uniform4iv | (Yes) | 25 | (Yes) | 4.0 | 11 | 12 | 8.1 |
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/uniform