Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: GLSL Fresnel, can't find whats wrong...

  1. #1
    Advanced Member Frequent Contributor
    Join Date
    Nov 2002
    Location
    Latvia
    Posts
    626

    GLSL Fresnel, can't find whats wrong...

    This is what I draw:
    Code :
    glActiveTextureARB(GL_TEXTURE0_ARB);
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, Floor.id);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,/*GL_MIRRORED_REPEAT_ARB*/GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,/*GL_MIRRORED_REPEAT_ARB*/GL_REPEAT);
    if(GLSL)
    {
    glUseProgramObjectARB(FresnelGLSL);
    glUniform1iARB(glGetUniformLocationARB(BumpGLSL, "diffuse"), 0);
    glUniform3fARB(glGetUniformLocationARB(BumpGLSL, "eyepos"), px, py, pz);
    }
    glBegin(GL_QUADS);
    glColor4f(1,1,1,1);
    glNormal3f(0,1,0);
    for (tx=-16; tx<16; tx+=4)
    for (tz=-6; tz<6; tz+=4)
    if(Frustum.SphereInFrustum(tx+2, 0, tz+2, 2.83))
    {
    glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0, 0);
    glVertex3f(tx, 0, tz+4);
    glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 2, 0);
    glVertex3f(tx+4, 0, tz+4);
    glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 2, 2);
    glVertex3f(tx+4, 0, tz);
    glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0, 2);
    glVertex3f(tx, 0, tz);
    }
    glEnd();
    if(GLSL)
    glUseProgramObjectARB(0);
    and GLSL shaders
    VSH:
    Code :
    uniform vec3 eyepos;
    varying float f;
    void main(void)
    {
    vec3 vtol = vec3(0,1,0);
    vec3 vtoe = normalize(eyepos-gl_Position);
    vec3 hway = normalize(vtoe+vtol);
    float vdoth = dot(vtoe,hway);
    float f = pow((1-vdoth),4);
    gl_Position = mul(gl_ModelViewProjectionMatrix, gl_Vertex);
    gl_TexCoord[0] = gl_MultiTexCoord0;
    }
    FSH:
    Code :
    uniform sampler2D diffuse;
    varying float f;
    void main (void)
    {
    gl_FragColor.rgb = 1;//texture2D(diffuse, gl_TexCoord[0]);
    gl_FragColor.a = f;
    }
    and the screenie
    http://www.lapas.dau.lv/salitis/out.bmp
    It seems that I'm doing fresnel in object space, but gl_Vertex is given in world space & px,py,pz are eye pos in world space too -> (gluLookAt(px,py,pz,....

    I'm sure it's my bug, but after 2 nights of coding I'm stuck

  2. #2
    Junior Member Newbie
    Join Date
    Jun 2003
    Posts
    19

    Re: GLSL Fresnel, can't find whats wrong...

    glUseProgramObjectARB(FresnelGLSL);glUniform1iARB( glGetUniformLocationARB(BumpGLSL, "diffuse"), 0);glUniform3fARB(glGetUniformLocationARB(BumpGLSL , "eyepos"), px, py, pz);

    Did you mean to do the above or is it just a copy'n'paste mistake?
    (UseProgram FresnelGLSL, then BumpGLSL for the variables) I suppose that would explain why it looks like your screenshot.

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Nov 2002
    Location
    Latvia
    Posts
    626

    Re: GLSL Fresnel, can't find whats wrong...

    Goosh, frikin cpy'n'paste bug :'( Hate'em

    But the problem was:
    I MUST LEARN DIFFERENCE BETWEEN gl_Vertex & gl_Position!!!!, I MUST LEARN DIFFERENCE BETWEEN gl_Vertex & gl_Position!!!!, I MUST LEARN DIFFERENCE BETWEEN gl_Vertex & gl_Position!!!!, I MUST LEARN DIFFERENCE BETWEEN gl_Vertex & gl_Position!!!!, I MUST LEARN DIFFERENCE BETWEEN gl_Vertex & gl_Position!!!!, I MUST LEARN DIFFERENCE BETWEEN gl_Vertex & gl_Position!!!!, I MUST LEARN DIFFERENCE BETWEEN gl_Vertex & gl_Position!!!!, I MUST LEARN DIFFERENCE BETWEEN gl_Vertex & gl_Position!!!!, I MUST LEARN DIFFERENCE BETWEEN gl_Vertex & gl_Position!!!!, I MUST LEARN DIFFERENCE BETWEEN gl_Vertex & gl_Position!!!!, I MUST LEARN DIFFERENCE BETWEEN gl_Vertex & gl_Position!!!!, I MUST LEARN DIFFERENCE BETWEEN gl_Vertex & gl_Position!!!!, I MUST LEARN DIFFERENCE BETWEEN gl_Vertex & gl_Position!!!!, I MUST LEARN DIFFERENCE BETWEEN gl_Vertex & gl_Position!!!!, I MUST LEARN DIFFERENCE BETWEEN gl_Vertex & gl_Position!!!!, I MUST LEARN DIFFERENCE BETWEEN gl_Vertex & gl_Position!!!!


    [This message has been edited by M/\dm/\n (edited 02-23-2004).]

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

    Re: GLSL Fresnel, can't find whats wrong...

    Oh...
    I would love to buy you a beer but there is probably tousands of km separating us.

    Not a joke - i really mean it.

    [This message has been edited by Zengar (edited 02-23-2004).]

  5. #5
    Advanced Member Frequent Contributor
    Join Date
    Nov 2002
    Location
    Latvia
    Posts
    626

    Re: GLSL Fresnel, can't find whats wrong...

    You know, when you have fixed bug like this & everything runs and looks flawlessly you're so happy, that you even forget about beer

    Now me must go work on data structures for BM

Posting Permissions

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