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 3 123 LastLast
Results 1 to 10 of 26

Thread: glslang problems

  1. #1
    Junior Member Regular Contributor
    Join Date
    Jan 2003
    Posts
    115

    glslang problems

    Hello,

    i have problems with the most simple glslang shaders

    Code :
    //vertex shader:
    varying	vec3	Normal;
     
    void main(void) {
    //Normal = gl_Normal;
    Normal = vec3(1.0, 1.0, 1.0);
    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
    }
     
    //fragment shader:
    varying vec3	Normal;
     
    void main(void) {
    gl_FragColor = vec4(Normal.x, Normal.y, Normal.z, 1.0);
    }
    with this Result .

    if I uncomment the 1st line in the vertex shader to change Normal to gl_Normal, the screen gets black.
    I check for open gl errors, the info log and validates the programm object but no errors messages.

    What can interfere in this way with the shader ? I've testet this shader with 3dlabs ogl2example and there were no problems. So I guess it's a problem in my framework. But i have no idea where. With fixed pipeline shading i had no problems.

    any ideas ?

  2. #2
    Member Regular Contributor
    Join Date
    Apr 2002
    Location
    Austria
    Posts
    328

    Re: glslang problems

    How do you pass the Normals to the GL? With glNormal3f() or with vertex arrays. I had a similar problem using vertex arrays. Try to define your own attribute:

    //vertex shader:
    attribute vec3 Normal;
    varying vec3 v2f_Normal;

    void main(void)
    {
    v2f_Normal = Normal;
    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
    }

    Maybe this will work
    There is a theory which states that if ever anybody discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.

    There is another theory which states that this has already happened...

  3. #3
    Junior Member Regular Contributor
    Join Date
    Jan 2003
    Posts
    115

    Re: glslang problems

    Originally posted by Corrail:
    How do you pass the Normals to the GL? With glNormal3f() or with vertex arrays. I had a similar problem using vertex arrays. Try to define your own attribute:
    Why are there also problems when i don't use the Vertex Normal but a constant value for the varying ? If the vertex normals are invalid, it shouldn't be a problem if i don't use them. I tried both, vertex arrays and glNormal3f, no difference, still the same problem.

    A can test it with own attribute but i doubt this will change something...

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

    Re: glslang problems

    Maybe a parser error?
    Try another name than "Normal"
    Or a cast error.
    Try vec4(myNormal, 1.0) instead of the three '.' references.

  5. #5
    Junior Member Regular Contributor
    Join Date
    Jan 2003
    Posts
    115

    Re: glslang problems

    Relic: I checked for compilation/linking errors. Other name or other cast: no difference.
    I've also checked with own vertex attribute. No difference.

    If I use glNormal/glVertex and
    Code :
    //vertex shader:
    varying	vec3	Normal;
    void main(void) {
    Normal = gl_Normal;
    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
    }
     
    //fragment shader:
    varying vec3 Normal;
    void main(void) {
    gl_FragColor = vec4(Normal.x, Normal.y, Normal.z, 1.0);
    }
    the screen get black. With vertex/normal array or attribute I get this Result (with the same scene/models as with first screenshot).

    I have absolutely no idea why the mesh get distorted although in the shader the gl_Position only depends on gl_Vertex and ModelViewProjection

    btw: I'm using ATI Radeon9800 np, Catalyst 3.10 and glew 1.1.4.

    [This message has been edited by valoh (edited 01-19-2004).]

  6. #6
    Junior Member Regular Contributor
    Join Date
    May 2003
    Location
    Germany
    Posts
    232

    Re: glslang problems

    I'm sure that your problem lies somewhere else, cause I've used normals in glSlang and never had any problems.
    I've just tested your shader in my samplapp, and I got the following (looking correct) shots : http://www.delphigl.de/normglslang.jpg http://www.delphigl.de/normglslang2.jpg

    (note that I replaced Normal = gl_Normal with Normal = gl_Normal * gl_NormalMatrix)

    Edit : Using a Radeon 9700 with Catalyst 3.10 on WinXP.

    [This message has been edited by PanzerSchreck (edited 01-19-2004).]

  7. #7
    Junior Member Regular Contributor
    Join Date
    Jan 2003
    Posts
    115

    Re: glslang problems

    Originally posted by PanzerSchreck:
    I'm sure that your problem lies somewhere else, cause I've used normals in glSlang and never had any problems.
    yeah, that's also my suspicion, but I am out of ideas where to look for the problem.

    The question is: what can interfere with glslang shaders in a way, that they are compiled and linked without problems, no OpenGL errors with glUseProgramObjectARB or validation but the rendering-result is only rubbish.

  8. #8
    Junior Member Regular Contributor
    Join Date
    Jan 2003
    Posts
    115

    Re: glslang problems

    for my shaders i use:
    Code :
    //construct programm
    _program_ID = glCreateProgramObjectARB();
    _vertex_shader_ID = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
    _fragment_shader_ID = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
    glAttachObjectARB(_program_ID,_vertex_shader_ID);
    glAttachObjectARB(_program_ID,_fragment_shader_ID);
    glShaderSourceARB(_vertex_shader_ID,1,&v_src,0);
    glShaderSourceARB(_fragment_shader_ID,1,&f_src,0);
     
    //....
     
    //build and bind
    glCompileShaderARB(_fragment_shader_ID);
    glCompileShaderARB(_vertex_shader_ID);
    glLinkProgramARB(_program_ID);
    glUseProgramObjectARB(_program_ID);
    anything forgotten ?

    I had in glEnable(GL_LIGHTING) in my render setup. If I remove this, the screen get black, else there are the described problems. Shouldn't the shading with glslang be independent from GL_LIGHTING ?

  9. #9
    Junior Member Regular Contributor
    Join Date
    Jan 2003
    Posts
    115

    Re: glslang problems

    Installing catalyst 4.1 has nothing changed.(Well I can't reproduce the mesh distortion right now, but still incorrect rendering).

    Now I have made a simple test and found something interesting:

    The first frame is rendered correct. All following frames are rendered incorrect. I tried to destroy and create, attach, recompile and link the shader in every frame drawing, but still incorrect renderings.
    What can be the cause that the first frame is rendered correct, all following not ?
    Fixed pipeline rendering is correct, every frame.

    btw: I'm using dotnet (Windows Forms) with managed c++. Can this make problems ?

  10. #10
    Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Spain
    Posts
    269

    Re: glslang problems

    Hello, i had compiled your shader and this is the result: http://www.typhoonlabs.com/~ffelagund/slang.jpg
    As you can see the sphere are right, your problem will be, with a 99% of posibilites, in the normals of the mesh. Your sphere aren't distorted (geometrically), only have colors bases on wrong normals.

    [This message has been edited by Ffelagund (edited 01-20-2004).]
    "I don't know... with a casual fly"

Posting Permissions

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