uniform <type> <name>[<count>];
#define SHAPE_COUNT 16
uniform vec2 centers[SHAPE_COUNT];
uniform float sizes[SHAPE_COUNT];
gl.uniform[1234][fi]
.
centers
uniform are
centers[0]
, centers[1]
, centers[2]
, ...,
centers[15]
.centers
unform:
for(var i=0; i<shapeCount; i++) {
var centerUniformName = "centers[" + i + "]";
var centerLocation = gl.getUniformLocation(program, centerUniformName);
gl.uniform2f(centerLocation, centerX[i], centerY[i]);
}
gl.uniform[1234][fi]v
gl.uniform
allows you to pass an array to the GPU.sizes
uniforms:
var sizes = [];
for(var i=0; i<shapeCount; i++) {
sizes.push(0.01 + Math.random()*0.09);
}
:
:
:
var sizeLocation = gl.getUniformLocation(program, "sizes[0]");
gl.uniform1fv(sizeLocation, sizes);