Results 1 to 4 of 4

Thread: Link error: "Could not pack varying"

  1. #1

    Link error: "Could not pack varying"

    My vertex and fragment shaders compile correctly on WebGL running Chrome Canary build. But I got the following shader link error:
    Code :
    Could not pack varying _v_lifetime
    With the following code snippets of my fragment shader
    // If the normal is facing the light
    if (NdotL > 0.0)
    {
    // Add the diffuse contribution
    color += v_diffuse * NdotL;

    // Re-normalize the half vector
    vec3 HV = normalize(v_halfVector);
    float NdotHV = max(dot(N, HV), 0.0);

    // Add the specular contribution
    color += material_specular * light0.specular * pow(NdotHV, material_shininess);
    }
    What does it mean?
    Where can I get info that document typical linker error?

    When I remove the following code snippets:
    // Re-normalize the half vector
    vec3 HV = normalize(v_halfVector);
    float NdotHV = max(dot(N, HV), 0.0);

    // Add the specular contribution
    color += material_specular * light0.specular * pow(NdotHV, material_shininess);
    The error disappears.

    Thanks in advance for your help.

  2. #2

    Re: Link error: "Could not pack varying"

    I found the problem.

    My vertex shader has the following code snippets:

    Code :
    varying vec3 v_halfVector;
    ...
    vec3 v_halfVector;             // This is the problem due to the re-declaration of v_halfVector
    ....

  3. #3

    Re: Link error: "Could not pack varying"

    I received the same error message again.

    It seems that there is a limit as how many varying variables you could use. See the discussions on http://www.opengl.org/discussion_boa...&Number=237438

    After reducing the number of varying variables, the error message disappears.

  4. #4
    Senior Member
    Join Date
    May 2010
    Posts
    207

    Re: Link error: "Could not pack varying"

    Yes - "varying" variables are interpolated between the vertices of the triangle, each varying requires a significant chunk of circuitry in the GPU and has to run for every pixel you draw - so there can't be a really large number of them.

    Most DirectX/OpenGL implementations limit you to 12 or 13 vec4's...but on low end hardware, it's possible that you might have a less. Since WebGL runs on top of the native DirectX/OpenGL right now, you're going to hit that limit if you aren't careful.

    If you are using less than a vec4 (eg if you have two sets of vec2 texture coordinates) then you should try to pack them (so put one texture coordinate into the .xy part of the varying - and the other texture coordinate into the .zw part).

    A clearer error message would have been nice though!

    -- Steve

Similar Threads

  1. a question about the "Varying" storage qualifier
    By qqca in forum OpenGL ES 2X - for programmable 3D graphics pipelines
    Replies: 1
    Last Post: 11-16-2007, 04:39 AM
  2. "required extension" and "core addition"
    By wycwang in forum OpenGL ES general technical discussions
    Replies: 2
    Last Post: 09-19-2007, 02:11 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
  •