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: Faded reflection...

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2010
    Posts
    3

    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.


  2. #2
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    4,388

    Re: Faded reflection...

    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.

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2010
    Posts
    3

    Re: Faded reflection...

    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?

    Code :
    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);			
    glEnd();

  4. #4
    Junior Member Regular Contributor
    Join Date
    Feb 2004
    Posts
    249

    Re: Faded reflection...

    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.

  5. #5
    Junior Member Newbie
    Join Date
    Jan 2010
    Posts
    3

    Re: Faded reflection...

    Thanks for the reply, will try that.

Posting Permissions

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