Wondering if it's possible to pass a large array into a WebGL shader, like this:
// array here
uniform vec4[huge] mydynamicarray;
void main() {
// iterate through the array here to perform processing on it,
// then write value to gl_Position
gl_Position = ...;
}
Then it would be populated like this:
gl.uniform4fv(myarrayloc, myarray)
I have seen many examples of how to pass in values like this, such as:
gl.uniform4fv(offsetLoc, [1, 0, 0, 0])
But I have not seen if it's possible to pass in a very large, dynamically sized array.
The reason to do this would be you could process 2 arrays:
- One that is the vector array running in parallel in WebGL.
- One that is the uniform array that you can iterate through for each vector.