GLSL Fresnel, can't find whats wrong

This is what I draw:

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:

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:

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

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.

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/
(edited 02-23-2004).]

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).]

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

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.