I was wondering if anyone could provide guidance on creating reflections - in a simple way (like just reversing the texture and using alpha blending) but having extra effects like fade-out of the reflection intensity as it gets further away from the thing being reflected. I have coded the following, simple stuff:
Code: glLoadIdentity; glTranslatef (X,Y,Z); glBindTexture (GL_TEXTURE_2D,Tex5); glColor4f (1,1,1,1); glBegin (GL_QUADS); glTexCoord2f (0,0); glVertex3f (-1,-1,0); glTexCoord2f (1,0); glVertex3f (1,-1,0); glTexCoord2f (1,1); glVertex3f (1,1,0); glTexCoord2f (0,1); glVertex3f (-1,1,0); glEnd; glTranslatef (0,-2.1,0); glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glColor4f (1,1,1,0.20); glBegin (GL_QUADS); glTexCoord2f (0,1); glVertex3f (-1,-1,0); glTexCoord2f (1,1); glVertex3f (1,-1,0); glTexCoord2f (1,0); glVertex3f (1,1,0); glTexCoord2f (0,0); glVertex3f (-1,1,0); glEnd; glDisable (GL_BLEND);
Which produces something like this:
I think this looks quite effective; it's not terrible anyway. However, what I am wondering is whether I can make the bottom half of the reflected texture fade away even further into the background. Can I do this using any simple techniques or do I have to go into what I've seen referred to on other Internet articles - stencil buffers and suchlike? I'd prefer to keep it simple... or maybe use a trick... I was thinking like another texture blended over it that matches the white background - but the background could change. Any ideas appreciated - and code snippets showing me how are appreciated even more.
|