Question

When compiling this WebGL fragment shader in both Chrome 22 and Firefox 15:

precision mediump float;
uniform vec2 u_resolution;
uniform sampler2D u_tex;
void main() {
    vec2 texCoord = gl_FragCoord.xy / u_resolution;
    vec4 floatColor = texture2D(u_tex, texCoord);
    mat3 outerMat = outerProduct(floatColor.rgb,floatColor.rgb);
    gl_FragColor = vec4(outerMat[0], 1);  
}

I'm getting this error:

ERROR: 0:8: 'outerProduct' : no matching overloaded function found
ERROR: 0:8: '=' :  cannot convert from 'const mediump float' to '3X3 matrix of float'

The OpenGL ES 2.0 GLSL spec indicates that mat3 outerProduct(vec3,vec3) is supported, and the WebGL spec says that it accepts ES shaders, so I'm not sure what's going wrong. Is outerProduct not supported in WebGL fragment shaders, or am I doing something wrong?

Was it helpful?

Solution

There is no outerProduct function in OpenGL ES 2.0 GLSL. Where did you read that there was? (or am I missing it?)

Here's the spec http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf

OTHER TIPS

Try mat3 outerMat = outerProduct(vec3(floatColor.rgb),vec3(floatColor.rgb));

To expand, maybe giving it an explicit type is better than using .rgb.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top