Drawing State
Uniform Transform
A shift uniform and a scale uniform transform the triangle before the shader writes clip-space positions.
Program
Uniforms are shared values for a draw call. Unlike attributes, a uniform has one value for all vertices in that draw.
uniform_transform.html
<canvas id="stage" width="360" height="210"></canvas>
<script>
const vertices = new Float32Array([
0.0, 0.62, 0.94, 0.35, 0.28,
-0.62, -0.52, 0.22, 0.82, 0.55,
0.62, -0.52, 0.29, 0.55, 0.96
]);
const uShift = gl.getUniformLocation(program, "uShift");
const uScale = gl.getUniformLocation(program, "uScale");
gl.uniform2f(uShift, 0.30, 0.02);
gl.uniform1f(uScale, 0.72);
gl.drawArrays(gl.TRIANGLES, 0, 3);
</script>
uniform
A uniform is one shared shader input value for a draw call.
clip space
Clip-space x and y coordinates range from -1 to 1 before viewport mapping.