PDA

View Full Version : Reflections



Vlasko
03-02-2004, 01:46 PM
I'm trying to learne from lesson26 on nehe but I run into a problem - i see the object i see the floor but i don't see the reflection
code:
double eqr[] = {0.0f,-1.0f, 0.0f, 0.0f};
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f,-0.6f,-4.0f);
glColorMask(0,0,0,0);
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS, 1, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
glDisable(GL_DEPTH_TEST);
drawfloor();
glEnable(GL_DEPTH_TEST); e
glColorMask(1,1,1,1);
glStencilFunc(GL_EQUAL, 1, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glEnable(GL_CLIP_PLANE0);
glClipPlane(GL_CLIP_PLANE0, eqr);
glPushMatrix();
glScalef(1.0f,-1.0f,1.0f); s y
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
glTranslatef(0.0f, height, 0.0f); drawobject();
glPopMatrix();
glDisable(GL_CLIP_PLANE0);
glDisable(GL_STENCIL_TEST);
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
glEnable(GL_BLEND);
glDisable(GL_LIGHTING);
glColor4f(1.0f, 1.0f, 1.0f, 0.8f); //color 80% Alpha reflection 20% floor ???
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
drawfloor();
glEnable(GL_LIGHTING);
glDisable(GL_BLEND); e )
glTranslatef(0.0f, height, 0.0f);
drawobject();
glutSwapBuffers();

Nychold
03-03-2004, 07:13 AM
I think you're out of order here:



glScalef(1.0f,-1.0f,1.0f);
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
glTranslatef(0.0f, height, 0.0f);
drawobject();


Try this instead:


glScalef(1.0f,-1.0f,1.0f);
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
glTranslatef(0.0f, -height, 0.0f);
drawobject();


or



glTranslatef(0.0f, height, 0.0f);
glScalef(1.0f,-1.0f,1.0f);
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
drawobject();

Vlasko
03-03-2004, 01:06 PM
That part of a code draws reflection which is under the floor so it should be ok(tested also-not working)

Vlasko
03-06-2004, 04:18 AM
Can anyone help ? it seems that the floor is the problem - if i don't draw it i see the reflection

Vlasko
03-06-2004, 04:20 AM
Ok working now I was just setting color for blending without alpha thanks anyway