Hi, forum.
I'm trying to understand how to send an array to a shader frag.
I want to send float array to frag. but i couldn't.
I wrote follows In the ofApp:
void ofApp::draw(){
myArray[0] = 1.0;
myArray[1] = 0.0;
myArray[2] = 0.0;
printf("%f \n", myArray[0]); // 1.0
shader.load("","shader.frag");
shader.begin();
shader.setUniform1fv("uniArray", myArray, 3);
ofRect(0,0,ofGetWidth(), ofGetHeight());
shader.end();
}
in the frag.
uniform float uniArray[3];
void main() {
gl_FragColor = vec4(uniArray[0], uniArray[1], uniArray[2], 1.0); // uniArray[0] seems not to be 1.0;
}
I expected red rect is drawn. but it was black.
When I use setUniform3f and an vec3 instead of an array, A red rect is drawn.
What went wrong?
thanks.