Faded reflection...

I have a cube that i have drawn a reflection for using the stencil buffer. I am using nehe.gamedev.net tutorial 26. The problem i have is that the reflection is a full length one. I am trying to create a reflection effect similar to ipod/apple coverflow thing. Anyone know how to achieve a faded out reflection? added an example below…faded refelection part is what i am looking for, i have got the reflection itself working.

Technically the reflection intensity is governed by Fresnel’s law.

For your scene you could render the reflective surface black with transparency as a function of View.Normal for the reflective surface and generate an effect similar to coverflow. Alternatively you could calculate what the modulation should be per vertex or pixel as you render the cube, that should be possible for a simple planar surface.

Coverflow just draws quads with fixed black vertices so it’s a trivial (and incorrect) hack.

In the book “More OpenGL Game Programming” Chapter 8, I describe and implement the equations necessary to get the reflection (and refraction) coefficients correct to modulate reflective and refractive terms.

Let me be sure i know what you mean…

Your first method means the dot product between the reflective surface normal and the vector to the camera( normalised), the dot product is then passed to glColor4f(0.0f,0.0f,0.0f,fDotProductHere); of the reflective surface?

Your second method is the code below, where when i render the cube to the stencil buffer i apply a color per vertex with an alpha value, thus allowing me to fade out the cube reflection. for the normal render pass of the cube, i disable the color values. Will glColor4f() alpha value work on textures?

glBegin(GL_TRIANGLES);						glColor4f(1.0f,0.0f,0.0f,1.0f);			
glVertex3f( 0.0f, 1.0f, 0.0f);					glColor4f(0.0f,1.0f,0.0f,1.0f);			
glVertex3f(-1.0f,-1.0f, 0.0f);			glColor4f(0.0f,0.0f,1.0f,1.0f);			
glVertex3f( 1.0f,-1.0f, 0.0f);			

For your example without using shaders and a black background you can simply set the vertex color of your top vertices to black (in your stencil pass).
The interpolated vertex colors will be multiplied by your texture color, giving you a linear blend to black.

Thanks for the reply, will try that.