Results 1 to 3 of 3

Thread: Shader compiles and attaches to program, but does not link

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    4

    Shader compiles and attaches to program, but does not link

    Hi,

    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));

    gl.validateProgram(shaderProgram);

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

    if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
    console.log("Could not initialize shaders");
    console.log(gl.getProgramInfoLog(shaderProgram));
    }

    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.

    Thanks.

  2. #2
    Junior Member
    Join Date
    Nov 2011
    Posts
    4

    Re: Shader compiles and attaches to program, but does not li

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

    #ifdef GL_ES
    precision highp float;
    #endif

    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);

    }

  3. #3
    Junior Member
    Join Date
    Nov 2011
    Posts
    4

    Re: Shader compiles and attaches to program, but does not li

    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.

Similar Threads

  1. Uniforms on a shader program used in multiple threads
    By TomCooksey in forum OpenGL ES 2X - for programmable 3D graphics pipelines
    Replies: 1
    Last Post: 09-14-2010, 09:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •