Results 1 to 3 of 3

Thread: GLES shader won't compile on iphone

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    5

    GLES shader won't compile on iphone

    This makes no sense. My shader won't build on the iphone, citing a link error that is wrong. See below:

    Code :
    **Link failure!!**
    Log contents: 
    ERROR: No 'main()' function found in linked vertex shaders.
    ERROR: No 'main()' function found in linked fragment shaders.
     
    Shaders attached: 4
     
    --Fragment shader--
    precision mediump float;
     
    vec4 ShadeFragment();
     
    void main()
    {
    	gl_FragColor = ShadeFragment();
    }
     
    --Vertex shader--
    //precision mediump float;
     
    vec4 ShadeVertex();
     
    void main()
    {
    	gl_Position = ShadeVertex();
    }
     
     
    --Vertex shader--
    //#version 120
    //#extension GL_EXT_gpu_shader4 : enable
     
    precision mediump float;
     
    uniform mat4 ModelViewMatrix;
    uniform mat4 ModelViewProjMatrix;
    uniform mat4 NormalMatrix;
    uniform vec4 Color;
     
    attribute vec4 Vertex;
    attribute vec4 Normal;
     
    varying vec4 out_color;
     
    /*******************************************************
    *  Fixed.vert Fixed Function Equivalent Vertex Shader  *
    *   Automatically Generated by 3Dlabs GLSL ShaderGen   *
    *             [url]http://developer.3dlabs.com[/url]              *
    *******************************************************/
    vec4 Ambient;
    vec4 Diffuse;
    vec4 Specular;
     
     
    void pointLight(in int i, in vec3 normal, in vec3 eye, in vec3 ecPosition3)
    {
       float nDotVP;       // normal . light direction
       float nDotHV;       // normal . light half vector
       float pf;           // power factor
       float attenuation;  // computed attenuation factor
       float d;            // distance from surface to light source
       vec3  VP;           // direction from surface to light position
       vec3  halfVector;   // direction of maximum highlights
     
       // Compute vector from surface to light position
       VP = vec3 (0,0,1) - ecPosition3;
     
       // Compute distance between surface and light position
       d = length(VP);
     
       // Normalize the vector from surface to light position
       VP = normalize(VP);
     
       // Compute attenuation
       attenuation = 1.0;
     
       halfVector = normalize(VP + eye);
     
       nDotVP = max(0.0, dot(normal, VP));
       nDotHV = max(0.0, dot(normal, halfVector));
     
       if (nDotVP == 0.0)
       {
           pf = 0.0;
       }
       else
       {
           pf = pow(nDotHV, 100.0);
       }
       Ambient  += vec4(0);
       Diffuse  += vec4(1,1,1,1) * nDotVP;
       Specular += vec4(1,1,1,1) * pf;
    }
     
    vec3 fnormal(void)
    {
        //Compute the normal 
        vec3 normal = (NormalMatrix * Normal).xyz;
        normal = normalize(normal);
        return normal;
    }
     
    void flight(in vec3 normal, in vec4 ecPosition, float alphaFade)
    {
        vec4 color;
        vec3 ecPosition3;
        vec3 eye;
     
        ecPosition3 = (vec3 (ecPosition)) / ecPosition.w;
        eye = vec3 (0.0, 0.0, 1.0);
     
        // Clear the light intensity accumulators
        Ambient  = vec4 (0.0);
        Diffuse  = vec4 (0.0);
        Specular = vec4 (0.0);
     
        pointLight(0, normal, eye, ecPosition3);
     
        color = Ambient*vec4(0.2, 0.2, 0.2, 1.0) +
                Diffuse*Color;
        color += Specular;
        color = clamp( color, 0.0, 1.0 );
        out_color = color;
     
        out_color.a *= alphaFade;
    }
     
     
    vec4 ShadeVertex()
    {
        vec3  transformedNormal;
        float alphaFade = 1.0;
     
        // Eye-coordinate position of vertex, needed in various calculations
        vec4 ecPosition = ModelViewMatrix * Vertex;
     
        // Do fixed functionality vertex transform
        transformedNormal = fnormal();
        flight(transformedNormal, ecPosition, alphaFade);
        return ModelViewProjMatrix * Vertex;	
    }
     
     
    --Fragment shader--
    //#version 120
    //#extension GL_EXT_gpu_shader4 : enable
     
    precision mediump float;
    varying vec4 out_color;
     
    /*******************************************************
    * Fixed.frag Fixed Function Equivalent Fragment Shader *
    *   Automatically Generated by 3Dlabs GLSL ShaderGen   *
    *             [url]http://developer.3dlabs.com[/url]              *
    *******************************************************/
     
    vec4 ShadeFragment() 
    {
        return out_color;
    }

    Did apple screw up the OpenGLES 2.0 implementation on the iphone simulator?

  2. #2
    Junior Member
    Join Date
    Feb 2010
    Posts
    5

    Re: GLES shader won't compile on iphone

    apparently opengl es cannot link multiple shaders, so I had to merge the source files.

    wow, so many limitations on gles

  3. #3
    Senior Member
    Join Date
    May 2006
    Posts
    353

    Re: GLES shader won't compile on iphone

    Since you can pass multiple strings to glShaderSource, that should be quite easy to handle.

    By the way, I'd recommend using highp precision for vertex position calculations. While mediump is sufficient for most other uses (and out_color could be lowp), vertex transformations often cause problems with anything less than highp.
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

Similar Threads

  1. pointer type conversion in kernel won't work
    By sanderbeckers in forum OpenCL
    Replies: 3
    Last Post: 03-11-2011, 08:59 AM

Posting Permissions

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