Shader compiles and attaches to program, but does not link


I have a shader that compiles and also attaches to the shader program, but it does not link.

gl.attachShader(shaderProgram, fragmentShader);

console.log("shaders attached: " + gl.getProgramParameter(shaderProgram, gl.ATTACHED_SHADERS));


console.log("Program Link status: " + gl.getProgramParameter(shaderProgram, gl.LINK_STATUS));

if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
console.log(“Could not initialize shaders”);

I get a value 1 for gl.ATTACHED_SHADERS, but validate, link, or use fail. The only log I get is “Program has not been successfully linked”; not particularly useful.

Has anyone seen this before, and can give me pointers. Is there a better way to debug and get some more useful information to see what’s really going on.


Here’s the shader itself. Am I hitting some limits for in/out to shaders?

#ifdef GL_ES
precision highp float;

const float EV_CONSTANT=3.0;
const float MIDDLE_GRAY=0.18;
const vec3 srgbLuminance = vec3(0.2126, 0.7152, 0.0722);

uniform float exposure;
uniform float highlights;
uniform float midtones;
uniform float shadows;
uniform float whitepoint;
uniform float saturation;

uniform sampler2D texture_binary;
varying vec2 vTexCoord;

void main(void) {
vec3 color = texture2D(texture_binary, vTexCoord).rgb;

float fLumScale = MIDDLE_GRAY / pow((exposure - EV_CONSTANT), 2.0);
float omSat = 1.0 - saturation;

float invGamma = 1.0 / (2.2*midtones);
float crunch = 2.0*shadows + 1.0;

color = fLumScale*color;
vec3 colorHighs;
colorHighs = highlights*color;

color[0] = (color[0] * (1.0 + colorHighs[0]))/(1.0 + color[0]);
color[1] = (color.r * (1.0 + colorHighs[1]))/(1.0 + color[1]);
color[2]= (color[2] * (1.0 + colorHighs[2]))/(1.0 + color[2]);

float rgbLum = dot(color, srgbLuminance);
vec3 colorSat;
colorSat = saturation*color;
color = colorSat + omSat*rgbLum; 

gl_FragColor = vec4(color, 1.0);


I figured out the problem.
Just wanted to point out to others, that I used WebGL Inspector to debug and find what was wrong with my shader program.