PDA

View Full Version : Cant find uniform variable in GLSL in Android



TpoM6oH
03-15-2013, 05:33 AM
I have a fragment shader:

varying highp vec2 textureCoordinate;

uniform sampler2D inputImageTexture;

uniform lowp vec4 mask[360000];
uniform lowp vec4 frame[360000];

void main()
{
float frameAlpha = frame[10].a;
if (frameAlpha != 0) {
gl_FragColor = vec4(mask[10].r, mask[10].g, mask[10].b, frameAlpha);
}
else {
lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
gl_FragColor = vec4(textureColor.rgb, textureColor.w);
};
}

I want to set the arrays from outside the shader. I try to do this:

int maskArrayLocation = GLES20.glGetUniformLocation(getProgram(), "mask");
int frameArrayLocation = GLES20.glGetUniformLocation(getProgram(), "frame");

But both functions return me -1. Where is the problem?

Alfonse Reinheart
03-15-2013, 08:11 AM
You asked for over 300,000 array entries. In OpenGL ES. I'd be surprised if your shader compiled at all let along successfully linked and gave you valid uniform locations.

I'd like to see some evidence that you had a successful compile/link. You are checking these, aren't you?