Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: noise function, can't compile it!

  1. #1
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,264

    noise function, can't compile it!

    I'm sure this is a stupid problem.
    I wanted to use noise instead of a texture for doing marble, but it always gives a compilation error.

    //---------------- the line in the code
    /objVertex is vec4
    float o=noise(objVertex);
    //----------------

    ERROR: 0:65: 'noise' : no matching overloaded function found
    ERROR: 1 compilation errors. No code generated.

    and no matter what I try, it always gives that same error

    //ERROR
    float o=noise(vec3(objVertex));

    //ERROR
    float o=noise(vec2(objVertex));

    //ERROR
    float o=noise(float(objVertex));

    //ERROR
    vec3 o=noise(vec3(objVertex));


    and so on...

    Help!
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  2. #2
    Intern Contributor
    Join Date
    Sep 2001
    Location
    Lewisville, TX
    Posts
    93

    Re: noise function, can't compile it!

    What drivers are you using?

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    3,576

    Re: noise function, can't compile it!

    Many (read: most) implementations of glslang don't actually make noise work. Modern hardware doesn't have a facility for creating a real noise function, so they give a compile error.

  4. #4
    Intern Contributor
    Join Date
    Sep 2001
    Location
    Marlboro MA
    Posts
    90

    Re: noise function, can't compile it!

    Originally posted by V-man:
    I'm sure this is a stupid problem.
    I wanted to use noise instead of a texture for doing marble, but it always gives a compilation error.

    //---------------- the line in the code
    /objVertex is vec4
    float o=noise(objVertex);
    //----------------

    ERROR: 0:65: 'noise' : no matching overloaded function found
    ERROR: 1 compilation errors. No code generated.

    Help!
    The functions are
    float noise1( genType x )
    vec2 noise2( genType x )
    vec3 noise3( genType x )
    and
    vec4 noise4( genType x )
    .

    (Overloaded functions must differ in more than their return type, so the name tells how many components of noise to return.)

    -mr. bill

  5. #5
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,264

    Re: noise function, can't compile it!

    OK, those functions work. I was looking at the older documents. I guess ShaderSpecV1.051.pdf is the one I should use.

    More "slight" problems :

    Why do I get compiler errors for :

    float t;
    vec3 PP=//some value written;
    t=abs((float)noise3(PP));

    --------------------
    ERROR: 0:73: ')' : syntax error parse error
    --------------------

    But this works

    float t;
    vec3 PP=//some value written;
    t=abs(float(noise3(PP)));

    Could it be a compiler bug? I updated to Catalyst 4.2 and this problem remains.

    In C/C++ programming, I write both forms so I assumed the same rules apply.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  6. #6
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,453

    Re: noise function, can't compile it!

    >>In C/C++ programming, I write both forms so I assumed the same rules apply.<<

    They don't.
    BTW, if you want only a single float as return value you should use noise1().

    [This message has been edited by Relic (edited 03-09-2004).]

  7. #7
    Intern Contributor
    Join Date
    Sep 2001
    Location
    Marlboro MA
    Posts
    90

    Re: noise function, can't compile it!

    The OpenGL Shading Language uses constructors, not casts. (Casts are often ambiguous.) There are also no implicit type promotion casts.

    vec3 PP;
    float t;
    t = 2 * float( PP ); // wrong
    t = float(2)*float( PP ); // ok
    t = 2.0 * float( PP ); // ok
    t = 2.0 * PP.x; // ok

    But also, use noise1 in your example instead:

    vec3 PP;
    float t = noise1( PP ); // scalar noise is "cheaper" than vector noise!

    -mr. bill

  8. #8
    Junior Member Regular Contributor
    Join Date
    Jun 2000
    Location
    Portugal
    Posts
    214

    Re: noise function, can't compile it!

    I find this a bit strange....

    t = 2 * float( PP ); // wrong
    t = 2.0 * float( PP ); // ok
    I mean, isn't "2" a float?! I believe that any given integer anotation should be used (or at least not get compiler errors) since it can be considered a float.

    This problem was rather stupid because I compiled the shader in a FX and then, a friend of mine trying it out on a Radeon, got compiler erros simply because of 2 and not 2.0

    Is this annotation really necessary?! If so, why?

  9. #9
    Intern Contributor
    Join Date
    Sep 2001
    Location
    Marlboro MA
    Posts
    90

    Re: noise function, can't compile it!

    Originally posted by KRONOS:
    I find this a bit strange....

    I mean, isn't "2" a float?! I believe that any given integer anotation should be used (or at least not get compiler errors) since it can be considered a float.
    "2" is a literal integer constant. Not a float. "2." "2.0" "2E0" or "2e0" are floating-point constants.

    Quoting from The OpenGL Shading Language Version 1.051.

    "Compilers, in general, accept programs that are ill-formed.... Portability is ensured for well-formed programs, which this specification describes." p. 3

    "The OpenGL Shading Language is type safe. There are no implicit conversions between types." p. 13

    You might consider "2" a float. So would many other people. But currently it's not, and it's likely to stay a literal integer constant for some time.

    You are absolutely free to write non-portable shaders. Some implementations may even compile and execute them. But other implementations may not.

    The problem right now it is too easy to accidently write non-portable shaders.

    Perhaps some lint-like tools for the shading language are needed? (The OpenGL Shading Language Front-End Comiler Open Source might be a great start.)

    -mr. bill

    [This message has been edited by mrbill (edited 03-11-2004).]

  10. #10
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,932

    Re: noise function, can't compile it!

    It seems that Nvidia's implementation treats '2' as float. I find it more logical then '2.0'.

Posting Permissions

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