Reputation: 10530
I am very new to OpenGL ES, and I am trying to play around with some shaders. My question is, when I initialize some values in a matrix, but not all, what is the default values? I assumed it would be zero, however I am using the following code in my fragment shader:
highp vec4 c = texture2D(inputImageTexture, textureCoordinate) ;
highp mat4 m;
m[0] = vec4(1.0);
m[1] = vec4(1.0);
m[2] = vec4(1.0);
c = m * c;
gl_FragColor = c;
Obviously, the last column of the array has not been initialized. Just to make sure all the values in the last column of m are zero, I added the line m[3] = vec4(0.0);
and I got a different result. I've tried setting the fourth column to 255.0
and 1.0
, but each time I got a different result then when I didn't initialize the column. Does anyone know what the default value is?
Upvotes: 0
Views: 85
Reputation: 13202
The default value is "undefined", just like in C. In other words it can be any arbitrary value that was in that memory cell before the matrix was allocated as allocation does not clear or initialize the cell in any other way. You should always initialize all elements of the matrix before using it in one of the standard way.
Upvotes: 4